Skip to content

Commit

Permalink
UBERF-5870: Fix cache control and some minor enhancements (hcengineer…
Browse files Browse the repository at this point in the history
…ing#4869)

UBERF-5870: Fix cache control and some minor enhancements

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
Signed-off-by: Tiago Cruz <tcruz@netic.io>
  • Loading branch information
haiodo authored and tjaoc committed Mar 5, 2024
1 parent 66b52fa commit c29dd03
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 115 deletions.
99 changes: 29 additions & 70 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion packages/presentation/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,12 @@ export function isCollectionAttr (hierarchy: Hierarchy, key: KeyedAttribute): bo
* @public
*/
export function decodeTokenPayload (token: string): any {
return JSON.parse(atob(token.split('.')[1]))
try {
return JSON.parse(atob(token.split('.')[1]))
} catch (err: any) {
console.error(err)
return {}
}
}

export function isAdminUser (): boolean {
Expand Down
34 changes: 30 additions & 4 deletions plugins/login-resources/src/components/SelectWorkspace.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
<script lang="ts">
import { LoginInfo, Workspace } from '@hcengineering/login'
import { OK, Severity, Status } from '@hcengineering/platform'
import presentation, { NavLink } from '@hcengineering/presentation'
import { Button, Label, Scroller, deviceOptionsStore as deviceInfo, setMetadataLocalStorage } from '@hcengineering/ui'
import presentation, { NavLink, isAdminUser } from '@hcengineering/presentation'
import {
Button,
Label,
Scroller,
SearchEdit,
deviceOptionsStore as deviceInfo,
setMetadataLocalStorage
} from '@hcengineering/ui'
import { onMount } from 'svelte'
import login from '../plugin'
import { getAccount, getHref, getWorkspaces, goTo, navigateToWorkspace, selectWorkspace } from '../utils'
Expand Down Expand Up @@ -84,6 +91,9 @@
throw err
}
}
$: isAdmin = isAdminUser()
let search: string = ''
</script>

<form class="container" style:padding={$deviceInfo.docWidth <= 480 ? '1.25rem' : '5rem'}>
Expand All @@ -95,16 +105,32 @@
<div class="status">
<StatusControl {status} />
</div>
{#if isAdmin}
<div class="ml-2 mr-2 mb-2 flex-grow">
<SearchEdit bind:value={search} width={'100%'} />
</div>
{/if}
{#await _getWorkspaces() then}
<Scroller padding={'.125rem 0'}>
<div class="form">
{#each workspaces as workspace}
{#each workspaces.filter((it) => search === '' || (it.workspaceName?.includes(search) ?? false) || it.workspace.includes(search)) as workspace}
{@const wsName = workspace.workspaceName ?? workspace.workspace}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="workspace flex-center fs-title cursor-pointer focused-button bordered form-row"
on:click={() => select(workspace.workspace)}
>
{workspace.workspaceName ?? workspace.workspace}
<div class="flex flex-col flex-grow">
<span class="label overflow-label flex-center">
{wsName}
</span>
{#if isAdmin && wsName !== workspace.workspace}
<span class="text-xs flex-center">
{workspace.workspace}
</span>
{/if}
</div>
</div>
{/each}
{#if workspaces.length === 0 && account?.confirmed === true}
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 @@ -203,7 +203,8 @@ export async function getWorkspaces (): Promise<Workspace[]> {
if (endpoint !== undefined) {
return [
{
workspace: DEV_WORKSPACE
workspace: DEV_WORKSPACE,
workspaceId: DEV_WORKSPACE
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/login/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export const loginId = 'login' as Plugin
* @public
*/
export interface Workspace {
workspace: string //
workspace: string // workspace Url
workspaceName?: string // A company name
workspaceId: string // A unique identifier for the workspace
}

/**
Expand Down
Loading

0 comments on commit c29dd03

Please sign in to comment.