Skip to content
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

Add option to set max length of a breadcrumb item #8769

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-max-length-breadcrumb-item
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Option for the max length of a breadcrumb item

We've added a configuration option `options.breadcrumbItemMaxLength` to set the max length of a breadcrumb items with exeption of the last item.

https://github.com/owncloud/web/pull/8769
1 change: 1 addition & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ hovers the row with his mouse. Defaults to `false`.
- `options.editor.autosaveEnabled` Specifies if the autosave for the editor apps is enabled.
- `options.editor.autosaveInterval` Specifies the time interval for the autosave of editor apps in seconds.
- `options.contextHelpersReadMore` Specifies whether the "Read more" link should be displayed or not.
- `options.breadcrumbItemMaxLength` Specifies the maximum length in letters for the breadcrumb item. If set to 0, no maximum length will be set.

### Sentry

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
class="oc-breadcrumb-list-item oc-flex oc-flex-middle"
>
<router-link v-if="item.to" :aria-current="getAriaCurrent(index)" :to="item.to">
<span>{{ item.text }}</span>
<span v-if="shortenItemShown(item.text)" v-oc-tooltip="item.text">{{
getItemText(item.text)
}}</span>
<span v-else>{{ item.text }}</span>
</router-link>
<oc-icon
v-if="item.to"
Expand All @@ -24,6 +27,13 @@
>
<span>{{ item.text }}</span>
</oc-button>
<span
v-else-if="shortenItemShown(item.text)"
v-oc-tooltip="item.text"
:aria-current="getAriaCurrent(index)"
tabindex="-1"
v-text="getItemText(item.text)"
/>
<span v-else :aria-current="getAriaCurrent(index)" tabindex="-1" v-text="item.text" />
<template v-if="showContextActions && index === items.length - 1">
<oc-button
Expand Down Expand Up @@ -138,6 +148,15 @@ export default defineComponent({
showContextActions: {
type: Boolean,
default: false
},
/**
* Defines the maximal length of a breadcrumb item. By longer item adds '...'. Defaults to 0 (no maximal length).
*/
itemMaxLength: {
type: Number,
required: false,
default: 0,
validator: (value: number) => Number.isInteger(value) && value >= 0
}
},
setup(props) {
Expand All @@ -161,7 +180,22 @@ export default defineComponent({
return props.items.length - 1 === index ? 'page' : null
}

return { currentFolder, parentFolderTo, contextMenuLabel, getAriaCurrent }
const getItemText = (itemText) => {
return `${itemText.slice(0, props.itemMaxLength - 1)}...`
}

const shortenItemShown = (itemText) => {
return props.itemMaxLength && itemText.length - props.itemMaxLength > 3
}

return {
currentFolder,
parentFolderTo,
contextMenuLabel,
getAriaCurrent,
getItemText,
shortenItemShown
}
}
})
</script>
Expand Down
6 changes: 5 additions & 1 deletion packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
context-menu-padding="small"
:show-context-actions="showContextActions"
:items="breadcrumbs"
:itemMaxLength="breadcrumbItemMaxLength"
>
<template #contextMenu>
<context-actions
Expand Down Expand Up @@ -182,10 +183,13 @@ export default defineComponent({
return props.breadcrumbs.length <= 1
})

const breadcrumbItemMaxLength = store.getters.configuration?.options?.breadcrumbItemMaxLength

return {
batchActions,
showBreadcrumb,
showMobileNav
showMobileNav,
breadcrumbItemMaxLength
}
},
data: function () {
Expand Down
3 changes: 2 additions & 1 deletion packages/web-runtime/src/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const state = {
runningOnEos: false,
cernFeatures: false,
sharingRecipientsPerPage: 200,
contextHelpersReadMore: true
contextHelpersReadMore: true,
breadcrumbItemMaxLength: 0
}
}

Expand Down