-
Notifications
You must be signed in to change notification settings - Fork 168
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
[full-ci] Add details accordion in sharing sidebar #5284
Changes from all commits
dd533c0
9aea01f
a0f4061
16bc7f8
ed925ab
a489b8f
9ffe2e8
cb7882e
5739839
42d11a7
8e03f23
822eb7b
03420f0
bac6d7b
d78e461
ec77da4
38b415e
125a387
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Enhancement: Details in Sharing Sidebar | ||
|
||
We're now displaying more information about the | ||
highlighted file in the sharing sidebar, including | ||
a preview (if applicable) as well as sharing and | ||
version information in one place. | ||
|
||
https://github.com/owncloud/web/issues/5161 | ||
https://github.com/owncloud/web/pull/5284 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
<template> | ||
<div id="oc-file-details-sidebar"> | ||
<oc-loader v-if="loading" /> | ||
<div v-else> | ||
<div | ||
v-if="highlightedFile.preview" | ||
class="details-preview uk-flex uk-flex-middle uk-flex-center oc-mb-m" | ||
> | ||
<oc-img :src="highlightedFile.preview" alt="" /> | ||
</div> | ||
<div v-if="showShares" data-test-id="sharingInfo" class="uk-flex uk-flex-middle oc-my-m"> | ||
<oc-button | ||
v-if="hasPeopleShares" | ||
v-oc-tooltip="peopleSharesLabel" | ||
appearance="raw" | ||
class="oc-mr-xs" | ||
:aria-label="peopleSharesLabel" | ||
@click="expandPeoplesAccordion" | ||
> | ||
<oc-icon name="group" /> | ||
</oc-button> | ||
<oc-button | ||
v-if="hasLinkShares" | ||
v-oc-tooltip="linkSharesLabel" | ||
appearance="raw" | ||
class="oc-mr-xs" | ||
:aria-label="linkSharesLabel" | ||
@click="expandLinksAccordion" | ||
> | ||
<oc-icon name="link" /> | ||
</oc-button> | ||
<p class="oc-my-rm oc-mx-s" v-text="detailSharingInformation" /> | ||
</div> | ||
<table class="details-table" aria-label="detailsTableLabel"> | ||
<tr v-if="hasTimestamp" data-test-id="timestamp"> | ||
<th scope="col" class="oc-pr-s" v-text="timestampTitle" /> | ||
<td> | ||
<oc-button | ||
v-if="showVersions" | ||
v-oc-tooltip="seeVersionsLabel" | ||
appearance="raw" | ||
:aria-label="seeVersionsLabel" | ||
@click="expandVersionsAccordion" | ||
v-text="capitalizedTimestamp" | ||
/> | ||
<span v-else v-text="capitalizedTimestamp" /> | ||
</td> | ||
</tr> | ||
<tr v-if="ownerName" data-test-id="ownerName"> | ||
<th scope="col" class="oc-pr-s" v-text="ownerTitle" /> | ||
<td> | ||
<p class="oc-m-rm"> | ||
{{ ownerName }} | ||
<span v-if="ownedByCurrentUser" v-translate>(me)</span> | ||
</p> | ||
</td> | ||
</tr> | ||
<tr data-test-id="sizeInfo"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have we decided to use data-test-id or data-testid? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The latter (data-testid) but haven't done search&replace in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did the search & replace in the ODS update PR. Could you switch to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surely, thanks 🙌🏽 |
||
<th scope="col" class="oc-pr-s" v-text="sizeTitle" /> | ||
<td v-text="getResourceSize(highlightedFile.size)" /> | ||
</tr> | ||
<tr v-if="showVersions" data-test-id="versionsInfo"> | ||
<th scope="col" class="oc-pr-s" v-text="versionsTitle" /> | ||
<td> | ||
<oc-button | ||
v-oc-tooltip="seeVersionsLabel" | ||
appearance="raw" | ||
:aria-label="seeVersionsLabel" | ||
@click="expandVersionsAccordion" | ||
v-text="versions.length" | ||
/> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
import Mixins from '../../../mixins' | ||
import MixinResources from '../../../mixins/resources' | ||
import MixinRoutes from '../../../mixins/routes' | ||
import { shareTypes, userShareTypes } from '../../../../../web-app-files/src/helpers/shareTypes' | ||
import { mapActions, mapGetters, mapMutations } from 'vuex' | ||
import { ImageDimension, ImageType } from '../../../constants' | ||
import intersection from 'lodash-es/intersection' | ||
import upperFirst from 'lodash-es/upperFirst' | ||
|
||
export default { | ||
mixins: [Mixins, MixinResources, MixinRoutes], | ||
title: $gettext => { | ||
return $gettext('Details') | ||
}, | ||
data: () => ({ | ||
loading: false | ||
}), | ||
computed: { | ||
...mapGetters('Files', ['highlightedFile', 'versions']), | ||
...mapGetters(['getToken']), | ||
...mapGetters(['user']), | ||
|
||
detailsTableLabel() { | ||
return this.$gettext('Overview of the information about the selected file') | ||
}, | ||
showShares() { | ||
return this.hasAnyShares && !this.isPublicPage | ||
}, | ||
detailSharingInformation() { | ||
return this.$gettext( | ||
'This file has been shared. Manage access rights by clicking on the icons on the left or on the sections below' | ||
) | ||
}, | ||
peopleSharesLabel() { | ||
return this.$gettext('Show invited people') | ||
}, | ||
linkSharesLabel() { | ||
return this.$gettext('Show links') | ||
}, | ||
hasTimestamp() { | ||
return this.highlightedFile.mdate?.length > 0 || this.highlightedFile.sdate?.length > 0 | ||
}, | ||
timestampTitle() { | ||
if (this.highlightedFile.mdate) { | ||
return this.$gettext('Last modified:') | ||
} | ||
return this.$gettext('Shared:') | ||
}, | ||
ownerTitle() { | ||
return this.$gettext('Owner:') | ||
}, | ||
ownerName() { | ||
return ( | ||
this.highlightedFile.ownerDisplayName || | ||
this.highlightedFile.shareOwnerDisplayname || | ||
this.highlightedFile.owner?.[0].displayName | ||
) | ||
}, | ||
sizeTitle() { | ||
return this.$gettext('Size:') | ||
}, | ||
showVersions() { | ||
if (this.highlightedFile.type === 'folder') { | ||
return | ||
} | ||
return this.versions.length > 0 && !this.isPublicPage | ||
}, | ||
versionsTitle() { | ||
return this.$gettext('Versions:') | ||
}, | ||
seeVersionsLabel() { | ||
return this.$gettext('See all versions') | ||
}, | ||
capitalizedTimestamp() { | ||
let displayDate = '' | ||
if (this.highlightedFile.mdate) { | ||
displayDate = this.formDateFromNow(this.highlightedFile.mdate, 'Http') | ||
} else { | ||
displayDate = this.formDateFromNow(this.highlightedFile.sdate, 'Http') | ||
} | ||
return upperFirst(displayDate) | ||
}, | ||
hasAnyShares() { | ||
return ( | ||
this.highlightedFile.shareTypes?.length > 0 || this.highlightedFile.indicators?.length > 0 | ||
) | ||
}, | ||
hasPeopleShares() { | ||
return ( | ||
intersection(this.highlightedFile.shareTypes, userShareTypes).length > 0 || | ||
this.highlightedFile.indicators?.filter(e => e.icon === 'group').length > 0 | ||
) | ||
}, | ||
hasLinkShares() { | ||
return ( | ||
this.highlightedFile.shareTypes.includes(shareTypes.link) || | ||
this.highlightedFile.indicators?.filter(e => e.icon === 'link').length > 0 | ||
) | ||
}, | ||
ownedByCurrentUser() { | ||
return ( | ||
this.highlightedFile.ownerId === this.user.id || | ||
this.highlightedFile.owner?.[0].username === this.user.id || | ||
this.highlightedFile.shareOwner === this.user.id | ||
) | ||
} | ||
}, | ||
watch: { | ||
highlightedFile() { | ||
this.loadData() | ||
} | ||
}, | ||
mounted() { | ||
this.loadData() | ||
}, | ||
methods: { | ||
...mapActions('Files', ['setHighlightedFile', 'loadPreview', 'loadVersions']), | ||
...mapMutations('Files', ['SET_APP_SIDEBAR_EXPANDED_ACCORDION']), | ||
expandPeoplesAccordion() { | ||
this.SET_APP_SIDEBAR_EXPANDED_ACCORDION('sharing-item') | ||
}, | ||
expandLinksAccordion() { | ||
this.SET_APP_SIDEBAR_EXPANDED_ACCORDION('links-item') | ||
}, | ||
expandVersionsAccordion() { | ||
this.SET_APP_SIDEBAR_EXPANDED_ACCORDION('versions-item') | ||
}, | ||
async loadData() { | ||
this.loading = true | ||
const calls = [ | ||
this.loadPreview({ | ||
resource: this.highlightedFile, | ||
isPublic: this.isPublicPage, | ||
dimensions: ImageDimension.Preview, | ||
type: ImageType.Preview | ||
}) | ||
] | ||
if (this.highlightedFile.type === 'file' && !this.isPublicPage) { | ||
calls.push(this.loadVersions({ client: this.$client, fileId: this.highlightedFile.id })) | ||
} | ||
await Promise.all(calls) | ||
this.loading = false | ||
} | ||
} | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.details-table { | ||
text-align: left; | ||
tr { | ||
height: 1.5rem; | ||
} | ||
th { | ||
font-weight: 600; | ||
} | ||
} | ||
.details-preview { | ||
background-color: var(--oc-color-background-highlight); | ||
border-radius: 3px; | ||
height: 300px; | ||
padding: 10px; | ||
img { | ||
object-fit: contain; | ||
height: 100%; | ||
max-height: 100%; | ||
} | ||
} | ||
</style> |
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.
can we add the resource name as alt here
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.
Thanks for the suggestion! Matter of fact we can't since there is no way to be sure there is (and no way for the user to add) enough context to make this a11y-compliant. An
alt
-tag that is intentionally left completely blank tells screenreaders to ignore the element as "not adding any valuable context" :)