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

[full-ci] Add details accordion in sharing sidebar #5284

Merged
merged 18 commits into from
Jul 7, 2021
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
9 changes: 9 additions & 0 deletions changelog/unreleased/enhancement-details-in-sharing-sidebar
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
246 changes: 246 additions & 0 deletions packages/web-app-files/src/components/SideBar/Details/FileDetails.vue
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="" />
Copy link
Contributor

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

Copy link
Contributor Author

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" :)

</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">
Copy link
Contributor

Choose a reason for hiding this comment

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

have we decided to use data-test-id or data-testid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latter (data-testid) but haven't done search&replace in web yet

Copy link
Contributor

Choose a reason for hiding this comment

The 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 data-testid in your PR as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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>
11 changes: 6 additions & 5 deletions packages/web-app-files/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ export default {
accordions() {
const accordions = [
{
app: 'sidebar-actions-item',
app: 'actions-item',
component: FileActions,
icon: 'slideshow'
}
]
accordions.splice(0, 0, this.fileSideBars[0])

if (this.isTrashbinRoute) {
return accordions
Expand Down Expand Up @@ -161,7 +162,7 @@ export default {
watch: {
highlightedFile: function() {
if (this.expandedAccordionId === null) {
this.expandActionsAccordion()
this.expandDetailsAccordion()
}
this.$nextTick(() => this.$emit('fileChanged', this, 'fileChanged'))
}
Expand All @@ -173,7 +174,7 @@ export default {

mounted() {
if (this.expandedAccordionId === null) {
this.expandActionsAccordion()
this.expandDetailsAccordion()
}
},

Expand Down Expand Up @@ -205,8 +206,8 @@ export default {
)
},

expandActionsAccordion() {
this.SET_APP_SIDEBAR_EXPANDED_ACCORDION('sidebar-actions-item')
expandDetailsAccordion() {
this.SET_APP_SIDEBAR_EXPANDED_ACCORDION('details-item')
},

onClickOutside(event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,61 +48,56 @@
<script>
import Mixins from '../../../mixins'
import MixinResources from '../../../mixins/resources'
import { mapGetters } from 'vuex'
import { mapActions, mapGetters } from 'vuex'

export default {
mixins: [Mixins, MixinResources],
title: $gettext => {
return $gettext('Versions')
},
data: () => ({
versions: [],
loading: false
}),
computed: {
...mapGetters('Files', ['highlightedFile']),
...mapGetters('Files', ['highlightedFile', 'versions']),
...mapGetters(['getToken']),
hasVersion() {
return this.versions.length > 0
},
currentFile() {
return this.highlightedFile
}
},
watch: {
currentFile() {
this.getFileVersions()
highlightedFile() {
this.fetchFileVersions()
}
},
mounted() {
this.getFileVersions()
this.fetchFileVersions()
},
methods: {
...mapActions('Files', ['loadVersions']),
currentVersionId(file) {
const etag = file.name.split('/')
return etag[etag.length - 1]
},
getFileVersions() {
async fetchFileVersions() {
this.loading = true
this.$client.fileVersions
.listVersions(this.currentFile.id)
.then(res => {
if (res) this.versions = res
})
.finally(_ => {
this.loading = false
})
await this.loadVersions({ client: this.$client, fileId: this.highlightedFile.id })
this.loading = false
},
revertVersion(file) {
this.$client.fileVersions
.restoreFileVersion(this.currentFile.id, this.currentVersionId(file), this.currentFile.path)
.restoreFileVersion(
this.highlightedFile.id,
this.currentVersionId(file),
this.highlightedFile.path
)
.then(() => {
this.getFileVersions()
this.fetchFileVersions()
})
},
downloadVersion(file) {
const version = this.currentVersionId(file)
return this.downloadFile(this.currentFile, null, version)
return this.downloadFile(this.highlightedFile, null, version)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/web-app-files/src/helpers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export function buildResource(resource) {
})(),
privateLink: resource.fileInfo['{http://owncloud.org/ns}privatelink'],
downloadURL: resource.fileInfo['{http://owncloud.org/ns}downloadURL'],
ownerDisplayName: resource.fileInfo['{http://owncloud.org/ns}owner-display-name'],
ownerId: resource.fileInfo['{http://owncloud.org/ns}owner-id'],
canUpload: function() {
return this.permissions.indexOf('C') >= 0
},
Expand Down
Loading