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

UBERF-7181: Fix GH PR statuses #5749

Merged
merged 1 commit into from
Jun 7, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions models/task/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
DOMAIN_STATUS,
DOMAIN_TX,
TxOperations,
toIdMap,
type Attribute,
type Class,
type Doc,
Expand Down Expand Up @@ -50,8 +51,8 @@ import {
type TaskType
} from '@hcengineering/task'

import task from './plugin'
import { DOMAIN_TASK } from '.'
import task from './plugin'

/**
* @public
Expand Down Expand Up @@ -566,7 +567,24 @@ function areSameArrays (arr1: any[] | undefined, arr2: any[] | undefined): boole

export const taskOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {
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<void> {
await tryUpgrade(client, taskId, [
Expand Down
1 change: 1 addition & 0 deletions packages/presentation/src/components/Card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<Button
loading={okProcessing}
focusIndex={10001}
minWidth={'5rem'}
disabled={!canSave}
label={okLabel}
kind={'primary'}
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
export let disabled: boolean = false
export let loading: boolean = false
export let width: string | undefined = undefined
export let minWidth: string | undefined = undefined
export let height: string | undefined = undefined
export let resetIconSize: 'none' | 'icon' | 'full' = 'none'
export let highlight: boolean = false
Expand Down Expand Up @@ -137,6 +138,7 @@
disabled={disabled || loading}
class:short
class:resetIconSize={resetIconSize === 'full'}
style:min-width={minWidth}
style:width
style:height
style:flex-shrink={shrink}
Expand Down
3 changes: 2 additions & 1 deletion plugins/login-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export async function getWorkspaces (): Promise<Workspace[]> {
return [
{
workspace: DEV_WORKSPACE,
workspaceId: DEV_WORKSPACE
workspaceId: DEV_WORKSPACE,
lastVisit: 0
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/login/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export interface Workspace {

creating?: boolean
createProgress?: number

lastVisit: number
}

/**
Expand Down
6 changes: 4 additions & 2 deletions plugins/setting-resources/src/components/PluginCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,22 @@
{#if (integration?.value ?? '') === ''}
{#if integrationType.createComponent}
<Button
minWidth={'5rem'}
label={setting.string.Add}
kind={'primary'}
on:click={(ev) => handleConfigure(integrationType.createComponent)}
/>
{/if}
{:else if (integration?.disabled ?? false) && integrationType.reconnectComponent}
<Button label={setting.string.Reconnect} kind={'primary'} on:click={handleReconnect} />
<Button label={setting.string.Reconnect} minWidth={'5rem'} kind={'primary'} on:click={handleReconnect} />
{:else if integration?.value !== ''}
{#if integrationType.onDisconnect}
<Button label={setting.string.Disconnect} on:click={disconnect} />
<Button label={setting.string.Disconnect} minWidth={'5rem'} on:click={disconnect} />
{/if}
{#if integrationType.configureComponent !== undefined}
<Button
label={setting.string.Configure}
minWidth={'5rem'}
kind={'primary'}
on:click={(ev) => handleConfigure(integrationType.configureComponent)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
// limitations under the License.
-->
<script lang="ts">
import contact from '@hcengineering/contact'
import login, { Workspace } from '@hcengineering/login'
import { getMetadata, getResource } from '@hcengineering/platform'
import contact from '@hcengineering/contact'
import presentation, { decodeTokenPayload, isAdminUser } from '@hcengineering/presentation'
import {
Icon,
IconCheck,
Expand All @@ -34,7 +35,6 @@
import { workbenchId } from '@hcengineering/workbench'
import { onDestroy, onMount } from 'svelte'
import { workspacesStore } from '../utils'
import presentation, { isAdminUser } from '@hcengineering/presentation'
// import Drag from './icons/Drag.svelte'

onMount(() => {
Expand Down Expand Up @@ -134,20 +134,29 @@
<div class="antiPopup" on:keydown={keyDown}>
<div class="ap-space x2" />
{#if isAdmin}
<div class="ml-2 mr-2 mb-2 flex-grow flex-row-center">
<div class="p-2 ml-2 mr-2 mb-2 flex-grow flex-row-center">
<SearchEdit bind:value={search} width={'100%'} />
{#if isAdminUser()}
<div class="p-1">
{#if $workspacesStore.length > 500}
500 /
{/if}
{$workspacesStore.length}
</div>
{/if}
</div>
<div class="p-2 ml-2 mb-4 select-text flex-col bordered">
{decodeTokenPayload(getMetadata(presentation.metadata.Token) ?? '').workspace}
</div>
{/if}
<div class="ap-scroll">
<div class="ap-box">
{#each $workspacesStore.filter((it) => search === '' || (it.workspaceName?.includes(search) ?? false) || it.workspace.includes(search)) as ws, i}
{#each $workspacesStore
.filter((it) => search === '' || (it.workspaceName?.includes(search) ?? false) || it.workspace.includes(search))
.slice(0, 500) as ws, i}
{@const wsName = ws.workspaceName ?? ws.workspace}
{@const _activeSession = activeSessions[ws.workspaceId]}
{@const lastUsageDays = Math.round((Date.now() - ws.lastVisit) / (1000 * 3600 * 24))}
<a
class="stealth"
href={getWorkspaceLink(ws)}
Expand All @@ -168,8 +177,13 @@
<!-- <div class="logo empty" /> -->
<!-- <div class="flex-col flex-grow"> -->
<div class="flex-col flex-grow">
<span class="label overflow-label flex-grow">
<span class="label overflow-label flex flex-grow flex-between">
{wsName}
{#if isAdmin && ws.lastVisit != null && ws.lastVisit !== 0}
<div class="text-sm">
({lastUsageDays} days)
</div>
{/if}
</span>
{#if isAdmin && wsName !== ws.workspace}
<span class="text-xs">
Expand Down
3 changes: 3 additions & 0 deletions server/account/src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ export async function getUserWorkspaces (
await db
.collection<Workspace>(WORKSPACE_COLLECTION)
.find(withProductId(productId, account.admin === true ? {} : { _id: { $in: account.workspaces } }))
.sort({ lastVisit: -1 })
.toArray()
)
.filter((it) => it.disabled !== true || it.creating === true)
Expand All @@ -1272,6 +1273,7 @@ export async function getWorkspaceInfo (
if (email !== systemAccountEmail && !guest) {
account = await getAccount(db, email)
if (account === null) {
ctx.error('no account', { email, productId, token })
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
}
} else if (guest) {
Expand All @@ -1294,6 +1296,7 @@ export async function getWorkspaceInfo (
await db.collection<Workspace>(WORKSPACE_COLLECTION).find(withProductId(productId, query)).toArray()
).filter((it) => it.disabled !== true || account?.admin === true || it.creating === true)
if (ws == null) {
ctx.error('no workspace', { workspace: workspace.name, email })
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
}
if (_updateLastVisit && isAccount(account)) {
Expand Down