diff --git a/src/lib/components/schedule/schedules-count.svelte b/src/lib/components/schedule/schedules-count.svelte new file mode 100644 index 000000000..2f70cc4e2 --- /dev/null +++ b/src/lib/components/schedule/schedules-count.svelte @@ -0,0 +1,25 @@ + + +
+ {translate('common.schedules-plural', { count: Number($schedulesCount) })} +
diff --git a/src/lib/i18n/locales/en/common.ts b/src/lib/i18n/locales/en/common.ts index 7e00d49b6..be8555697 100644 --- a/src/lib/i18n/locales/en/common.ts +++ b/src/lib/i18n/locales/en/common.ts @@ -96,6 +96,8 @@ export const Strings = { 'workflows-plural_one': 'Workflow', 'workflows-plural_other': 'Workflows', schedules: 'Schedules', + 'schedules-plural_one': '{{ count }} Schedule', + 'schedules-plural_other': '{{ count }} Schedules', archive: 'Archive', import: 'Import', feedback: 'Feedback', diff --git a/src/lib/pages/schedules.svelte b/src/lib/pages/schedules.svelte index 0e296fe72..7f51dc834 100644 --- a/src/lib/pages/schedules.svelte +++ b/src/lib/pages/schedules.svelte @@ -4,6 +4,7 @@ import { goto } from '$app/navigation'; import { page } from '$app/stores'; + import SchedulesCount from '$lib/components/schedule/schedules-count.svelte'; import SchedulesTableRow from '$lib/components/schedule/schedules-table-row.svelte'; import SchedulesTable from '$lib/components/schedule/schedules-table.svelte'; import ApiPagination from '$lib/holocene/api-pagination.svelte'; @@ -15,6 +16,7 @@ import { translate } from '$lib/i18n/translate'; import { fetchPaginatedSchedules } from '$lib/services/schedule-service'; import { coreUserStore } from '$lib/stores/core-user'; + import { schedulesCount } from '$lib/stores/schedules'; import type { ScheduleListEntry } from '$lib/types'; import type { ErrorCallback } from '$lib/utilities/request-from-api'; import { routeForScheduleCreate } from '$lib/utilities/route-for'; @@ -49,6 +51,7 @@ let:visibleItems {onFetch} {onError} + total={$schedulesCount} aria-label={translate('common.schedules')} pageSizeSelectLabel={translate('common.per-page')} nextButtonLabel={translate('common.next')} @@ -65,7 +68,7 @@

- {translate('common.schedules')} +

{#if !createDisabled && visibleItems.length} @@ -101,6 +104,7 @@ {:else} + => { + const query = + 'TemporalNamespaceDivision="TemporalScheduler" AND ExecutionStatus="Running"'; + const countRoute = routeForApi('workflows.count', { + namespace, + }); + const { count } = await requestFromAPI( + countRoute, + { + params: { + query, + }, + notifyOnError: false, + }, + ); + return count ?? '0'; +}; diff --git a/src/lib/stores/schedules.ts b/src/lib/stores/schedules.ts index 6bb53eca8..2c13fcc81 100644 --- a/src/lib/stores/schedules.ts +++ b/src/lib/stores/schedules.ts @@ -200,3 +200,4 @@ export const submitEditSchedule = async ( export const loading = writable(false); export const error = writable(''); +export const schedulesCount = writable('0'); diff --git a/tests/integration/disable-write-actions.spec.ts b/tests/integration/disable-write-actions.spec.ts index 7ecffb038..4799d285b 100644 --- a/tests/integration/disable-write-actions.spec.ts +++ b/tests/integration/disable-write-actions.spec.ts @@ -47,7 +47,7 @@ test.describe('Disable write actions on empty schedules list actions', () => { await page.goto(schedulesUrl); const namespace = await page.locator('h1').innerText(); - expect(namespace).toBe('Schedules'); + expect(namespace).toBe('0 Schedules'); const createButton = page.getByTestId('create-schedule'); await expect(createButton).toBeDisabled(); diff --git a/tests/integration/schedules-list.spec.ts b/tests/integration/schedules-list.spec.ts index cb533c8d5..3255878b1 100644 --- a/tests/integration/schedules-list.spec.ts +++ b/tests/integration/schedules-list.spec.ts @@ -15,7 +15,7 @@ test.describe('Schedules List with no schedules', () => { await page.goto(schedulesUrl); const namespace = await page.locator('h1').innerText(); - expect(namespace).toBe('Schedules'); + expect(namespace).toBe('0 Schedules'); const createButton = page.getByTestId('create-schedule'); await expect(createButton).toBeEnabled(); @@ -33,7 +33,7 @@ test.describe('Schedules List with schedules', () => { await page.goto(schedulesUrl); const namespace = await page.locator('h1').innerText(); - expect(namespace).toBe('Schedules'); + expect(namespace).toBe('0 Schedules'); const createButton = page.getByTestId('create-schedule'); await expect(createButton).toBeEnabled();