Skip to content
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,39 @@
<template>
Copy link
Contributor

Choose a reason for hiding this comment

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

Script setup would be nice for new components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true!

<context-action-menu :menu-sections="menuSections" :action-options="actionOptions" />
</template>

<script setup lang="ts">
import {
ContextActionMenu,
MenuSection,
SpaceActionOptions,
useSpaceActionsNavigateToTrash
} from '@opencloud-eu/web-pkg'
import { computed, toRef, unref } from 'vue'

const props = defineProps<{
actionOptions: SpaceActionOptions
}>()

const actionOptions = toRef(props, 'actionOptions')

const { actions: navigateToTrashActions } = useSpaceActionsNavigateToTrash()

const menuItemsPrimaryActions = computed(() => {
const fileHandlers = [...unref(navigateToTrashActions)]
return fileHandlers.filter((item) => item.isVisible(unref(actionOptions)))
})

const menuSections = computed<MenuSection[]>(() => {
const sections: MenuSection[] = []

if (unref(menuItemsPrimaryActions)) {
sections.push({
name: 'primaryActions',
items: unref(menuItemsPrimaryActions)
})
}

return sections
})
</script>
9 changes: 8 additions & 1 deletion packages/web-app-files/src/views/trash/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
:sort-dir="sortDir"
:is-side-bar-open="isSideBarOpen"
:header-position="fileListHeaderY"
:has-actions="false"
:are-thumbnails-displayed="false"
:are-paths-displayed="false"
:is-selectable="false"
:target-route-callback="resourceTargetRouteCallback"
@sort="handleSort"
>
<template #contextMenu="{ resource, isOpen }">
<trash-context-actions
v-if="isOpen"
:action-options="{ resources: [resource] as SpaceResource[] }"
/>
</template>
<template #footer>
<div class="oc-text-center oc-width-1-1 oc-my-s">
<p class="oc-text-muted">{{ footerTextTotal }}</p>
Expand Down Expand Up @@ -88,10 +93,12 @@ import {
import { FieldType } from '@opencloud-eu/design-system/helpers'
import { ResourceTable } from '@opencloud-eu/web-pkg/src'
import { RouteLocationNamedRaw } from 'vue-router'
import TrashContextActions from '../../components/Trash/TrashContextActions.vue'

export default defineComponent({
name: 'TrashOverview',
components: {
TrashContextActions,
ResourceTable,
FileSideBar,
FilesViewWrapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ exports[`TrashOverview > view states > should render trash list 1`] = `
<!--v-if-->
<!-- @slot Content of the button --> <span class="oc-table-thead-content header-text">Name</span> <span class="oc-icon oc-icon-s oc-p-xs oc-rounded"><!----></span>
</button></th>
<th class="oc-table-cell oc-table-cell-align-right oc-table-cell-align-middle oc-table-cell-width-shrink oc-th oc-table-header-cell oc-table-header-cell-indicators oc-pr-m" style="top: 0px;">
<th class="oc-table-cell oc-table-cell-align-right oc-table-cell-align-middle oc-table-cell-width-shrink oc-th oc-table-header-cell oc-table-header-cell-indicators" style="top: 0px;">
<div><span class="oc-table-thead-content header-text">Status</span></div>
</th>
<th class="oc-table-cell oc-table-cell-align-right oc-table-cell-align-middle oc-table-cell-width-shrink oc-th oc-table-header-cell oc-table-header-cell-actions oc-pr-m" style="top: 0px;">
<div><span class="oc-table-thead-content header-text">Actions</span></div>
</th>
</tr>
</thead>
<tbody class="has-item-context-menu">
<tr class="oc-tbody-tr oc-tbody-tr-1" data-item-id="1" draggable="false">
<td class="oc-table-cell oc-table-cell-align-left oc-table-cell-align-middle oc-table-cell-width-auto oc-td" colspan="2"><span class="shimmer"></span></td>
<td class="oc-table-cell oc-table-cell-align-left oc-table-cell-align-middle oc-table-cell-width-auto oc-td" colspan="3"><span class="shimmer"></span></td>
</tr>
<tr class="oc-tbody-tr oc-tbody-tr-2" data-item-id="2" draggable="false">
<td class="oc-table-cell oc-table-cell-align-left oc-table-cell-align-middle oc-table-cell-width-auto oc-td" colspan="2"><span class="shimmer"></span></td>
<td class="oc-table-cell oc-table-cell-align-left oc-table-cell-align-middle oc-table-cell-width-auto oc-td" colspan="3"><span class="shimmer"></span></td>
</tr>
<tr class="oc-tbody-tr oc-tbody-tr-3" data-item-id="3" draggable="false">
<td class="oc-table-cell oc-table-cell-align-left oc-table-cell-align-middle oc-table-cell-width-auto oc-td" colspan="2"><span class="shimmer"></span></td>
<td class="oc-table-cell oc-table-cell-align-left oc-table-cell-align-middle oc-table-cell-width-auto oc-td" colspan="3"><span class="shimmer"></span></td>
</tr>
</tbody>
<tfoot class="oc-table-footer">
<tr class="oc-table-footer-row">
<td colspan="2" class="oc-table-footer-cell">
<td colspan="3" class="oc-table-footer-cell">
<!-- @slot Footer of the table -->
<!-- @slot Footer of the files table -->
<div class="oc-text-center oc-width-1-1 oc-my-s">
Expand Down
18 changes: 15 additions & 3 deletions packages/web-pkg/src/components/FilesList/ResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
</oc-button>
</template>
<template #actions="{ item }">
<div v-if="!isResourceDisabled(item)" class="resource-table-actions">
<div v-if="showContextDrop(item)" class="resource-table-actions">
<!-- @slot Add quick actions before the `context-menu / three dot` button in the actions column -->
<slot name="quickActions" :resource="item" />
<context-menu-quick-action
Expand Down Expand Up @@ -290,6 +290,7 @@ import {
FolderViewModeConstants,
routeToContextQuery,
SortDir,
useActiveLocation,
useAuthStore,
useCanBeOpenedWithSecureView,
useCapabilityStore,
Expand Down Expand Up @@ -323,7 +324,7 @@ import { useResourceRouteResolver } from '../../composables/filesList/useResourc
import { ClipboardActions } from '../../helpers/clipboardActions'
import { determineResourceTableSortFields } from '../../helpers/ui/resourceTable'
import { useFileActionsRename } from '../../composables/actions'
import { createLocationCommon } from '../../router'
import { createLocationCommon, isLocationTrashActive } from '../../router'
import get from 'lodash-es/get'
import { storeToRefs } from 'pinia'
import { OcButton, OcSpinner, OcTable } from '@opencloud-eu/design-system/components'
Expand Down Expand Up @@ -593,6 +594,8 @@ export default defineComponent({
() => capabilityStore.filesTags && width.value >= TAGS_MINIMUM_SCREEN_WIDTH
)

const isTrashOverviewRoute = useActiveLocation(isLocationTrashActive, 'files-trash-overview')

const { actions: renameActions } = useFileActionsRename()
const { actions: renameActionsSpace } = useSpaceActionsRename()
const renameHandler = computed(() => unref(renameActions)[0].handler)
Expand Down Expand Up @@ -674,6 +677,14 @@ export default defineComponent({
return unref(deleteQueue).includes(id)
}

const showContextDrop = (item: Resource | SpaceResource) => {
if (unref(isTrashOverviewRoute) && isProjectSpaceResource(item) && item.disabled) {
return false
}

return !isResourceDisabled(item)
}

return {
router,
configOptions,
Expand Down Expand Up @@ -713,7 +724,8 @@ export default defineComponent({
getResourceLink,
isSticky,
isResourceInDeleteQueue,
ShareTypes
ShareTypes,
showContextDrop
}
},
data() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { computed } from 'vue'
import { SpaceAction } from '../types'
import { useGettext } from 'vue3-gettext'
import { useRouter } from '../../router'
import { SpaceResource } from '@opencloud-eu/web-client'
import {
isPersonalSpaceResource,
isProjectSpaceResource,
SpaceResource
} from '@opencloud-eu/web-client'
import { createLocationTrash } from '../../../router'
import { createFileRouteOptions } from '../../../helpers'
import { isProjectSpaceResource } from '@opencloud-eu/web-client'

export const useSpaceActionsNavigateToTrash = () => {
const router = useRouter()
Expand All @@ -21,7 +24,7 @@ export const useSpaceActionsNavigateToTrash = () => {
{
name: 'navigateToTrash',
icon: 'delete-bin',
label: () => $gettext('Show deleted files'),
label: () => $gettext('Open Deleted files'),
handler: ({ resources }) => {
router.push(getTrashLink(resources[0]))
},
Expand All @@ -30,7 +33,7 @@ export const useSpaceActionsNavigateToTrash = () => {
return false
}

if (!isProjectSpaceResource(resources[0])) {
if (!isProjectSpaceResource(resources[0]) && !isPersonalSpaceResource(resources[0])) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useSpaceActionsNavigateToTrash } from '../../../../../src'
import { mock } from 'vitest-mock-extended'
import {
defaultComponentMocks,
RouteLocation,
getComposableWrapper
getComposableWrapper,
RouteLocation
} from '@opencloud-eu/web-test-helpers'
import { unref } from 'vue'
import { SpaceResource } from '@opencloud-eu/web-client'
import { Resource, SpaceResource } from '@opencloud-eu/web-client'

describe('navigateToSpace', () => {
describe('isVisible property', () => {
Expand All @@ -17,6 +17,17 @@ describe('navigateToSpace', () => {
}
})
})
it('should be false when the resource is not a space resource', () => {
getWrapper({
setup: ({ actions }) => {
expect(
unref(actions)[0].isVisible({
resources: [mock<Resource>() as any]
})
).toBe(false)
}
})
})
it('should be false when the space is disabled', () => {
getWrapper({
setup: ({ actions }) => {
Expand All @@ -33,7 +44,7 @@ describe('navigateToSpace', () => {
}
})
})
it('should be false when the space is no project space', () => {
it('should be true when the space is personal space', () => {
getWrapper({
setup: ({ actions }) => {
expect(
Expand All @@ -45,7 +56,23 @@ describe('navigateToSpace', () => {
})
]
})
).toBe(false)
).toBe(true)
}
})
})
it('should be true when the space is project space', () => {
getWrapper({
setup: ({ actions }) => {
expect(
unref(actions)[0].isVisible({
resources: [
mock<SpaceResource>({
disabled: false,
driveType: 'project'
})
]
})
).toBe(true)
}
})
})
Expand Down