Repository navigation
refactor(core): move AppMenu component tree into core/src/appmenu/ #60937
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c1868c9
refactor(core): namespace AppMenu under components/AppMenu
pringelmann 03cc289
feat(core): add standalone AppMenu bootstrap
pringelmann 29bd9ff
refactor(core): drop legacy MainMenu mount
pringelmann 511249b
build(core): register core-appmenu as a vite entry
pringelmann e8586db
feat(core): load AppMenu as a deferred core script
pringelmann 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,23 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| * | ||
| * Standalone entry for the waffle launcher (AppMenu). Mounts independently of | ||
| * core-main so the app grid lives in its own chunk. | ||
| */ | ||
|
|
||
| import { createApp } from 'vue' | ||
| import AppMenu from './components/AppMenu/AppMenu.vue' | ||
| import { mountInPlace } from './utils/mountInPlace.ts' | ||
|
|
||
| const placeholder = document.getElementById('header-start__appmenu') | ||
| // No placeholder on layouts without the app menu, e.g. public pages. | ||
| if (placeholder) { | ||
| const appMenu = mountInPlace(createApp(AppMenu), placeholder) as InstanceType<typeof AppMenu> | ||
|
|
||
| Object.assign(window.OC, { | ||
| setNavigationCounter(id: string, counter: number) { | ||
| appMenu.setNavigationCounter(id, counter) | ||
| }, | ||
| }) | ||
| } |
File renamed without changes.
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
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
This file was deleted.
Oops, something went wrong.
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,84 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock('@nextcloud/initial-state', () => ({ | ||
| loadState: (_app: string, key: string, fallback: unknown) => key === 'apps' | ||
| ? [{ id: 'files', app: 'files', active: false, order: 0, href: '/apps/files', icon: '/apps/files/img/app.svg', type: 'link', name: 'Files', unread: 0 }] | ||
| : fallback, | ||
| })) | ||
| vi.mock('@nextcloud/auth', () => ({ | ||
| getCurrentUser: () => ({ isAdmin: false }), | ||
| })) | ||
| vi.mock('@nextcloud/event-bus', () => ({ | ||
| subscribe: () => undefined, | ||
| unsubscribe: () => undefined, | ||
| })) | ||
| vi.mock('@nextcloud/router', () => ({ | ||
| generateUrl: (path: string) => path, | ||
| imagePath: (app: string, file: string) => `/${app}/img/${file}`, | ||
| })) | ||
|
|
||
| const logger = vi.hoisted(() => ({ | ||
| warn: vi.fn(), | ||
| })) | ||
| vi.mock('../utils/logger.ts', () => ({ logger })) | ||
|
|
||
| type SetNavigationCounter = (id: string, counter: number) => void | ||
|
|
||
| /** | ||
| * Get the counter setter the app menu adds to the OC global, if any. | ||
| */ | ||
| function getSetNavigationCounter(): SetNavigationCounter | undefined { | ||
| return (window.OC as { setNavigationCounter?: SetNavigationCounter }).setNavigationCounter | ||
| } | ||
|
|
||
| /** | ||
| * Add the placeholder the app menu is mounted in place of. | ||
| */ | ||
| function addPlaceholder(): void { | ||
| const placeholder = document.createElement('nav') | ||
| placeholder.id = 'header-start__appmenu' | ||
| document.body.appendChild(placeholder) | ||
| } | ||
|
|
||
| describe('core: appmenu', () => { | ||
| beforeEach(() => { | ||
| document.body.innerHTML = '' | ||
| window.OC = {} as typeof window.OC | ||
| logger.warn.mockClear() | ||
| vi.resetModules() | ||
| }) | ||
|
|
||
| it('mounts the app menu in place of the placeholder', async () => { | ||
| addPlaceholder() | ||
|
|
||
| await import('../appmenu.ts') | ||
|
|
||
| expect(document.querySelector('.app-menu')).not.toBeNull() | ||
| expect(document.getElementById('header-start__appmenu')).toBeNull() | ||
| }) | ||
|
|
||
| it('does nothing without the placeholder', async () => { | ||
| await import('../appmenu.ts') | ||
|
|
||
| expect(document.body.children.length).toBe(0) | ||
| expect(getSetNavigationCounter()).toBeUndefined() | ||
| }) | ||
|
|
||
| it('forwards OC.setNavigationCounter to the app menu', async () => { | ||
| addPlaceholder() | ||
|
|
||
| await import('../appmenu.ts') | ||
|
|
||
| const setNavigationCounter = getSetNavigationCounter()! | ||
| setNavigationCounter('files', 3) | ||
| expect(logger.warn).not.toHaveBeenCalled() | ||
|
|
||
| setNavigationCounter('unknown', 3) | ||
| expect(logger.warn).toHaveBeenCalledOnce() | ||
| }) | ||
| }) |
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
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
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.