Skip to content

Commit

Permalink
Shared with me: Show / Hide shares (#9531) (#9718)
Browse files Browse the repository at this point in the history
* Next iteration of share show/hide

* Rebase and add changelog item

* put remaining parts together to make it work

* fixup! put remaining parts together to make it work

* keep original action names internally for accepting/declining shares

* test: fix tests

* do not allow decline action on pending shares

* feat: rename hide to hidden, use PUT for the request to set it

* fix: center no-content-message for shared-with-me-section

* feat: add action to hide shares to context menu

* fix: ensure the share hidden-param does not get sent when not needed

* fix pipeline

---------

Co-authored-by: Jannik Stehle <[email protected]>
  • Loading branch information
2 people authored and AlexAndBear committed Dec 13, 2023
1 parent 4fab709 commit 7d7431d
Show file tree
Hide file tree
Showing 30 changed files with 523 additions and 320 deletions.
9 changes: 9 additions & 0 deletions changelog/unreleased/enhancement-show-hide-shares
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Enhancement: Personal shares can be shown and hidden

On the shared-with-me page, there is no distinction between pending, accepted and rejected shares anymore.
Instead, the user can toggle to display either shown or hidden shares.

Furthermore, accepting and rejecting shares has been renamed to "enable sync"/"disable sync" to better reflect what's happening on the server and on other devices.

https://github.com/owncloud/web/issues/9531
https://github.com/owncloud/web/pull/9718
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<h2 class="oc-px-m oc-py-s">
<h2 class="oc-px-m oc-py-s oc-invisible-sr">
{{ title }}
<span class="oc-text-medium">({{ items.length }})</span>
</h2>
Expand Down Expand Up @@ -39,25 +39,12 @@
:key="resource.getDomSelector() + resource.status"
class="oc-text-nowrap oc-flex oc-flex-middle oc-flex-right"
>
<oc-button
v-if="getShowAcceptButton(resource)"
size="small"
variation="success"
class="file-row-share-status-accept"
@click.stop="triggerAction('accept-share', { space: null, resources: [resource] })"
>
<oc-icon size="small" name="check" />
<span v-translate>Accept</span>
</oc-button>
<oc-button
v-if="getShowDeclineButton(resource)"
size="small"
class="file-row-share-decline oc-ml-s"
@click.stop="triggerAction('decline-share', { space: null, resources: [resource] })"
>
<oc-icon size="small" name="spam-3" fill-type="line" />
<span v-translate>Decline</span>
</oc-button>
<oc-icon
v-if="getShowSynchedIcon(resource)"
v-oc-tooltip="$gettext('Synced with your devices')"
name="loop-right"
class="sync-enabled"
/>
</div>
</template>
<template #contextMenu="{ resource }">
Expand All @@ -66,6 +53,17 @@
:action-options="{ space: getMatchingSpace(resource), resources: selectedResources }"
/>
</template>
<template #quickActions="{ resource }">
<oc-button
size="small"
appearance="raw"
:class="['oc-ml-s', 'oc-p-s', hideShareAction.class]"
@click.stop="hideShareAction.handler({ space: null, resources: [resource] })"
>
<oc-icon size="small" :name="resource.hidden ? 'eye' : 'eye-off'" fill-type="line" />
<span>{{ hideShareAction.label({ space: null, resources: [resource] }) }}</span>
</oc-button>
</template>
<template #footer>
<div v-if="showMoreToggle && hasMore" class="oc-width-1-1 oc-text-center oc-mt">
<oc-button
Expand All @@ -92,13 +90,12 @@
</template>

<script lang="ts">
import { ResourceTable } from '@ownclouders/web-pkg'
import { defineComponent, PropType } from 'vue'
import { ResourceTable, useFileActions, useFileActionsToggleHideShare } from '@ownclouders/web-pkg'
import { computed, defineComponent, PropType, unref } from 'vue'
import { debounce } from 'lodash-es'
import { ImageDimension, ImageType } from '@ownclouders/web-pkg'
import { VisibilityObserver } from '@ownclouders/web-pkg'
import { mapActions } from 'vuex'
import { useFileActions } from '@ownclouders/web-pkg'
import { SortDir, useStore, useGetMatchingSpace } from '@ownclouders/web-pkg'
import { createLocationSpaces } from '@ownclouders/web-pkg'
import ListInfo from '../../components/FilesList/ListInfo.vue'
Expand Down Expand Up @@ -137,7 +134,7 @@ export default defineComponent({
},
shareStatus: {
type: Number,
required: true
default: ShareStatus.accepted
},
sortBy: {
type: String,
Expand Down Expand Up @@ -195,6 +192,10 @@ export default defineComponent({
const store = useStore()
const { getMatchingSpace } = useGetMatchingSpace()
const { triggerDefaultAction } = useFileActions()
const { actions: hideShareActions } = useFileActionsToggleHideShare({ store })
const hideShareAction = computed(() => unref(hideShareActions)[0])
const resourceTargetRouteCallback = ({
path,
fileId,
Expand All @@ -207,7 +208,8 @@ export default defineComponent({
}
return {
...useFileActions(),
triggerDefaultAction,
hideShareAction,
resourceTargetRouteCallback,
...useSelectedResources({ store }),
getMatchingSpace
Expand Down Expand Up @@ -271,10 +273,13 @@ export default defineComponent({
onExit: debounced.cancel
})
},
getShowAcceptButton(resource) {
getShowSynchedIcon(resource: Resource) {
return resource.status === ShareStatus.accepted
},
getShowAcceptButton(resource: Resource) {
return resource.status === ShareStatus.declined || resource.status === ShareStatus.pending
},
getShowDeclineButton(resource) {
getShowDeclineButton(resource: Resource) {
return resource.status === ShareStatus.accepted || resource.status === ShareStatus.pending
},
toggleShowMore() {
Expand All @@ -285,7 +290,7 @@ export default defineComponent({
</script>

<style lang="scss" scoped>
.files-empty {
height: auto;
.oc-files-actions-hide-share-trigger:hover {
background-color: var(--oc-color-background-secondary) !important;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class FolderLoaderSharedWithMe implements FolderLoader {
let resources = yield clientService.owncloudSdk.shares.getShares('', {
state: 'all',
include_tags: false,
shared_with_me: true
shared_with_me: true,
show_hidden: true
})

resources = resources.map((r) => r.shareInfo)
Expand Down
Loading

0 comments on commit 7d7431d

Please sign in to comment.