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

9493 expiration date three dot menu #9584

Merged
merged 9 commits into from
Aug 24, 2023
Merged
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
@@ -0,0 +1,5 @@
Enhancement: Moving share's "set expiration date" function
Moving "set expiration date" function to a three dots menu to help reduce visual load on simple shares in sharing pane

https://github.com/owncloud/web/issues/9493
https://github.com/owncloud/web/pull/9584
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
:max-date="dateMax"
:locale="language.current"
:is-required="enforced"
class="files-recipient-expiration-datepicker"
class="files-recipient-expiration-datepicker oc-width-1-1"
data-testid="recipient-datepicker"
>
<template #default="{ togglePopover }">
<oc-button
class="files-collaborators-expiration-button"
class="files-collaborators-expiration-button oc-p-s action-menu-item"
data-testid="recipient-datepicker-btn"
appearance="raw"
gap-size="none"
Expand All @@ -20,19 +20,17 @@
"
@click="togglePopover"
>
<oc-icon name="calendar-event" fill-type="line" size="medium" variation="passive" />
<span
v-if="!dateCurrent"
key="no-expiration-date-label"
class="oc-text-truncate"
v-text="$gettext('Set expiration date')"
/>
<span
v-else
key="set-expiration-date-label"
class="oc-text-truncate"
v-text="$gettext('Expires %{expires}', { expires: dateExpire })"
v-text="$gettextInterpolate($gettext('Expires %{expires}'), { expires: dateExpire })"
/>
<oc-icon v-if="!dateCurrent" name="arrow-down-s" />
</oc-button>
</template>
</oc-datepicker>
Expand Down Expand Up @@ -163,7 +161,4 @@ export default defineComponent({
.recipient-edit-expiration-btn-remove {
vertical-align: middle;
}
.files-collaborators-expiration-button {
max-width: 160px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,67 @@
<span />
</template>
</oc-select>
<div class="oc-flex oc-flex-middle oc-flex-between oc-mb-l oc-mt-s">
<div class="oc-flex oc-flex-between oc-mb-l oc-mt-s">
<role-dropdown
:allow-share-permission="hasResharing || resourceIsSpace"
mode="create"
class="role-selection-dropdown"
@option-change="collaboratorRoleChanged"
/>
<expiration-datepicker
v-if="!saving"
:share-types="selectedCollaborators.map((c) => c.value.shareType)"
@option-change="collaboratorExpiryChanged"
/>
<oc-button
id="new-collaborators-form-create-button"
key="new-collaborator-save-button"
data-testid="new-collaborators-form-create-button"
:disabled="!$_isValid || saving"
:variation="saving ? 'passive' : 'primary'"
:appearance="saving ? 'outline' : 'filled'"
submit="submit"
:show-spinner="savingDelayed"
@click="share"
>
<span v-text="$gettext(saveButtonLabel)" />
</oc-button>
<div class="oc-flex">
<div v-if="expirationDate" class="oc-flex oc-flex-middle">
<oc-icon
v-oc-tooltip="formattedExpirationDate"
class="files-collaborators-collaborator-expiration"
data-testid="recipient-info-expiration-date"
:aria-label="formattedExpirationDate"
name="calendar-event"
fill-type="line"
/>
<span class="oc-invisible-sr" v-text="screenreaderShareExpiration" />
</div>
<oc-button
class="oc-mx-s"
id="show-more-share-options-btn"
:aria-label="$gettext('Show more actions')"
appearance="raw"
>
<oc-icon name="more-2" />
<oc-drop
ref="showMoreShareOptionsDropRef"
:drop-id="'show-more-share-options-drop'"
:toggle="'#show-more-share-options-btn'"
mode="click"
padding-size="small"
>
<oc-list
class="collaborator-edit-dropdown-options-list"
:aria-label="'shareEditOptions'"
>
<li class="oc-rounded oc-menu-item-hover">
<expiration-datepicker
v-if="!saving"
:share-types="selectedCollaborators.map((c) => c.value.shareType)"
@option-change="collaboratorExpiryChanged"
/>
</li>
</oc-list>
</oc-drop>
</oc-button>
<oc-button
id="new-collaborators-form-create-button"
key="new-collaborator-save-button"
data-testid="new-collaborators-form-create-button"
:disabled="!$_isValid || saving"
:variation="saving ? 'passive' : 'primary'"
:appearance="saving ? 'outline' : 'filled'"
submit="submit"
:show-spinner="savingDelayed"
@click="share"
>
<span v-text="$gettext(saveButtonLabel)" />
</oc-button>
</div>
</div>
<oc-hidden-announcer level="assertive" :announcement="announcement" />
</div>
Expand Down Expand Up @@ -92,6 +128,12 @@ import {
import { defineComponent, inject, ref, unref, watch } from 'vue'
import { Resource } from 'web-client'
import { useShares } from 'web-app-files/src/composables'
import {
displayPositionedDropdown,
formatDateFromDateTime,
formatRelativeDateFromDateTime
} from 'web-pkg'
import { DateTime } from 'luxon'

// just a dummy function to trick gettext tools
const $gettext = (str) => {
Expand Down Expand Up @@ -138,6 +180,16 @@ export default defineComponent({
savingDelayed.value = true
}, 700)
})

const contextMenuButtonRef = ref(undefined)

const showContextMenuOnBtnClick = ({ dropdown, event }) => {
if (dropdown?.tippy === undefined) {
return
}
displayPositionedDropdown(dropdown.tippy, event, unref(contextMenuButtonRef))
}

return {
resource: inject<Resource>('resource'),
hasResharing: useCapabilityFilesSharingResharing(store),
Expand All @@ -147,7 +199,9 @@ export default defineComponent({
clientService,
saving,
savingDelayed,
...useShares()
...useShares(),
showContextMenuOnBtnClick,
contextMenuButtonRef
}
},

Expand Down Expand Up @@ -184,6 +238,28 @@ export default defineComponent({

resourceIsSpace() {
return this.resource.type === 'space'
},
formattedExpirationDate() {
return this.expirationDate === null
? null
: formatDateFromDateTime(
DateTime.fromISO(this.expirationDate).endOf('day'),
this.$language.current
)
},
expirationDateRelative() {
return this.expirationDate === null
? null
: formatRelativeDateFromDateTime(
DateTime.fromISO(this.expirationDate).endOf('day'),
this.$language.current
)
},
screenreaderShareExpiration() {
return this.$gettext('Share expires %{ expiryDateRelative } (%{ expiryDate })', {
expiryDateRelative: this.expirationDateRelative,
expiryDate: this.expirationDate
})
}
},
mounted() {
Expand Down Expand Up @@ -392,6 +468,7 @@ export default defineComponent({
.role-selection-dropdown {
max-width: 150px;
}

#new-collaborators-form-create-button {
padding-left: 30px;
padding-right: 30px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ module.exports = {
},
expandExpirationDatePicker: function (collaborator) {
if (!collaborator) {
this.waitForElementVisible('@expirationDatePickerTrigger').click(
'@expirationDatePickerTrigger'
)
this.waitForElementVisible('@threeDotsTrigger').click('@threeDotsTrigger')
this.waitForElementVisible('@setExpirationDateButton').click('@setExpirationDateButton')
return client.page.FilesPageElement.expirationDatePicker()
}
const informationSelector = util.format(
Expand Down Expand Up @@ -311,6 +310,12 @@ module.exports = {
'//p[contains(@class, "files-collaborators-collaborator-name") and text()="%s"]/../..//span[contains(@class, "files-collaborators-collaborator-expires")]',
locateStrategy: 'xpath'
},
threeDotsTrigger: {
selector: 'button#show-more-share-options-btn'
},
setExpirationDateButton: {
selector: '.files-recipient-expiration-datepicker'
},
expirationDatePickerTrigger: {
selector: '//button[contains(@class, "files-collaborators-expiration-button")]',
locateStrategy: 'xpath'
Expand Down