-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Open
pringelmann
wants to merge
6
commits into
master
Choose a base branch
from
feat/noid/appmenu-priority-loading
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−54
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e790954
refactor(core): move AppMenu component tree into core/src/appmenu/
pringelmann 4aecbff
feat(core): add standalone AppMenu bootstrap
pringelmann c9c59cd
refactor(core): drop legacy MainMenu mount
pringelmann c968e27
build(core): register core-appmenu as a webpack entry
pringelmann 014f7a4
feat(core): load AppMenu as a deferred core script
pringelmann e1a531a
refactor(core): namespace AppMenu under components/AppMenu
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,39 @@ | ||
| /*! | ||
| * 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 Vue from 'vue' | ||
| import AppMenu from './components/AppMenu/AppMenu.vue' | ||
|
|
||
| interface AppMenuInstance { | ||
| setNavigationCounter(id: string, counter: number): void | ||
| } | ||
|
|
||
| declare global { | ||
| var OC: { | ||
| setNavigationCounter?: (id: string, counter: number) => void | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Mount the AppMenu into the header container, if present on this layout. | ||
| */ | ||
| function mount(): void { | ||
| const container = document.getElementById('header-start__appmenu') | ||
| if (!container) { | ||
| // No container on this layout (e.g. public pages). Nothing to mount. | ||
| return | ||
| } | ||
| const AppMenuApp = Vue.extend(AppMenu) | ||
| const instance = new AppMenuApp({}).$mount(container) as unknown as AppMenuInstance | ||
|
|
||
| globalThis.OC = globalThis.OC ?? {} | ||
| globalThis.OC.setNavigationCounter = (id, counter) => { | ||
| instance.setNavigationCounter(id, counter) | ||
| } | ||
| } | ||
|
|
||
| mount() |
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,67 @@ | ||
| /*! | ||
| * 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: () => [], | ||
| })) | ||
| vi.mock('@nextcloud/auth', () => ({ | ||
| getCurrentUser: () => ({ isAdmin: false }), | ||
| })) | ||
| vi.mock('@nextcloud/event-bus', () => ({ | ||
| subscribe: () => undefined, | ||
| unsubscribe: () => undefined, | ||
| })) | ||
| vi.mock('@nextcloud/l10n', () => ({ | ||
| isRTL: () => false, | ||
| n: (_app: string, singular: string) => singular, | ||
| t: (_app: string, text: string) => text, | ||
| })) | ||
| vi.mock('@nextcloud/router', () => ({ | ||
| generateUrl: (url: string) => url, | ||
| imagePath: (_app: string, file: string) => `/img/${file}`, | ||
| })) | ||
|
|
||
| declare global { | ||
| var OC: { setNavigationCounter?: (id: string, count: number) => void } | ||
| } | ||
|
|
||
| // The id the bootstrap mounts into (must match main.ts). | ||
| function addContainer(): void { | ||
| const container = document.createElement('nav') | ||
| container.id = 'header-start__appmenu' | ||
| document.body.appendChild(container) | ||
| } | ||
|
|
||
| describe('core: appmenu', () => { | ||
| beforeEach(() => { | ||
| document.body.innerHTML = '' | ||
| globalThis.OC = {} | ||
| vi.resetModules() | ||
| }) | ||
|
|
||
| it('mounts AppMenu when the container is present', async () => { | ||
| addContainer() | ||
|
|
||
| await import('../appmenu.ts') | ||
|
|
||
| // Vue 2 $mount replaces the container with AppMenu's root <nav class="app-menu">. | ||
| expect(document.querySelector('.app-menu')).not.toBeNull() | ||
| }) | ||
|
|
||
| it('no-ops when the container is missing', async () => { | ||
| await import('../appmenu.ts') | ||
|
|
||
| expect(document.body.children.length).toBe(0) | ||
| }) | ||
|
|
||
| it('exposes OC.setNavigationCounter as a callable function', async () => { | ||
| addContainer() | ||
|
|
||
| await import('../appmenu.ts') | ||
|
|
||
| expect(typeof globalThis.OC.setNavigationCounter).toBe('function') | ||
| }) | ||
| }) |
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.