Skip to content

Commit

Permalink
fix: add missing share date
Browse files Browse the repository at this point in the history
Adds the missing share date for incoming share resources as well as listed shares in the right sidebar.
  • Loading branch information
JammingBen committed Apr 30, 2024
1 parent b7a20be commit e2bf4d5
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 30 deletions.
Expand Up @@ -198,7 +198,7 @@ export default defineComponent({
const { showMessage, showErrorMessage } = useMessages()
const userStore = useUserStore()
const clientService = useClientService()
const { $gettext } = useGettext()
const { $gettext, current: currentLanguage } = useGettext()
const { dispatchModal } = useModals()
const { updateShare } = useSharesStore()
Expand All @@ -212,6 +212,10 @@ export default defineComponent({
.pop()
})
const shareDate = computed(() => {
return formatDateFromDateTime(DateTime.fromISO(props.share.createdDateTime), currentLanguage)
})
const setDenyShare = (value) => {
emit('onSetDeny', { share: props.share, value })
}
Expand All @@ -238,6 +242,7 @@ export default defineComponent({
user,
clientService,
sharedParentDir,
shareDate,
setDenyShare,
showNotifyShareModal,
showMessage,
Expand Down Expand Up @@ -334,14 +339,6 @@ export default defineComponent({
editDropDownToggleId() {
return uuid.v4()
},
shareDate() {
return ''
// FIXME
// return formatDateFromDateTime(
// DateTime.fromSeconds(parseInt(this.share.permission.)),
// this.$language.current
// )
},
shareOwnerDisplayName() {
return this.share.sharedBy.displayName
},
Expand Down
Expand Up @@ -179,15 +179,15 @@ export default defineComponent({
const directLinks = computed(() =>
unref(linkShares)
.filter((l) => !l.indirect && !l.isQuickLink)
.sort((a: any, b: any) => b.stime - a.stime) // FIXME: share date not yet available
.sort((a, b) => b.createdDateTime.localeCompare(a.createdDateTime))
.map((share) => {
return { ...share, key: 'direct-link-' + share.id }
})
)
const indirectLinks = computed(() =>
unref(linkShares)
.filter((l) => l.indirect)
.sort((a: any, b: any) => b.stime - a.stime) // FIXME: share date not yet available
.sort((a, b) => b.createdDateTime.localeCompare(a.createdDateTime))
.map((share) => {
return { ...share, key: 'indirect-link-' + share.id }
})
Expand Down
Expand Up @@ -55,7 +55,8 @@ const getShareMock = ({
role: mock<ShareRole>({ description: '', displayName: '' }),
resourceId: '1',
indirect: false,
expirationDateTime: expirationDateTime || ''
expirationDateTime: expirationDateTime || '',
createdDateTime: '2024-01-01'
})

describe('Collaborator ListItem component', () => {
Expand Down
Expand Up @@ -19,13 +19,15 @@ const defaultLinksList = [
id: '1',
indirect: false,
shareType: ShareTypes.link.value,
createdDateTime: '2020-01-01',
displayName: 'public link 1',
webUrl: ' some-link-1'
},
{
id: '2',
indirect: true,
shareType: ShareTypes.link.value,
createdDateTime: '2020-01-01',
displayName: 'public link 2',
webUrl: ' some-link-2'
}
Expand Down Expand Up @@ -70,7 +72,11 @@ describe('FileLinks', () => {
})

describe('collapsing', () => {
const link = mock<LinkShare>({ indirect: false, isQuickLink: false })
const link = mock<LinkShare>({
indirect: false,
isQuickLink: false,
createdDateTime: '2020-01-01'
})

it('shows all links if showAllOnLoad config is set', () => {
const links = [link, link, link, link]
Expand Down
Expand Up @@ -34,7 +34,8 @@ const getCollaborator = (): CollaboratorShare => ({
role: mock<ShareRole>(),
resourceId: uuidV4(),
indirect: false,
shareType: ShareTypes.user.value
shareType: ShareTypes.user.value,
createdDateTime: '2024-01-01'
})

describe('FileShares', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/web-client/src/graph/index.ts
Expand Up @@ -61,7 +61,11 @@ export interface Graph {
disableDrive: (id: string) => AxiosPromise<void>
deleteDrive: (id: string) => AxiosPromise<void>
deleteDriveItem: (driveId: string, itemId: string) => AxiosPromise<void>
updateDriveItem: (driveId: string, itemId: string, driveItem: DriveItem) => AxiosPromise<void>
updateDriveItem: (
driveId: string,
itemId: string,
driveItem: DriveItem
) => AxiosPromise<DriveItem>
createDriveItem: (driveId: string, driveItem: DriveItem) => AxiosPromise<DriveItem>
}
users: {
Expand Down
1 change: 0 additions & 1 deletion packages/web-client/src/helpers/resource/types.ts
Expand Up @@ -67,7 +67,6 @@ export interface Resource {
lockTime?: string
mimeType?: string
isFolder?: boolean
sdate?: string // FIXME: move to `ShareResource`
mdate?: string
indicators?: ResourceIndicator[]
size?: number | string // FIXME
Expand Down
6 changes: 4 additions & 2 deletions packages/web-client/src/helpers/share/functions.ts
Expand Up @@ -122,7 +122,7 @@ export function buildIncomingShareResource({
fileId: driveItem.remoteItem.id,
storageId,
parentFolderId: driveItem.parentReference?.id,
sdate: driveItem.lastModifiedDateTime, // FIXME: share date is missing in API
sdate: driveItem.remoteItem.permissions[0].createdDateTime,
indicators: [],
tags: [],
webDavPath: buildWebDavSpacesPath(driveItem.id, '/'),
Expand Down Expand Up @@ -175,7 +175,7 @@ export function buildOutgoingShareResource({
fileId: driveItem.id,
storageId,
parentFolderId: driveItem.parentReference?.id,
sdate: driveItem.lastModifiedDateTime, // FIXME: share date is missing in API
sdate: driveItem.permissions[0].createdDateTime,
indicators: [],
tags: [],
webDavPath: buildWebDavSpacesPath(storageId, path),
Expand Down Expand Up @@ -251,6 +251,7 @@ export function buildCollaboratorShare({
permissions: (graphPermission['@libre.graph.permissions.actions']
? graphPermission['@libre.graph.permissions.actions']
: role.rolePermissions.flatMap((p) => p.allowedResourceActions)) as GraphSharePermission[],
createdDateTime: graphPermission.createdDateTime,
expirationDateTime: graphPermission.expirationDateTime
}
}
Expand All @@ -273,6 +274,7 @@ export function buildLinkShare({
shareType: ShareTypes.link.value,
sharedBy: { id: user.id, displayName: user.displayName },
hasPassword: graphPermission.hasPassword,
createdDateTime: graphPermission.createdDateTime,
expirationDateTime: graphPermission.expirationDateTime,
displayName: graphPermission.link['@libre.graph.displayName'],
isQuickLink: graphPermission.link['@libre.graph.quickLink'],
Expand Down
2 changes: 2 additions & 0 deletions packages/web-client/src/helpers/share/types.ts
Expand Up @@ -19,6 +19,7 @@ export enum GraphSharePermission {
export interface ShareResource extends Resource {
sharedWith: Array<{ shareType: number } & Identity>
sharedBy: Identity[]
sdate: string
outgoing: boolean
driveId: string
}
Expand All @@ -42,6 +43,7 @@ export interface Share {
indirect: boolean
sharedBy: Identity
shareType: number
createdDateTime: string
expirationDateTime?: string
}

Expand Down
Expand Up @@ -104,8 +104,7 @@ export const useSharesStore = defineStore('shares', () => {
return
}

// FIXME: use push as soon as we have a share date
unref(linkShares).unshift(share)
unref(linkShares).push(share)
}

const removeLinkShare = (share: LinkShare) => {
Expand Down
20 changes: 10 additions & 10 deletions packages/web-pkg/tests/unit/composables/sort/useSort.spec.ts
Expand Up @@ -33,15 +33,15 @@ describe('useSort', () => {

describe('sorting resources', () => {
const resources: Resource[] = [
{ id: '1', name: 'c.png', path: '', webDavPath: '', sdate: '2' },
{ id: '2', name: 'Dir4', path: '', webDavPath: '', sdate: '4', type: 'folder' },
{ id: '3', name: 'a.png', path: '', webDavPath: '', sdate: '3' },
{ id: '4', name: 'A.png', path: '', webDavPath: '', sdate: '6' },
{ id: '5', name: 'dir2', path: '', webDavPath: '', sdate: '7', type: 'folder' },
{ id: '6', name: 'b.png', path: '', webDavPath: '', sdate: '1' },
{ id: '7', name: 'Dir1', path: '', webDavPath: '', sdate: '5', type: 'folder' },
{ id: '8', name: 'dir11', path: '', webDavPath: '', sdate: '8', type: 'folder' },
{ id: '9', name: 'dir3', path: '', webDavPath: '', sdate: '9', type: 'folder' }
{ id: '1', name: 'c.png', path: '', webDavPath: '', mdate: '2' },
{ id: '2', name: 'Dir4', path: '', webDavPath: '', mdate: '4', type: 'folder' },
{ id: '3', name: 'a.png', path: '', webDavPath: '', mdate: '3' },
{ id: '4', name: 'A.png', path: '', webDavPath: '', mdate: '6' },
{ id: '5', name: 'dir2', path: '', webDavPath: '', mdate: '7', type: 'folder' },
{ id: '6', name: 'b.png', path: '', webDavPath: '', mdate: '1' },
{ id: '7', name: 'Dir1', path: '', webDavPath: '', mdate: '5', type: 'folder' },
{ id: '8', name: 'dir11', path: '', webDavPath: '', mdate: '8', type: 'folder' },
{ id: '9', name: 'dir3', path: '', webDavPath: '', mdate: '9', type: 'folder' }
]

it('sorts resources by name', () => {
Expand All @@ -55,7 +55,7 @@ describe('useSort', () => {
sortable: true
},
{
name: 'sdate',
name: 'mdate',
sortable: true
}
],
Expand Down

0 comments on commit e2bf4d5

Please sign in to comment.