From b36e6b1ea74f3e6e9da9b906ac71904721242a7d Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Wed, 31 May 2023 16:25:58 +0400 Subject: [PATCH] [UBER-70] Remove old Projects section from Workspace/templates (#3302) Signed-off-by: Sergei Ogorelkov --- models/task/src/migration.ts | 64 ++--------------------------- models/task/src/plugin.ts | 6 +-- plugins/task-assets/lang/en.json | 2 - plugins/task-assets/lang/ru.json | 2 - plugins/task-resources/src/index.ts | 2 - plugins/task/src/index.ts | 3 -- 6 files changed, 5 insertions(+), 74 deletions(-) diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index d75afd0658..f99747ca19 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -15,9 +15,9 @@ import { Class, Doc, Domain, Ref, Space, TxOperations, DOMAIN_STATUS } from '@hcengineering/core' import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model' -import core from '@hcengineering/model-core' +import core, { DOMAIN_SPACE } from '@hcengineering/model-core' import tags from '@hcengineering/model-tags' -import { createKanban, DoneStateTemplate, genRanks, KanbanTemplate, StateTemplate } from '@hcengineering/task' +import { DoneStateTemplate, genRanks, KanbanTemplate, StateTemplate } from '@hcengineering/task' import { DOMAIN_TASK, DOMAIN_KANBAN } from '.' import task from './plugin' @@ -127,66 +127,8 @@ async function createDefaultSequence (tx: TxOperations): Promise { } } -async function createDefaultKanbanTemplate (tx: TxOperations): Promise> { - const defaultKanban = { - states: [ - { color: 9, name: 'Open' }, - { color: 10, name: 'In Progress' }, - { color: 1, name: 'Under review' }, - { color: 0, name: 'Done' }, - { color: 11, name: 'Invalid' } - ], - doneStates: [ - { isWon: true, name: 'Won' }, - { isWon: false, name: 'Lost' } - ] - } - - return await createKanbanTemplate(tx, { - kanbanId: task.template.DefaultProject, - space: task.space.ProjectTemplates as Ref as Ref, - title: 'Default project', - description: '', - shortDescription: '', - states: defaultKanban.states, - doneStates: defaultKanban.doneStates - }) -} - -async function createDefaultKanban (tx: TxOperations): Promise { - const current = await tx.findOne(task.class.Kanban, { - attachedTo: task.space.TasksPublic - }) - if (current !== undefined) return - const defaultTmpl = await createDefaultKanbanTemplate(tx) - await createKanban(tx, task.space.TasksPublic, defaultTmpl) -} - -async function createSpace (tx: TxOperations): Promise { - const currentTemplate = await tx.findOne(core.class.Space, { - _id: task.space.ProjectTemplates - }) - if (currentTemplate === undefined) { - await tx.createDoc( - task.class.KanbanTemplateSpace, - core.space.Space, - { - name: task.string.Projects, - description: task.string.ManageProjectStatues, - icon: task.component.TemplatesIcon, - private: false, - members: [], - archived: false - }, - task.space.ProjectTemplates - ) - } -} - async function createDefaults (tx: TxOperations): Promise { - await createSpace(tx) await createDefaultSequence(tx) - await createDefaultKanban(tx) } async function migrateTodoItems (client: MigrationClient): Promise { @@ -237,6 +179,8 @@ export const taskOperation: MigrateOperation = { { _class: { $in: [...stateTemplateClasses, ...doneStateTemplatesClasses] }, title: { $exists: true } }, { $rename: { title: 'name' } } ) + + await client.delete(DOMAIN_SPACE, 'task:space:ProjectTemplates' as Space['_id']) }, async upgrade (client: MigrationUpgradeClient): Promise { const tx = new TxOperations(client, core.account.System) diff --git a/models/task/src/plugin.ts b/models/task/src/plugin.ts index 81e5cbb924..6fdbcc1d9d 100644 --- a/models/task/src/plugin.ts +++ b/models/task/src/plugin.ts @@ -17,7 +17,7 @@ import type { Ref, Space } from '@hcengineering/core' import { mergeIds } from '@hcengineering/platform' import { TagCategory } from '@hcengineering/tags' -import { KanbanTemplate, taskId } from '@hcengineering/task' +import { taskId } from '@hcengineering/task' import task from '@hcengineering/task-resources/src/plugin' import type { AnyComponent } from '@hcengineering/ui' import type { Action, ActionCategory, ViewAction, Viewlet } from '@hcengineering/view' @@ -47,7 +47,6 @@ export default mergeIds(taskId, task, { TaskPresenter: '' as AnyComponent, KanbanTemplatePresenter: '' as AnyComponent, KanbanCard: '' as AnyComponent, - TemplatesIcon: '' as AnyComponent, StatePresenter: '' as AnyComponent, DoneStatePresenter: '' as AnyComponent, StateEditor: '' as AnyComponent, @@ -64,9 +63,6 @@ export default mergeIds(taskId, task, { space: { TasksPublic: '' as Ref }, - template: { - DefaultProject: '' as Ref - }, viewlet: { TableIssue: '' as Ref, KanbanIssue: '' as Ref diff --git a/plugins/task-assets/lang/en.json b/plugins/task-assets/lang/en.json index 3c78e0bc2b..7c2f7a98ce 100644 --- a/plugins/task-assets/lang/en.json +++ b/plugins/task-assets/lang/en.json @@ -32,7 +32,6 @@ "MarkAsUndone": "Mark as undone", "Kanban": "Kanban", "ApplicationLabelTask": "Tasks", - "Projects": "Projects", "ProjectNamePlaceholder": "Project name", "TaskNamePlaceholder": "The boring task", "TodoDescriptionPlaceholder": "todo...", @@ -63,7 +62,6 @@ "States": "States", "NoDoneState": "Not done", "ManageStatusesWithin": "Manage application statuses within", - "ManageProjectStatues": "Manage project statues", "UnarchiveConfirm": "Do you want to unarchive?", "ArchiveConfirm": "Do you want to archive?", "StatusDelete": "Delete status", diff --git a/plugins/task-assets/lang/ru.json b/plugins/task-assets/lang/ru.json index c972eb1c31..a023518463 100644 --- a/plugins/task-assets/lang/ru.json +++ b/plugins/task-assets/lang/ru.json @@ -32,7 +32,6 @@ "MarkAsUndone": "Отметить невыполненным", "Kanban": "Канбан", "ApplicationLabelTask": "Задачи", - "Projects": "Проекты", "ProjectNamePlaceholder": "Название проекта", "TaskNamePlaceholder": "Задача", "TodoDescriptionPlaceholder": "todo...", @@ -63,7 +62,6 @@ "States": "Статусы", "NoDoneState": "Не завершено", "ManageStatusesWithin": "Управление статусами для", - "ManageProjectStatues": "Управление статусами задачи", "UnarchiveConfirm": "Вы действительно хотите разархивировать?", "ArchiveConfirm": "Вы действительно хотите архивировать?", "StatusDelete": "Удалить статус", diff --git a/plugins/task-resources/src/index.ts b/plugins/task-resources/src/index.ts index 5a5e8b2418..06c04cdf3f 100644 --- a/plugins/task-resources/src/index.ts +++ b/plugins/task-resources/src/index.ts @@ -30,7 +30,6 @@ import StatusTableView from './components/StatusTableView.svelte' import TaskHeader from './components/TaskHeader.svelte' import TaskPresenter from './components/TaskPresenter.svelte' import KanbanTemplatePresenter from './components/KanbanTemplatePresenter.svelte' -import TemplatesIcon from './components/TemplatesIcon.svelte' import TodoItemPresenter from './components/todos/TodoItemPresenter.svelte' import TodoItemsPopup from './components/todos/TodoItemsPopup.svelte' import Todos from './components/todos/Todos.svelte' @@ -54,7 +53,6 @@ export default async (): Promise => ({ TaskPresenter, KanbanTemplatePresenter, Dashboard, - TemplatesIcon, KanbanView, StatePresenter, StateEditor, diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index d49ab67d1a..3884040c6a 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -226,8 +226,6 @@ const task = plugin(taskId, { MarkAsUndone: '' as IntlString, Kanban: '' as IntlString, ApplicationLabelTask: '' as IntlString, - Projects: '' as IntlString, - ManageProjectStatues: '' as IntlString, TodoItems: '' as IntlString, AssignedToMe: '' as IntlString, Dashboard: '' as IntlString @@ -268,7 +266,6 @@ const task = plugin(taskId, { Task: '' as Ref }, space: { - ProjectTemplates: '' as Ref, Sequence: '' as Ref }, component: {