Skip to content

Commit

Permalink
UBERF-6728 Show spinner while teamspace not loaded (#5472)
Browse files Browse the repository at this point in the history
  • Loading branch information
aonnikov committed Apr 26, 2024
1 parent a55c4cd commit 8af5279
Showing 1 changed file with 46 additions and 32 deletions.
78 changes: 46 additions & 32 deletions plugins/document-resources/src/components/NewDocumentHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
<script lang="ts">
import { Ref, Space } from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import { Button, showPopup, IconAdd, ButtonWithDropdown, SelectPopupValueType, IconDropdown } from '@hcengineering/ui'
import {
Button,
ButtonWithDropdown,
IconAdd,
IconDropdown,
Loading,
SelectPopupValueType,
showPopup
} from '@hcengineering/ui'
import { openDoc } from '@hcengineering/view-resources'
import document from '../plugin'
import { getDocumentIdFromFragment } from '../utils'
Expand All @@ -28,12 +36,14 @@
const client = getClient()
const query = createQuery()
let loading = true
let hasTeamspace = false
query.query(
document.class.Teamspace,
{ archived: false },
(res) => {
hasTeamspace = res.length > 0
loading = false
},
{ limit: 1, projection: { _id: 1 } }
)
Expand Down Expand Up @@ -64,34 +74,38 @@
}
</script>

<div class="antiNav-subheader">
{#if hasTeamspace}
<ButtonWithDropdown
icon={IconAdd}
justify={'left'}
kind={'primary'}
label={document.string.CreateDocument}
on:click={newDocument}
mainButtonId={'new-document'}
dropdownIcon={IconDropdown}
dropdownItems={[
{ id: document.string.CreateDocument, label: document.string.CreateDocument },
{ id: document.string.CreateTeamspace, label: document.string.CreateTeamspace }
]}
on:dropdown-selected={(ev) => {
void dropdownItemSelected(ev.detail)
}}
/>
{:else}
<Button
id={'new-teamspace'}
icon={IconAdd}
label={document.string.CreateTeamspace}
justify={'left'}
width={'100%'}
kind={'primary'}
gap={'large'}
on:click={newTeamspace}
/>
{/if}
</div>
{#if loading}
<Loading shrink />
{:else}
<div class="antiNav-subheader">
{#if hasTeamspace}
<ButtonWithDropdown
icon={IconAdd}
justify={'left'}
kind={'primary'}
label={document.string.CreateDocument}
on:click={newDocument}
mainButtonId={'new-document'}
dropdownIcon={IconDropdown}
dropdownItems={[
{ id: document.string.CreateDocument, label: document.string.CreateDocument },
{ id: document.string.CreateTeamspace, label: document.string.CreateTeamspace }
]}
on:dropdown-selected={(ev) => {
void dropdownItemSelected(ev.detail)
}}
/>
{:else}
<Button
id={'new-teamspace'}
icon={IconAdd}
label={document.string.CreateTeamspace}
justify={'left'}
width={'100%'}
kind={'primary'}
gap={'large'}
on:click={newTeamspace}
/>
{/if}
</div>
{/if}

0 comments on commit 8af5279

Please sign in to comment.