From 5b3f69a85f7a01b9e7624eed877092bbd496128a Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Wed, 6 Nov 2024 21:01:29 +0700 Subject: [PATCH] UBERF-8573 Hide archived teamspaces and drives (#7112) --- models/document/src/index.ts | 16 +++++- models/document/src/plugin.ts | 5 +- models/drive/src/index.ts | 16 +++++- models/drive/src/plugin.ts | 4 +- models/view/src/plugin.ts | 3 +- plugins/document-resources/src/index.ts | 7 ++- plugins/drive-resources/src/index.ts | 7 ++- plugins/view-assets/lang/en.json | 3 +- plugins/view-assets/lang/es.json | 3 +- plugins/view-assets/lang/fr.json | 3 +- plugins/view-assets/lang/it.json | 3 +- plugins/view-assets/lang/pt.json | 3 +- plugins/view-assets/lang/ru.json | 3 +- plugins/view-assets/lang/zh.json | 3 +- .../src/components/SpecialView.svelte | 52 +++++++++++++++++-- tests/sanity/tests/drive/drive.spec.ts | 1 + .../tests/model/drive/drive-drives-page.ts | 16 ++++++ 17 files changed, 130 insertions(+), 18 deletions(-) diff --git a/models/document/src/index.ts b/models/document/src/index.ts index 6a51aaca3c..e06e6dbbc3 100644 --- a/models/document/src/index.ts +++ b/models/document/src/index.ts @@ -207,7 +207,21 @@ function defineTeamspace (builder: Builder): void { configOptions: { hiddenKeys: ['name', 'description'] }, - config: ['', 'members', 'private', 'archived'] + config: ['', 'members', 'private', 'archived'], + viewOptions: { + groupBy: [], + orderBy: [], + other: [ + { + key: 'hideArchived', + type: 'toggle', + defaultValue: true, + actionTarget: 'query', + action: document.function.HideArchivedTeamspaces, + label: view.string.HideArchived + } + ] + } }, document.viewlet.TeamspaceTable ) diff --git a/models/document/src/plugin.ts b/models/document/src/plugin.ts index b300742654..883cfc54b8 100644 --- a/models/document/src/plugin.ts +++ b/models/document/src/plugin.ts @@ -21,7 +21,7 @@ import { type ObjectSearchCategory, type ObjectSearchFactory } from '@hcengineer import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform' import { type TagCategory } from '@hcengineering/tags' import { type AnyComponent } from '@hcengineering/ui' -import { type Viewlet, type Action, type ActionCategory, type ViewAction } from '@hcengineering/view' +import type { Viewlet, Action, ActionCategory, ViewAction, ViewQueryAction } from '@hcengineering/view' export default mergeIds(documentId, document, { component: { @@ -51,7 +51,8 @@ export default mergeIds(documentId, document, { }, function: { CanLockDocument: '' as Resource<(doc?: Doc | Doc[]) => Promise>, - CanUnlockDocument: '' as Resource<(doc?: Doc | Doc[]) => Promise> + CanUnlockDocument: '' as Resource<(doc?: Doc | Doc[]) => Promise>, + HideArchivedTeamspaces: '' as ViewQueryAction }, viewlet: { TeamspaceTable: '' as Ref diff --git a/models/drive/src/index.ts b/models/drive/src/index.ts index c4d35d18b8..c262ce8005 100644 --- a/models/drive/src/index.ts +++ b/models/drive/src/index.ts @@ -268,7 +268,21 @@ function defineDrive (builder: Builder): void { configOptions: { hiddenKeys: ['name', 'description'] }, - config: ['', 'members', 'owners', 'private', 'archived'] + config: ['', 'members', 'owners', 'private', 'archived'], + viewOptions: { + groupBy: [], + orderBy: [], + other: [ + { + key: 'hideArchived', + type: 'toggle', + defaultValue: true, + actionTarget: 'query', + action: drive.function.HideArchivedDrives, + label: view.string.HideArchived + } + ] + } }, drive.viewlet.DriveTable ) diff --git a/models/drive/src/plugin.ts b/models/drive/src/plugin.ts index 533cb025d5..032df816a8 100644 --- a/models/drive/src/plugin.ts +++ b/models/drive/src/plugin.ts @@ -25,6 +25,7 @@ import { type ActionCategory, type ViewAction, type ViewActionAvailabilityFunction, + type ViewQueryAction, type Viewlet, type ViewletDescriptor } from '@hcengineering/view' @@ -54,7 +55,8 @@ export default mergeIds(driveId, drive, { FolderLinkProvider: '' as Resource<(doc: Doc, props: Record) => Promise>, FileLinkProvider: '' as Resource<(doc: Doc, props: Record) => Promise>, CanRenameFile: '' as Resource, - CanRenameFolder: '' as Resource + CanRenameFolder: '' as Resource, + HideArchivedDrives: '' as ViewQueryAction }, completion: { FileQuery: '' as Resource, diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index d456d2abee..4f71ba9b84 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -110,7 +110,8 @@ export default mergeIds(viewId, view, { General: '' as IntlString, Navigation: '' as IntlString, Editor: '' as IntlString, - MarkdownFormatting: '' as IntlString + MarkdownFormatting: '' as IntlString, + HideArchived: '' as IntlString }, function: { FilterArrayAllResult: '' as FilterFunction, diff --git a/plugins/document-resources/src/index.ts b/plugins/document-resources/src/index.ts index 72b151e4ae..b46ea7c610 100644 --- a/plugins/document-resources/src/index.ts +++ b/plugins/document-resources/src/index.ts @@ -159,6 +159,10 @@ export async function canUnlockDocument (doc: Document | Document[]): Promise p.lockedBy != null) } +export function hideArchivedTeamspaces (value: boolean, query: DocumentQuery): DocumentQuery { + return value ? { ...query, archived: false } : query +} + export default async (): Promise => ({ component: { CreateDocument, @@ -196,7 +200,8 @@ export default async (): Promise => ({ CanLockDocument: canLockDocument, CanUnlockDocument: canUnlockDocument, GetDocumentLinkId: getDocumentLinkId, - ParseDocumentId: parseDocumentId + ParseDocumentId: parseDocumentId, + HideArchivedTeamspaces: hideArchivedTeamspaces }, resolver: { Location: resolveLocation diff --git a/plugins/drive-resources/src/index.ts b/plugins/drive-resources/src/index.ts index 22343aa278..d41c7bffcb 100644 --- a/plugins/drive-resources/src/index.ts +++ b/plugins/drive-resources/src/index.ts @@ -160,6 +160,10 @@ export async function CanRenameFolder (doc: Folder | Folder[] | undefined): Prom return doc !== undefined && !Array.isArray(doc) } +export function HideArchivedDrives (value: boolean, query: DocumentQuery): DocumentQuery { + return value ? { ...query, archived: false } : query +} + export default async (): Promise => ({ component: { CreateDrive, @@ -200,7 +204,8 @@ export default async (): Promise => ({ FileLinkProvider, FolderLinkProvider, CanRenameFile, - CanRenameFolder + CanRenameFolder, + HideArchivedDrives }, resolver: { Location: resolveLocation diff --git a/plugins/view-assets/lang/en.json b/plugins/view-assets/lang/en.json index ba1013178b..9ef6000360 100644 --- a/plugins/view-assets/lang/en.json +++ b/plugins/view-assets/lang/en.json @@ -125,6 +125,7 @@ "MoreActions": "More actions", "Leave": "Leave", "Join": "Join", - "Copied": "Copied" + "Copied": "Copied", + "HideArchived": "Hide archived" } } diff --git a/plugins/view-assets/lang/es.json b/plugins/view-assets/lang/es.json index 57288a9388..d75fa4bdca 100644 --- a/plugins/view-assets/lang/es.json +++ b/plugins/view-assets/lang/es.json @@ -120,6 +120,7 @@ "MoreActions": "Más Acciones", "Leave": "Salir", "Join": "Unirse", - "Copied": "Copiado" + "Copied": "Copiado", + "HideArchived": "Ocultar archivadas" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/fr.json b/plugins/view-assets/lang/fr.json index 031ab57189..80dffa64bc 100644 --- a/plugins/view-assets/lang/fr.json +++ b/plugins/view-assets/lang/fr.json @@ -120,6 +120,7 @@ "MoreActions": "Plus d'actions", "Leave": "Quitter", "Join": "Rejoindre", - "Copied": "Copié" + "Copied": "Copié", + "HideArchived": "Masquer les archives" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/it.json b/plugins/view-assets/lang/it.json index f5e86a5f5d..84c3a00a16 100644 --- a/plugins/view-assets/lang/it.json +++ b/plugins/view-assets/lang/it.json @@ -120,6 +120,7 @@ "MoreActions": "Altre azioni", "Leave": "Esci", "Join": "Unisciti", - "Copied": "Copiato" + "Copied": "Copiato", + "HideArchived": "Nascondi archiviato" } } diff --git a/plugins/view-assets/lang/pt.json b/plugins/view-assets/lang/pt.json index 8c009a19d3..1df93c9011 100644 --- a/plugins/view-assets/lang/pt.json +++ b/plugins/view-assets/lang/pt.json @@ -120,6 +120,7 @@ "MoreActions": "Mais Ações", "Leave": "Sair", "Join": "Ingressar", - "Copied": "Copiado" + "Copied": "Copiado", + "HideArchived": "Ocultar arquivado" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/ru.json b/plugins/view-assets/lang/ru.json index d2c3f54823..cb554da378 100644 --- a/plugins/view-assets/lang/ru.json +++ b/plugins/view-assets/lang/ru.json @@ -122,6 +122,7 @@ "MoreActions": "Больше действий", "Leave": "Покинуть", "Join": "Присоединиться", - "Copied": "Скопировано" + "Copied": "Скопировано", + "HideArchived": "Скрыть архивные" } } diff --git a/plugins/view-assets/lang/zh.json b/plugins/view-assets/lang/zh.json index 34e738e854..3d31fb6195 100644 --- a/plugins/view-assets/lang/zh.json +++ b/plugins/view-assets/lang/zh.json @@ -125,6 +125,7 @@ "MoreActions": "更多操作", "Leave": "离开", "Join": "加入", - "Copied": "已复制" + "Copied": "已复制", + "HideArchived": "隱藏已存檔" } } diff --git a/plugins/workbench-resources/src/components/SpecialView.svelte b/plugins/workbench-resources/src/components/SpecialView.svelte index c1358ef78a..5f1462904d 100644 --- a/plugins/workbench-resources/src/components/SpecialView.svelte +++ b/plugins/workbench-resources/src/components/SpecialView.svelte @@ -14,7 +14,8 @@ -->