Skip to content

Commit

Permalink
Time for improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAckermann committed Jul 27, 2022
1 parent 65431fd commit dfb6221
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
<span class="oc-text-initial">({{ items.length }})</span>
</h2>

<no-content-message
v-if="!items.length > 0"
:id="noContentMessageId"
class="files-empty oc-flex-stretch"
icon="group"
>
<no-content-message v-if="!items.length > 0" class="files-empty oc-flex-stretch" icon="group">
<template #message>
<span>{{ emptyMessage }}</span>
</template>
</no-content-message>
<resource-table
v-else
:id="tableId"
v-model="itemsSelected"
:data-test-share-status="shareStatus"
class="files-table"
Expand All @@ -43,7 +37,7 @@
class="oc-text-nowrap oc-flex oc-flex-middle oc-flex-right"
>
<oc-button
v-if="showAcceptButton"
v-if="getShowAcceptButton(resource)"
size="small"
variation="success"
class="file-row-share-status-accept"
Expand All @@ -53,7 +47,7 @@
<translate>Accept</translate>
</oc-button>
<oc-button
v-if="showDeclineButton"
v-if="getShowDeclineButton(resource)"
size="small"
class="file-row-share-decline oc-ml-s"
@click.stop="$_declineShare_trigger({ resources: [resource] })"
Expand All @@ -69,7 +63,7 @@
<template #footer>
<div v-if="showMoreLessToggle && hasMore" class="oc-width-1-1 oc-text-center oc-mt">
<oc-button
id="files-shared-with-me-pending-show-all"
id="files-shared-with-me-show-all"
appearance="raw"
gap-size="xsmall"
size="small"
Expand Down Expand Up @@ -160,6 +154,14 @@ export default defineComponent({
showMoreLessToggle: {
type: Boolean,
default: false
},
resourceClickable: {
type: Boolean,
default: true
},
displayThumbnails: {
type: Boolean,
default: true
}
},
setup() {
Expand Down Expand Up @@ -208,28 +210,14 @@ export default defineComponent({
countFolders() {
return this.items.filter((s) => s.type === 'folder').length
},
showAcceptButton() {
return this.shareStatus === ShareStatus.declined || this.shareStatus === ShareStatus.pending
},
showDeclineButton() {
return this.shareStatus === ShareStatus.accepted || this.shareStatus === ShareStatus.pending
},
itemsSelected: {
get() {
return this.selectedFiles.filter((r) => r.status === this.shareStatus)
return this.selectedFiles
},
set(resources) {
this.SET_FILE_SELECTION(resources.filter((r) => r.status === this.shareStatus))
}
},
displayThumbnails() {
return (
!this.configuration?.options?.disablePreviews && this.shareStatus === ShareStatus.accepted
)
},
resourceClickable() {
return this.shareStatus === ShareStatus.accepted
},
toggleMoreLabel() {
return this.showMore ? this.$gettext('Show less') : this.$gettext('Show more')
},
Expand All @@ -241,30 +229,6 @@ export default defineComponent({
return this.items
}
return this.items.slice(0, 3)
},
tableId() {
switch (this.shareStatus) {
case ShareStatus.pending:
return 'files-shared-with-me-pending-table'
case ShareStatus.accepted:
return 'files-shared-with-me-accepted-table'
case ShareStatus.declined:
return 'files-shared-with-me-declined-table'
default:
return ''
}
},
noContentMessageId() {
switch (this.shareStatus) {
case ShareStatus.pending:
return 'files-shared-with-me-pending-empty'
case ShareStatus.accepted:
return 'files-shared-with-me-accepted-empty'
case ShareStatus.declined:
return 'files-shared-with-me-declined-empty'
default:
return ''
}
}
},
beforeDestroy() {
Expand Down Expand Up @@ -296,7 +260,12 @@ export default defineComponent({
onExit: debounced.cancel
})
},
getShowAcceptButton(resource) {
return resource.status === ShareStatus.declined || resource.status === ShareStatus.pending
},
getShowDeclineButton(resource) {
return resource.status === ShareStatus.accepted || resource.status === ShareStatus.pending
},
toggleShowMore() {
this.showMore = !this.showMore
}
Expand Down
13 changes: 12 additions & 1 deletion packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,33 @@
<template v-else>
<shared-with-me-section
v-if="pendingItems.length > 0"
id="files-shared-with-me-pending-section"
:title="pendingTitle"
:items="pendingItems"
:share-status="ShareStatus.pending"
:sort-by="pendingSortBy"
:sort-dir="pendingSortDir"
:sort-handler="acceptedHandleSort"
:sort-handler="pendingHandleSort"
:show-more-less-toggle="true"
:resource-clickable="false"
:display-thumbnails="false"
></shared-with-me-section>

<shared-with-me-section
id="files-shared-with-me-accepted-section"
:title="acceptedTitle"
:empty-message="acceptedEmptyMessage"
:items="acceptedItems"
:share-status="ShareStatus.accepted"
:sort-by="acceptedSortBy"
:sort-dir="acceptedSortDir"
:sort-handler="acceptedHandleSort"
:resource-clickable="true"
:display-thumbnails="displayThumbnails"
></shared-with-me-section>

<shared-with-me-section
id="files-shared-with-me-declined-section"
:title="declinedTitle"
:empty-message="declinedEmptyMessage"
:items="declinedItems"
Expand All @@ -33,6 +40,7 @@
:sort-by="declinedSortBy"
:sort-dir="declinedSortDir"
:sort-handler="declinedHandleSort"
:display-thumbnails="false"
></shared-with-me-section>
</template>
</div>
Expand Down Expand Up @@ -158,6 +166,9 @@ export default defineComponent({
},
declinedEmptyMessage() {
return this.$gettext("You don't have any previously declined shares.")
},
displayThumbnails() {
return !this.configuration?.options?.disablePreviews
}
},
Expand Down
32 changes: 20 additions & 12 deletions packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ const stubs = {
translate: true,
'oc-pagination': true,
'oc-spinner': true,
'context-actions': true
'context-actions': true,
'no-content-message': true
}

const selectors = {
pendingTable: '#files-shared-with-me-pending-table',
pendingTableRow: '#files-shared-with-me-pending-table tbody > tr.oc-tbody-tr',
pendingExpand: '#files-shared-with-me-pending-show-all[data-test-expand="true"]',
pendingCollapse: '#files-shared-with-me-pending-show-all[data-test-expand="false"]',
acceptedNoContentMessage: '#files-shared-with-me-accepted-empty',
declinedNoContentMessage: '#files-shared-with-me-declined-empty',
acceptedTable: '#files-shared-with-me-accepted-table',
declinedTable: '#files-shared-with-me-declined-table',
acceptedTableRow: '#files-shared-with-me-accepted-table tbody > tr.oc-tbody-tr',
declinedTableRow: '#files-shared-with-me-declined-table tbody > tr.oc-tbody-tr',
pendingTable: '#files-shared-with-me-pending-section .files-table',
pendingTableRow: '#files-shared-with-me-pending-section tbody > tr.oc-tbody-tr',
pendingExpand:
'#files-shared-with-me-pending-section #files-shared-with-me-show-all[data-test-expand="true"]',
pendingCollapse:
'#files-shared-with-me-pending-section #files-shared-with-me-show-all[data-test-expand="false"]',
acceptedNoContentMessage: '#files-shared-with-me-accepted-section .files-empty',
declinedNoContentMessage: '#files-shared-with-me-declined-section .files-empty',
acceptedTable: '#files-shared-with-me-accepted-section .files-table',
declinedTable: '#files-shared-with-me-declined-section .files-table',
acceptedTableRow: '#files-shared-with-me-accepted-section tbody > tr.oc-tbody-tr',
declinedTableRow: '#files-shared-with-me-declined-section tbody > tr.oc-tbody-tr',
sharesToggleViewMode: '#files-shared-with-me-toggle-view-mode'
}

Expand Down Expand Up @@ -209,7 +212,12 @@ function mountOptions({
loadResourcesTask: {
perform: jest.fn()
},
handleSort: jest.fn()
pendingHandleSort: jest.fn(),
acceptedHandleSort: jest.fn(),
declinedHandleSort: jest.fn(),
pendingSortBy: '',
acceptedSortBy: '',
declinedSortBy: ''
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const invitationInput = '#files-share-invite-input'
const filesCollaboratorRolesSelector = '//*[@id="files-collaborators-role-button-new"]'
const collaboratorRoleItemSelector = `//*[@id="files-role-%s"]`
const shareInvitationButton = '#new-collaborators-form-create-button'
const filesSharedWithMeAccepted = `#files-shared-with-me-accepted-table [data-test-resource-name="%s"]`
const filesSharedWithMeAccepted = `#files-shared-with-me-accepted-section [data-test-resource-name="%s"]`
const collaboratorUserItem = `//*[@data-testid="collaborator-user-item-%s"]`
const shareAcceptDeclineButton = `//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "file-row-share-%s")]`
const quickShareButton = `//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "files-quick-action-collaborators")]`
Expand Down

0 comments on commit dfb6221

Please sign in to comment.