Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<component
:is="type"
v-bind="additionalAttributes"
:aria-label="ariaLabel"
:aria-label="ariaLabel || null"
:class="ocButton_buttonClass"
v-on="handlers"
>
Expand Down
20 changes: 17 additions & 3 deletions packages/web-pkg/src/components/ContextActions/ActionMenuItem.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<template>
<li v-oc-tooltip="componentProps.disabled ? action.disabledTooltip?.(actionOptions) : ''">
<oc-button
v-oc-tooltip="showTooltip || action.hideLabel ? action.label(actionOptions) : ''"
v-oc-tooltip="showTooltip || action.hideLabel ? tooltipText : ''"
:type="componentType"
v-bind="componentProps"
:class="[action.class, 'action-menu-item', 'oc-py-s', 'oc-px-m', 'oc-width-1-1']"
:aria-label="ariaLabel"
data-testid="action-handler"
:size="size"
justify-content="left"
:title="action.label(actionOptions)"
:title="tooltipText"
:aria-describedby="uniqueId"
v-on="componentListeners"
>
<oc-img
Expand Down Expand Up @@ -51,11 +52,14 @@
v-text="action.shortcut"
/>
</oc-button>
<span :id="uniqueId" class="oc-invisible-sr">
{{ tooltipText }}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this result in the action label being read twice in case there is no custom tooltip?

</span>
</li>
</template>

<script lang="ts" setup>
import { computed, unref } from 'vue'
import { computed, unref, useId } from 'vue'
import { Action, ActionOptions, useConfigStore } from '../../composables'
import { useGettext } from 'vue3-gettext'
import { storeToRefs } from 'pinia'
Expand Down Expand Up @@ -98,6 +102,16 @@ const componentType = computed<string>(() => {
return 'button'
})

const uniqueId = useId()

const tooltipText = computed<string>(() => {
if (action?.tooltip) {
return `${action.label(actionOptions)} - ${action.tooltip(actionOptions)}`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we need to include the action label here or if we can rely only on the tooltip...

}

return action.label(actionOptions)
})

const ariaLabel = computed<string | null>(() => {
if (componentProps.value.disabled && action.disabledTooltip) {
return action.disabledTooltip(actionOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useMessages, useConfigStore, useResourcesStore } from '../../piniaStore
export const useFileActionsDisableSync = () => {
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const { $gettext, $ngettext } = useGettext()
const { $gettext, $ngettext, $pgettext } = useGettext()

const clientService = useClientService()
const loadingService = useLoadingService()
Expand Down Expand Up @@ -81,6 +81,11 @@ export const useFileActionsDisableSync = () => {
icon: 'spam-3',
handler: (args) => loadingService.addTask(() => handler(args)),
label: () => $gettext('Disable sync'),
tooltip: () =>
$pgettext(
'Explanation tooltip for the disable sync action in files shared with me and spaces',
'Only affects desktop and mobile clients. You can toggle this setting here, but it will only take effect on those platforms.'
),
isVisible: ({ space, resources }) => {
if (
!isLocationSharesActive(router, 'files-shares-with-me') &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useMessages, useConfigStore, useResourcesStore } from '../../piniaStore
export const useFileActionsEnableSync = () => {
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const { $gettext, $ngettext } = useGettext()
const { $gettext, $ngettext, $pgettext } = useGettext()

const clientService = useClientService()
const loadingService = useLoadingService()
Expand Down Expand Up @@ -82,6 +82,11 @@ export const useFileActionsEnableSync = () => {
name: 'enable-sync',
icon: 'check',
handler: (args) => loadingService.addTask(() => handler(args)),
tooltip: () =>
$pgettext(
'Explanation tooltip for the enable sync action in files shared with me and spaces',
'Only affects desktop and mobile clients. You can toggle this setting here, but it will only take effect on those platforms.'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to check with @DeepDiver1975 whether mobile clients are really affected or if it's only desktop...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you say about being a bit more explicite what the settings actually do? Then maybe the mention that it does not affect web client might be redundant because it might be clear enough from the functionality description.

),
label: () => $gettext('Enable sync'),
isVisible: ({ space, resources }) => {
if (
Expand Down
2 changes: 2 additions & 0 deletions packages/web-pkg/src/composables/actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface Action<T = ActionOptions> {
isExternal?: boolean
ext?: string

tooltip?(options?: T): string

label(options?: T): string

isVisible(options?: T): boolean
Expand Down