Repository navigation
feat(applications): standalone application shell with its own menu #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import type { Page } from '@playwright/test' | ||
| import { test, expect } from '../support/fixtures' | ||
| import { ocsRequest, type TestUser } from '../support/api' | ||
|
|
||
| /** | ||
| * Creates a grid view and an application whose menu opens it, through the API. | ||
| * | ||
| * @param page the page of the test user | ||
| * @param user the test user | ||
| * @param name name of the application | ||
| * @param pageTitle title of the grid view, and label of its menu item | ||
| */ | ||
| async function createApplicationWithGridPage(page: Page, user: TestUser, name: string, pageTitle: string) { | ||
| const viewResponse = await ocsRequest(page.request, user, { | ||
| method: 'POST', | ||
| url: '/ocs/v2.php/apps/tables/api/2/views?format=json', | ||
| data: { title: pageTitle }, | ||
| }) | ||
| const view = (await viewResponse.json()).ocs.data | ||
| const contextResponse = await ocsRequest(page.request, user, { | ||
| method: 'POST', | ||
| url: '/ocs/v2.php/apps/tables/api/2/contexts?format=json', | ||
| data: { | ||
| name, | ||
| iconName: 'star', | ||
| menuItems: [{ label: pageTitle, targetType: 'view', targetId: view.id }], | ||
| }, | ||
| }) | ||
| return (await contextResponse.json()).ocs.data | ||
| } | ||
|
|
||
| test.describe('Applications', () => { | ||
| test('An application opened on its own shows its menu and its first page', async ({ userPage: { page, user } }) => { | ||
| const context = await createApplicationWithGridPage(page, user, 'standalone application', 'Front page') | ||
|
|
||
| await page.goto(`/index.php/apps/tables/app/${context.id}`) | ||
|
|
||
| await expect(page.locator('[data-cy="application-nav-header"]')).toContainText('standalone application') | ||
| await expect(page.locator('[data-cy="application-nav-item"]').filter({ hasText: 'Front page' })).toBeVisible() | ||
| await expect(page).toHaveURL(/\/menu\/front_page$/) | ||
| await expect(page.locator('[data-cy="gridViewHeading"]')).toContainText('Front page') | ||
| await expect(page.locator('[data-cy="navigationCreateTableIcon"]')).toHaveCount(0) | ||
| // Nothing focused the content area before the person touched the page, so no focus ring is drawn around it | ||
| expect(await page.evaluate(() => document.activeElement?.id ?? '')).not.toBe('app-content-vue') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
src/modules/navigation/sections/ApplicationNavigation.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
| <template> | ||
| <NcAppNavigation :aria-label="context ? context.name : t('tables', 'Application')"> | ||
| <template #list> | ||
| <NcLoadingIcon v-if="!context" :size="32" /> | ||
| <template v-else> | ||
| <div class="application-navigation__header" data-cy="application-nav-header"> | ||
| <ApplicationIcon :icon-name="context.iconName" :size="32" /> | ||
| <div class="application-navigation__title"> | ||
| <strong>{{ context.name }}</strong> | ||
| <span v-if="context.description" class="application-navigation__description">{{ context.description }}</span> | ||
| </div> | ||
| </div> | ||
| <NcAppNavigationItem v-for="branch in menuTree" | ||
| :key="branch.item.id" | ||
| :name="branch.item.label" | ||
| :to="branch.item.targetType === 'url' ? undefined : menuItemRoute(branch.item, context.id)" | ||
| :href="branch.item.targetType === 'url' ? branch.item.url : undefined" | ||
| :class="{ active: isActive(branch.item) }" | ||
| :allow-collapse="branch.children.length > 0" | ||
| :open="branch.children.some(child => isActive(child))" | ||
| data-cy="application-nav-item"> | ||
| <template #icon> | ||
| <MenuItemIcon :item="branch.item" /> | ||
| </template> | ||
| <template v-if="branch.children.length > 0"> | ||
| <NcAppNavigationItem v-for="child in branch.children" | ||
| :key="child.id" | ||
| :name="child.label" | ||
| :to="child.targetType === 'url' ? undefined : menuItemRoute(child, context.id)" | ||
| :href="child.targetType === 'url' ? child.url : undefined" | ||
| :class="{ active: isActive(child) }" | ||
| data-cy="application-nav-item"> | ||
| <template #icon> | ||
| <MenuItemIcon :item="child" /> | ||
| </template> | ||
| </NcAppNavigationItem> | ||
| </template> | ||
| </NcAppNavigationItem> | ||
| <NcAppNavigationItem v-if="hasResources" | ||
| :name="t('tables', 'Overview')" | ||
| :to="'/application/' + context.id" | ||
| :class="{ active: !$route.params.itemName }" | ||
| data-cy="application-nav-overview"> | ||
| <template #icon> | ||
| <ViewGridOutline :size="20" /> | ||
| </template> | ||
| </NcAppNavigationItem> | ||
| </template> | ||
| </template> | ||
| <template #footer> | ||
| <div v-if="context && ownsContext(context)" class="application-navigation__footer"> | ||
| <NcButton variant="tertiary" :href="configurationUrl" data-cy="application-nav-configure"> | ||
| <template #icon> | ||
| <CogOutline :size="20" /> | ||
| </template> | ||
| {{ t('tables', 'Configure in Tables') }} | ||
| </NcButton> | ||
| </div> | ||
| </template> | ||
| </NcAppNavigation> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { NcAppNavigation, NcAppNavigationItem, NcButton, NcLoadingIcon } from '@nextcloud/vue' | ||
| import CogOutline from 'vue-material-design-icons/CogOutline.vue' | ||
| import ViewGridOutline from 'vue-material-design-icons/ViewGridOutline.vue' | ||
| import { generateUrl } from '@nextcloud/router' | ||
| import { mapState } from 'pinia' | ||
| import ApplicationIcon from '../../../shared/components/ApplicationIcon.vue' | ||
| import MenuItemIcon from '../../../shared/components/MenuItemIcon.vue' | ||
| import permissionsMixin from '../../../shared/components/ncTable/mixins/permissionsMixin.js' | ||
| import { menuItemRoute, menuTree } from '../../../shared/utils/menuItems.js' | ||
| import { NODE_TYPE_TABLE } from '../../../shared/constants.ts' | ||
| import { useTablesStore } from '../../../store/store.js' | ||
|
|
||
| /** | ||
| * The navigation of an application opened on its own: its menu items are the entries. | ||
| */ | ||
| export default { | ||
| name: 'ApplicationNavigation', | ||
| components: { | ||
| NcAppNavigation, | ||
| NcAppNavigationItem, | ||
| NcButton, | ||
| NcLoadingIcon, | ||
| CogOutline, | ||
| ViewGridOutline, | ||
| ApplicationIcon, | ||
| MenuItemIcon, | ||
| }, | ||
| mixins: [permissionsMixin], | ||
| computed: { | ||
| ...mapState(useTablesStore, ['activeContext', 'views']), | ||
| context() { | ||
| return this.activeContext | ||
| }, | ||
| menuItems() { | ||
| return [...(this.context?.menuItems ?? [])].sort((a, b) => a.order - b.order) | ||
| }, | ||
| menuTree() { | ||
| return menuTree(this.menuItems) | ||
| }, | ||
| /** | ||
| * Whether the overview has a table or view to show. A grid view is a page of its own, reached | ||
| * through the menu, so it does not count. | ||
| * | ||
| * @return {boolean} | ||
| */ | ||
| hasResources() { | ||
| return Object.values(this.context?.nodes ?? {}).some(node => parseInt(node.node_type) === NODE_TYPE_TABLE | ||
| || this.views.find(view => view.id === node.node_id)?.type !== 'grid') | ||
| }, | ||
| configurationUrl() { | ||
| return generateUrl('/apps/tables/') + '#/application/' + this.context.id | ||
| }, | ||
| }, | ||
| methods: { | ||
| menuItemRoute, | ||
| isActive(item) { | ||
| return item.targetType !== 'url' && this.$route.params.itemName === item.technicalName | ||
| }, | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .application-navigation { | ||
| &__header { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: calc(3 * var(--default-grid-baseline)); | ||
| padding: calc(3 * var(--default-grid-baseline)) calc(4 * var(--default-grid-baseline)); | ||
| } | ||
|
|
||
| &__title { | ||
| display: flex; | ||
| flex-direction: column; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| &__description { | ||
| color: var(--color-text-maxcontrast); | ||
| font-size: 0.9em; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| &__footer { | ||
| padding: calc(2 * var(--default-grid-baseline)); | ||
| } | ||
| } | ||
| </style> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.