mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-30 04:05:40 +00:00
UBERF-9316 Allow to delete drive file versions (#7889)
This commit is contained in:
parent
2c64ceadb8
commit
bc1d41a63a
@ -568,6 +568,25 @@ function defineFileVersion (builder: Builder): void {
|
|||||||
},
|
},
|
||||||
drive.action.RestoreFileVersion
|
drive.action.RestoreFileVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
|
createAction(
|
||||||
|
builder,
|
||||||
|
{
|
||||||
|
action: view.actionImpl.Delete,
|
||||||
|
visibilityTester: drive.function.CanDeleteFileVersion,
|
||||||
|
label: view.string.Delete,
|
||||||
|
icon: view.icon.Delete,
|
||||||
|
category: drive.category.Drive,
|
||||||
|
input: 'none',
|
||||||
|
target: drive.class.FileVersion,
|
||||||
|
context: {
|
||||||
|
mode: ['context', 'browser'],
|
||||||
|
application: drive.app.Drive,
|
||||||
|
group: 'edit'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
drive.action.DeleteFileVersion
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function defineFile (builder: Builder): void {
|
function defineFile (builder: Builder): void {
|
||||||
|
@ -54,7 +54,8 @@ export default mergeIds(driveId, drive, {
|
|||||||
FolderLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
FolderLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
||||||
FileLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
FileLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
||||||
CanRenameFile: '' as Resource<ViewActionAvailabilityFunction>,
|
CanRenameFile: '' as Resource<ViewActionAvailabilityFunction>,
|
||||||
CanRenameFolder: '' as Resource<ViewActionAvailabilityFunction>
|
CanRenameFolder: '' as Resource<ViewActionAvailabilityFunction>,
|
||||||
|
CanDeleteFileVersion: '' as Resource<ViewActionAvailabilityFunction>
|
||||||
},
|
},
|
||||||
completion: {
|
completion: {
|
||||||
FileQuery: '' as Resource<ObjectSearchFactory>,
|
FileQuery: '' as Resource<ObjectSearchFactory>,
|
||||||
@ -78,6 +79,7 @@ export default mergeIds(driveId, drive, {
|
|||||||
DownloadFile: '' as Ref<Action>,
|
DownloadFile: '' as Ref<Action>,
|
||||||
RenameFile: '' as Ref<Action>,
|
RenameFile: '' as Ref<Action>,
|
||||||
RenameFolder: '' as Ref<Action>,
|
RenameFolder: '' as Ref<Action>,
|
||||||
|
DeleteFileVersion: '' as Ref<Action>,
|
||||||
RestoreFileVersion: '' as Ref<Action>
|
RestoreFileVersion: '' as Ref<Action>
|
||||||
},
|
},
|
||||||
actionImpl: {
|
actionImpl: {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import core, { FindOptions, SortingOrder } from '@hcengineering/core'
|
import { FindOptions, SortingOrder } from '@hcengineering/core'
|
||||||
import { type File, type FileVersion } from '@hcengineering/drive'
|
import { type File, type FileVersion } from '@hcengineering/drive'
|
||||||
import { Scroller, Section } from '@hcengineering/ui'
|
import { Scroller, Section } from '@hcengineering/ui'
|
||||||
import { Table } from '@hcengineering/view-resources'
|
import { Table } from '@hcengineering/view-resources'
|
||||||
@ -24,6 +24,9 @@
|
|||||||
export let readonly: boolean = false
|
export let readonly: boolean = false
|
||||||
|
|
||||||
const options: FindOptions<FileVersion> = {
|
const options: FindOptions<FileVersion> = {
|
||||||
|
lookup: {
|
||||||
|
attachedTo: drive.class.File
|
||||||
|
},
|
||||||
sort: { version: SortingOrder.Descending }
|
sort: { version: SortingOrder.Descending }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -160,6 +160,17 @@ export async function CanRenameFolder (doc: Folder | Folder[] | undefined): Prom
|
|||||||
return doc !== undefined && !Array.isArray(doc)
|
return doc !== undefined && !Array.isArray(doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function CanDeleteFileVersion (
|
||||||
|
doc: WithLookup<FileVersion> | Array<WithLookup<FileVersion>> | undefined
|
||||||
|
): Promise<boolean> {
|
||||||
|
if (doc === undefined) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const docs = Array.isArray(doc) ? doc : [doc]
|
||||||
|
return docs.every((p) => p.$lookup?.attachedTo !== undefined && p.$lookup?.attachedTo.file !== p._id)
|
||||||
|
}
|
||||||
|
|
||||||
export default async (): Promise<Resources> => ({
|
export default async (): Promise<Resources> => ({
|
||||||
component: {
|
component: {
|
||||||
CreateDrive,
|
CreateDrive,
|
||||||
@ -200,7 +211,8 @@ export default async (): Promise<Resources> => ({
|
|||||||
FileLinkProvider,
|
FileLinkProvider,
|
||||||
FolderLinkProvider,
|
FolderLinkProvider,
|
||||||
CanRenameFile,
|
CanRenameFile,
|
||||||
CanRenameFolder
|
CanRenameFolder,
|
||||||
|
CanDeleteFileVersion
|
||||||
},
|
},
|
||||||
resolver: {
|
resolver: {
|
||||||
Location: resolveLocation
|
Location: resolveLocation
|
||||||
|
Loading…
Reference in New Issue
Block a user