Skip to content

Commit

Permalink
Improve loading state (#209)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Kempf Le Stanc <[email protected]>
  • Loading branch information
ThibaudDauce and nicolaskempf57 authored Dec 16, 2024
1 parent 6daf0db commit e126734
Show file tree
Hide file tree
Showing 17 changed files with 452 additions and 415 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AdminTable :loading>
<AdminTable>
<thead>
<AdminTableTh
:sorted="sorted('title')"
Expand Down Expand Up @@ -77,11 +77,10 @@ import AdminBadge from '../../../components/AdminBadge/AdminBadge.vue'
import AdminTable from '../../../components/AdminTable/Table/AdminTable.vue'
import AdminTableTh from '../../../components/AdminTable/Table/AdminTableTh.vue'
import AdminContentWithTooltip from '../../../components/AdminContentWithTooltip/AdminContentWithTooltip.vue'
import type { AdminBadgeState, AdminBadgeType, CommunityResourceSortedBy, SortDirection } from '~/types/types'
import type { AdminBadgeType, CommunityResourceSortedBy, SortDirection } from '~/types/types'
const props = defineProps<{
communityResources: Array<CommunityResource>
loading: boolean
sortedBy: CommunityResourceSortedBy
sortDirection: SortDirection
}>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AdminTable :loading>
<AdminTable>
<thead>
<tr>
<AdminTableTh
Expand Down Expand Up @@ -46,12 +46,18 @@
</AdminContentWithTooltip>
</td>
<td>
<AdminBadge size="xs" :type="getStatus(dataservice).type">
<AdminBadge
size="xs"
:type="getStatus(dataservice).type"
>
{{ getStatus(dataservice).label }}
</AdminBadge>
</td>
<td>
<AdminBadge size="xs" :type="getAccess(dataservice).type">
<AdminBadge
size="xs"
:type="getAccess(dataservice).type"
>
{{ getAccess(dataservice).label }}
</AdminBadge>
</td>
Expand All @@ -71,11 +77,10 @@ import AdminBadge from '../../../components/AdminBadge/AdminBadge.vue'
import AdminTable from '../../../components/AdminTable/Table/AdminTable.vue'
import AdminTableTh from '../../../components/AdminTable/Table/AdminTableTh.vue'
import AdminContentWithTooltip from '../../../components/AdminContentWithTooltip/AdminContentWithTooltip.vue'
import type { AdminBadgeState, AdminBadgeType, DataserviceSortedBy, SortDirection } from '~/types/types'
import type { AdminBadgeType, DataserviceSortedBy, SortDirection } from '~/types/types'
const props = defineProps<{
dataservices: Array<Dataservice>
loading: boolean
sortedBy: DataserviceSortedBy
sortDirection: SortDirection
}>()
Expand Down
10 changes: 6 additions & 4 deletions components/AdminTable/AdminDatasetsTable/AdminDatasetsTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AdminTable :loading>
<AdminTable>
<thead>
<tr>
<AdminTableTh
Expand Down Expand Up @@ -121,7 +121,10 @@
</AdminContentWithTooltip>
</td>
<td>
<AdminBadge size="xs" :type="getStatus(dataset).type">
<AdminBadge
size="xs"
:type="getStatus(dataset).type"
>
{{ getStatus(dataset).label }}
</AdminBadge>
</td>
Expand Down Expand Up @@ -175,15 +178,14 @@ import AdminContentWithTooltip from '../../AdminContentWithTooltip/AdminContentW
import AdminTable from '../Table/AdminTable.vue'
import AdminTableTh from '../Table/AdminTableTh.vue'
import Tooltip from '../../Tooltip/Tooltip.vue'
import type { AdminBadgeState, AdminBadgeType, DatasetSortedBy, SortDirection } from '~/types/types'
import type { AdminBadgeType, DatasetSortedBy, SortDirection } from '~/types/types'
const emit = defineEmits<{
(event: 'sort', column: DatasetSortedBy, direction: SortDirection): void
}>()
const props = defineProps<{
datasets: Array<Dataset | DatasetV2>
loading: boolean
sortDirection?: SortDirection
sortedBy?: DatasetSortedBy
}>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AdminTable :loading>
<AdminTable>
<thead>
<tr>
<AdminTableTh
Expand Down Expand Up @@ -108,7 +108,6 @@ import { getDiscussionUrl, getSubject, getSubjectTypeIcon, getSubjectTitle } fro
const props = defineProps<{
discussions: Array<Thread>
loading: boolean
sortDirection: SortDirection
sortedBy: DiscussionSortedBy
}>()
Expand Down
11 changes: 6 additions & 5 deletions components/AdminTable/AdminReusesTable/AdminReusesTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AdminTable :loading>
<AdminTable>
<thead>
<tr>
<AdminTableTh
Expand Down Expand Up @@ -89,7 +89,10 @@
</AdminContentWithTooltip>
</td>
<td>
<AdminBadge size="xs" :type="getStatus(reuse).type">
<AdminBadge
size="xs"
:type="getStatus(reuse).type"
>
{{ getStatus(reuse).label }}
</AdminBadge>
</td>
Expand Down Expand Up @@ -120,11 +123,10 @@ import AdminTable from '../../../components/AdminTable/Table/AdminTable.vue'
import AdminTableTh from '../../../components/AdminTable/Table/AdminTableTh.vue'
import AdminContentWithTooltip from '../../../components/AdminContentWithTooltip/AdminContentWithTooltip.vue'
import Tooltip from '../../../components/Tooltip/Tooltip.vue'
import type { AdminBadgeState, AdminBadgeType, ReuseSortedBy, SortDirection } from '~/types/types'
import type { AdminBadgeType, ReuseSortedBy, SortDirection } from '~/types/types'
const props = defineProps<{
reuses: Array<Reuse>
loading: boolean
sortedBy: ReuseSortedBy
sortDirection: SortDirection
}>()
Expand All @@ -133,7 +135,6 @@ defineEmits<{
(event: 'sort', column: ReuseSortedBy, direction: SortDirection): void
}>()
const config = useRuntimeConfig()
const { t } = useI18n()
function sorted(column: ReuseSortedBy) {
Expand Down
43 changes: 23 additions & 20 deletions components/CommunityResources/AdminCommunityResourcesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--middle">
<div class="fr-col">
<h2
v-if="status === 'success' && pageData.total"
v-if="pageData && pageData.total"
class="subtitle subtitle--uppercase fr-m-0"
>
{{ t('{n} community resources', pageData.total) }}
Expand All @@ -42,33 +42,36 @@
<!-- Buttons -->
</div>
</div>
<AdminCommunityResourcesTable
v-if="status === 'pending' || (status === 'success' && pageData.total > 0)"
:community-resources="pageData ? pageData.data : []"
:loading="status === 'pending'"
:sort-direction="direction"
:sorted-by
@sort="sort"
/>

<LoadingBlock :status>
<div v-if="pageData && pageData.total > 0">
<AdminCommunityResourcesTable
:community-resources="pageData ? pageData.data : []"
:sort-direction="direction"
:sorted-by
@sort="sort"
/>
<Pagination
:page="page"
:page-size="pageSize"
:total-results="pageData.total"
@change="(changedPage: number) => page = changedPage"
/>
</div>
</LoadingBlock>

<div
v-else
v-if="pageData && !pageData.total"
class="flex flex-col items-center"
>
<!-- <nuxt-img
src="/illustrations/dataset.svg"
<nuxt-img
src="/illustrations/schema.svg"
class="h-20"
/> -->
/>
<p class="fr-text--bold fr-my-3v">
{{ t(`You haven't published a community resource yet`) }}
</p>
</div>
<Pagination
v-if="status === 'success' && pageData.total > pageSize"
:page="page"
:page-size="pageSize"
:total-results="pageData.total"
@change="(changedPage: number) => page = changedPage"
/>
</div>
</template>

Expand Down
37 changes: 20 additions & 17 deletions components/Dataservices/AdminDataservicesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--middle">
<div class="fr-col">
<h2
v-if="status === 'success' && pageData.total"
v-if="pageData && pageData.total"
class="subtitle subtitle--uppercase fr-m-0"
>
{{ t('{n} dataservices', pageData.total) }}
Expand All @@ -46,16 +46,26 @@
/>
</div>
</div>
<AdminDataservicesTable
v-if="status === 'pending' || (status === 'success' && pageData.total > 0)"
:dataservices="pageData ? pageData.data : []"
:loading="status === 'pending'"
:sort-direction="direction"
:sorted-by
@sort="sort"
/>

<LoadingBlock :status>
<div v-if="pageData && pageData.total > 0">
<AdminDataservicesTable
:dataservices="pageData ? pageData.data : []"
:sort-direction="direction"
:sorted-by
@sort="sort"
/>
<Pagination
:page="page"
:page-size="pageSize"
:total-results="pageData.total"
@change="(changedPage: number) => page = changedPage"
/>
</div>
</LoadingBlock>

<div
v-else
v-if="pageData && !pageData.total"
class="flex flex-col items-center"
>
<nuxt-img
Expand All @@ -67,13 +77,6 @@
</p>
<AdminPublishButton type="dataservice" />
</div>
<Pagination
v-if="status === 'success' && pageData.total > pageSize"
:page="page"
:page-size="pageSize"
:total-results="pageData.total"
@change="(changedPage: number) => page = changedPage"
/>
</div>
</template>

Expand Down
Loading

0 comments on commit e126734

Please sign in to comment.