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

fix: add missing share date #10834

Merged
merged 2 commits into from
Apr 30, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
84 changes: 82 additions & 2 deletions packages/web-client/src/graph/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,12 @@ export interface Permission {
* @memberof Permission
*/
'expirationDateTime'?: string | null;
/**
* An optional creation date. Libregraph only.
* @type {string}
* @memberof Permission
*/
'createdDateTime'?: string | null;
/**
*
* @type {SharePointIdentitySet}
Expand Down Expand Up @@ -2551,6 +2557,44 @@ export const DriveItemApiAxiosParamCreator = function (configuration?: Configura



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Get a DriveItem by using its ID.
* @summary Get a DriveItem.
* @param {string} driveId key: id of drive
* @param {string} itemId key: id of item
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getDriveItem: async (driveId: string, itemId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'driveId' is not null or undefined
assertParamExists('getDriveItem', 'driveId', driveId)
// verify required parameter 'itemId' is not null or undefined
assertParamExists('getDriveItem', 'itemId', itemId)
const localVarPath = `/v1beta1/drives/{drive-id}/items/{item-id}`
.replace(`{${"drive-id"}}`, encodeURIComponent(String(driveId)))
.replace(`{${"item-id"}}`, encodeURIComponent(String(itemId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
Expand Down Expand Up @@ -2626,6 +2670,18 @@ export const DriveItemApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.deleteDriveItem(driveId, itemId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Get a DriveItem by using its ID.
* @summary Get a DriveItem.
* @param {string} driveId key: id of drive
* @param {string} itemId key: id of item
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getDriveItem(driveId: string, itemId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DriveItem>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getDriveItem(driveId, itemId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Update a DriveItem. The request body must include a JSON object with the properties to update. Only the properties that are provided will be updated. Currently it supports updating the following properties: * `@UI.Hidden` - Hides the item from the UI.
* @summary Update a DriveItem.
Expand All @@ -2635,7 +2691,7 @@ export const DriveItemApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateDriveItem(driveId: string, itemId: string, driveItem: DriveItem, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
async updateDriveItem(driveId: string, itemId: string, driveItem: DriveItem, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DriveItem>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateDriveItem(driveId, itemId, driveItem, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
Expand All @@ -2660,6 +2716,17 @@ export const DriveItemApiFactory = function (configuration?: Configuration, base
deleteDriveItem(driveId: string, itemId: string, options?: any): AxiosPromise<void> {
return localVarFp.deleteDriveItem(driveId, itemId, options).then((request) => request(axios, basePath));
},
/**
* Get a DriveItem by using its ID.
* @summary Get a DriveItem.
* @param {string} driveId key: id of drive
* @param {string} itemId key: id of item
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getDriveItem(driveId: string, itemId: string, options?: any): AxiosPromise<DriveItem> {
return localVarFp.getDriveItem(driveId, itemId, options).then((request) => request(axios, basePath));
},
/**
* Update a DriveItem. The request body must include a JSON object with the properties to update. Only the properties that are provided will be updated. Currently it supports updating the following properties: * `@UI.Hidden` - Hides the item from the UI.
* @summary Update a DriveItem.
Expand All @@ -2669,7 +2736,7 @@ export const DriveItemApiFactory = function (configuration?: Configuration, base
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateDriveItem(driveId: string, itemId: string, driveItem: DriveItem, options?: any): AxiosPromise<void> {
updateDriveItem(driveId: string, itemId: string, driveItem: DriveItem, options?: any): AxiosPromise<DriveItem> {
return localVarFp.updateDriveItem(driveId, itemId, driveItem, options).then((request) => request(axios, basePath));
},
};
Expand All @@ -2695,6 +2762,19 @@ export class DriveItemApi extends BaseAPI {
return DriveItemApiFp(this.configuration).deleteDriveItem(driveId, itemId, options).then((request) => request(this.axios, this.basePath));
}

/**
* Get a DriveItem by using its ID.
* @summary Get a DriveItem.
* @param {string} driveId key: id of drive
* @param {string} itemId key: id of item
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DriveItemApi
*/
public getDriveItem(driveId: string, itemId: string, options?: AxiosRequestConfig) {
return DriveItemApiFp(this.configuration).getDriveItem(driveId, itemId, options).then((request) => request(this.axios, this.basePath));
}

/**
* Update a DriveItem. The request body must include a JSON object with the properties to update. Only the properties that are provided will be updated. Currently it supports updating the following properties: * `@UI.Hidden` - Hides the item from the UI.
* @summary Update a DriveItem.
Expand Down
6 changes: 5 additions & 1 deletion packages/web-client/src/graph/index.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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