From ba5b0749bc2aafeee823f54258a6517eecca6edf Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Fri, 7 Jun 2024 15:40:24 +0700 Subject: [PATCH] UBERF-7181: Fix GH PR statuses (#5749) Signed-off-by: Andrey Sobolev --- models/task/src/migration.ts | 22 +++++++++++++++-- .../presentation/src/components/Card.svelte | 1 + packages/ui/src/components/Button.svelte | 2 ++ plugins/login-resources/src/utils.ts | 3 ++- plugins/login/src/index.ts | 2 ++ .../src/components/PluginCard.svelte | 6 +++-- .../src/components/SelectWorkspaceMenu.svelte | 24 +++++++++++++++---- server/account/src/operations.ts | 3 +++ 8 files changed, 53 insertions(+), 10 deletions(-) diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index 2d4c4ffc94..a43aad23f7 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -18,6 +18,7 @@ import { DOMAIN_STATUS, DOMAIN_TX, TxOperations, + toIdMap, type Attribute, type Class, type Doc, @@ -50,8 +51,8 @@ import { type TaskType } from '@hcengineering/task' -import task from './plugin' import { DOMAIN_TASK } from '.' +import task from './plugin' /** * @public @@ -566,7 +567,24 @@ function areSameArrays (arr1: any[] | undefined, arr2: any[] | undefined): boole export const taskOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise { - await tryMigrate(client, taskId, []) + await tryMigrate(client, taskId, [ + { + state: 'migrate-tt-model-states', + func: async (client) => { + const prTaskTypes = client.model.findAllSync(task.class.TaskType, {}) + + const allModelStatuses = toIdMap(client.model.findAllSync(core.class.Status, {})) + for (const tt of prTaskTypes) { + const missing = tt.statuses.filter((it) => !allModelStatuses.has(it)) + await client.update( + DOMAIN_TX, + { objectId: { $in: missing }, objectSpace: 'task:space:Statuses' }, + { $set: { objectSpace: core.space.Model } } + ) + } + } + } + ]) }, async upgrade (client: MigrationUpgradeClient): Promise { await tryUpgrade(client, taskId, [ diff --git a/packages/presentation/src/components/Card.svelte b/packages/presentation/src/components/Card.svelte index bbed53e71b..6bba7cb726 100644 --- a/packages/presentation/src/components/Card.svelte +++ b/packages/presentation/src/components/Card.svelte @@ -197,6 +197,7 @@