-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathWorkbenchApp.svelte
More file actions
109 lines (104 loc) · 3.6 KB
/
WorkbenchApp.svelte
File metadata and controls
109 lines (104 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!--
// Copyright © 2020 Anticrm Platform Contributors.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { getMetadata } from '@hcengineering/platform'
import { upgradeDownloadProgress } from '@hcengineering/presentation'
import { Button, Component, AppLoading, Label, Notifications, location } from '@hcengineering/ui'
import { connect, disconnect, error, errorActions } from '../connect'
import workbench, { workbenchId } from '@hcengineering/workbench'
import { onDestroy } from 'svelte'
import workbenchRes from '../plugin'
import { workspaceCreating } from '../utils'
const isNeedUpgrade = window.location.host === ''
onDestroy(disconnect)
</script>
{#if $location.path[0] === workbenchId || $location.path[0] === workbenchRes.component.WorkbenchApp}
{#key $location.path[1]}
{#await connect(getMetadata(workbenchRes.metadata.PlatformTitle) ?? 'Platform')}
<AppLoading>
{#if ($workspaceCreating ?? -1) >= 0}
<div class="ml-1">
<Label label={workbenchRes.string.WorkspaceCreating} />
{$workspaceCreating} %
</div>
{/if}
{#if $error}
<div class="ml-2">
{$error}
</div>
{/if}
{#if $upgradeDownloadProgress >= 0}
<div class="ml-1" class:ml-2={$error === undefined}>
<Label label={workbench.string.UpgradeDownloadProgress} params={{ percent: $upgradeDownloadProgress }} />
</div>
{/if}
<svelte:fragment slot="actions">
{#if $error && $errorActions.length > 0}
{#each $errorActions as action}
<Button label={action.label} on:click={action.action} />
{/each}
{/if}
</svelte:fragment>
</AppLoading>
{:then client}
{#if $error}
<div class="version-wrapper">
<div class="antiPopup version-popup">
{#if isNeedUpgrade}
<h1><Label label={workbenchRes.string.NewVersionAvailable} /></h1>
<span class="please-update"><Label label={workbenchRes.string.PleaseUpdate} /></span>
{:else}
<h1><Label label={workbenchRes.string.ServerUnderMaintenance} /></h1>
{/if}
{$error}
{#if $upgradeDownloadProgress >= 0}
<div class="mt-1">
<Label
label={workbench.string.UpgradeDownloadProgress}
params={{ percent: $upgradeDownloadProgress }}
/>
</div>
{/if}
</div>
</div>
{:else if client}
<Notifications>
<Component is={workbenchRes.component.Workbench} />
</Notifications>
{/if}
{:catch error}
<div>{error} -- {error.stack}</div>
{/await}
{/key}
{/if}
<style lang="scss">
.version-wrapper {
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.please-update {
margin-bottom: 1rem;
}
.version-popup {
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
flex-grow: 1;
}
</style>