-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
feat: add navigation actions to the waffle menu #63134
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
susnux
wants to merge
2
commits into
master
Choose a base branch
from
feat/navigation-actions
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.
Open
Changes from all commits
Commits
Show all changes
2 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
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,107 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import IconPlus from 'vue-material-design-icons/Plus.vue' | ||
|
|
||
| const props = defineProps<{ | ||
| /** URL of the icon, painted as-is so the colors of the action are kept. */ | ||
| icon?: string | ||
| /** Color of the indicator; without one no indicator is rendered. */ | ||
| color?: string | ||
| }>() | ||
|
|
||
| // Escaped so a crafted path cannot break out of the url() token. | ||
| const iconStyle = computed(() => ({ | ||
| '--app-action-icon-url': `url("${(props.icon ?? '').replace(/["\\]/g, '\\$&')}")`, | ||
| })) | ||
|
|
||
| const indicatorStyle = computed(() => ({ | ||
| '--app-action-icon-indicator-color': props.color, | ||
| })) | ||
| </script> | ||
|
|
||
| <template> | ||
| <span class="app-action-icon"> | ||
| <!-- @slot Icon to render instead of the `icon` URL, e.g. an inline icon component. --> | ||
| <slot> | ||
| <span | ||
| v-if="icon" | ||
| class="app-action-icon__img" | ||
| :style="iconStyle" | ||
| aria-hidden="true" /> | ||
| </slot> | ||
| <span | ||
| v-if="color" | ||
| class="app-action-icon__indicator" | ||
| :style="indicatorStyle" | ||
| aria-hidden="true"> | ||
| <IconPlus /> | ||
| </span> | ||
| </span> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .app-action-icon { | ||
| // Consumers size the icon through --app-action-icon-size, see AppMenuItem. | ||
| --app-action-icon-glyph-size: calc(var(--app-action-icon-size, calc(var(--default-grid-baseline) * 12)) * 0.8); | ||
| position: relative; | ||
| box-sizing: border-box; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| width: var(--app-action-icon-size, calc(var(--default-grid-baseline) * 12)); | ||
| height: var(--app-action-icon-size, calc(var(--default-grid-baseline) * 12)); | ||
| transform: scale(var(--app-icon-scale, 1)); | ||
| transition: transform var(--animation-quick) ease-out; | ||
|
|
||
| @media (prefers-reduced-motion: reduce) { | ||
| transition: none; | ||
| } | ||
|
|
||
| &__img { | ||
| width: var(--app-action-icon-glyph-size); | ||
| height: var(--app-action-icon-glyph-size); | ||
| background: var(--app-action-icon-url) center / contain no-repeat; | ||
| } | ||
|
|
||
| // Slotted icon components ship their own SVG dimensions. | ||
| :deep(.material-design-icon) { | ||
| width: var(--app-action-icon-glyph-size); | ||
| height: var(--app-action-icon-glyph-size); | ||
|
|
||
| svg { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
| } | ||
|
|
||
| &__indicator { | ||
| --app-action-icon-indicator-size: max(12px, calc(var(--app-action-icon-size, calc(var(--default-grid-baseline) * 12)) * 0.36)); | ||
| position: absolute; | ||
| inset-block-end: 0; | ||
| inset-inline-end: 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| width: var(--app-action-icon-indicator-size); | ||
| height: var(--app-action-icon-indicator-size); | ||
| border-radius: 50%; | ||
| background-color: var(--app-action-icon-indicator-color); | ||
| // Separates the indicator from the icon underneath. | ||
| border: 2px solid var(--color-main-background); | ||
| box-sizing: content-box; | ||
| // The indicator color is app-provided and saturated, so the glyph on top | ||
| // of it cannot follow the theme text color. | ||
| color: #fff; | ||
|
|
||
| :deep(svg) { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
| } | ||
| } | ||
| </style> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
|
|
||
| <script setup lang="ts"> | ||
| import type { INavigationEntry } from '../types/navigation.d.ts' | ||
|
|
||
| import { emit as emitOnEventBus } from '@nextcloud/event-bus' | ||
| import { computed } from 'vue' | ||
| import AppActionIcon from './AppActionIcon.vue' | ||
| import AppMenuItem from './AppMenuItem.vue' | ||
|
|
||
| const props = withDefaults(defineProps<{ | ||
| /** The navigation action to render (INavigationManager::TYPE_ACTION entry). */ | ||
| action: INavigationEntry | ||
| /** Render as a one-line list row instead of a tile (used in the overflow menu). */ | ||
| compact?: boolean | ||
| /** Roving-tabindex value, see AppMenuItem. */ | ||
| tabindex?: number | ||
| }>(), { | ||
| tabindex: -1, | ||
| }) | ||
|
|
||
| const emit = defineEmits<{ | ||
| /** Emitted after the action was activated, so the app menu can close. */ | ||
| (event: 'click', mouseEvent: MouseEvent): void | ||
| }>() | ||
|
|
||
| // `href` is required by NavigationManager, so handler-only actions carry an | ||
| // empty string or "#" as placeholder. | ||
| const hasLink = computed(() => Boolean(props.action.href) && props.action.href !== '#') | ||
|
|
||
| // AppMenuItem picks the element by `href`, so the placeholder has to be | ||
| // stripped for handler-only actions to render as a <button>. | ||
| const entry = computed<INavigationEntry>(() => hasLink.value | ||
| ? props.action | ||
| : { ...props.action, href: '' }) | ||
|
|
||
| /** | ||
| * Actions with a link simply navigate. Actions without one are implemented in | ||
| * JavaScript by the registering app, which listens on the event bus. | ||
| * | ||
| * @param mouseEvent - The click event of the underlying item | ||
| */ | ||
| function onClick(mouseEvent: MouseEvent): void { | ||
| if (!hasLink.value) { | ||
| emitOnEventBus('core:navigation:action', props.action) | ||
| } | ||
| emit('click', mouseEvent) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <AppMenuItem | ||
| :app="entry" | ||
| :compact="compact" | ||
| :tabindex="tabindex" | ||
| @click="onClick"> | ||
| <template #icon> | ||
| <AppActionIcon :icon="action.icon" :color="action.color" /> | ||
| </template> | ||
| </AppMenuItem> | ||
| </template> | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This emits
core:navigation:actionwith the whole entry, but as far as I can telleventbus.d.tsdeclarescore:navigation-action:clickedwith just the id, and the tests assert the second one.Which one is the contract? I'd keep the full entry (listeners can read
.id, the reverse needs a lookup)