Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule Frequency as JSON #1598

Merged
merged 9 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions cypress/integration/schedules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ describe('Schedules View', () => {

cy.get('[data-testid="schedule-name"]').should('exist');
cy.get('[data-testid="schedule-name"]').contains(scheduleId);

cy.get('[data-testid="schedule-interval-frequency"]').contains(
'Every 30sec',
);
});
});

Expand All @@ -74,10 +70,6 @@ describe('Schedules Edit', () => {
cy.get('[data-testid="schedule-name"]').should('exist');
cy.get('[data-testid="schedule-name"]').contains(scheduleId);

cy.get('[data-testid="schedule-interval-frequency"]').contains(
'Every 30sec',
);

cy.get('#schedule-actions-menu-button').click();
cy.get('#schedule-actions-menu > [data-testid="edit-schedule"]').click();
cy.url().should('contain', `/schedules/${scheduleId}/edit`);
Expand Down
56 changes: 31 additions & 25 deletions src/lib/components/schedule/schedule-advanced-settings.svelte
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
<script lang="ts">
import Icon from '$lib/holocene/icon/icon.svelte';
import { translate } from '$lib/i18n/translate';


import ScheduleNotes from './schedule-notes.svelte';

import type { SchedulePolicies, ScheduleSpec, ScheduleState } from '$types';

export let spec: ScheduleSpec;
export let state: ScheduleState;
export let policies: SchedulePolicies;
export let notes = '';

let show = false;
</script>

<button on:click={() => (show = !show)} class="settings">
{translate('schedules', 'advanced-settings')}
<Icon class="inline" name={show ? 'chevron-up' : 'chevron-down'} />
</button>
{#if show}
<p>
{translate('schedules', 'start-time')}
{spec?.startTime ?? translate('none')}
</p>
<p>
{translate('schedules', 'end-time')}{spec?.endTime ?? translate('none')}
</p>
<p>{translate('schedules', 'jitter')}{spec?.jitter ?? translate('none')}</p>
<p>
{translate('schedules', 'exclusion-calendar')}{spec?.excludeCalendar?.[0] ??
translate('none')}
</p>
{#if state?.limitedActions}
<ScheduleNotes {notes} />
<div>
<button on:click={() => (show = !show)} class="settings">
{translate('schedules', 'advanced-settings')}
<Icon class="inline" name={show ? 'chevron-up' : 'chevron-down'} />
</button>
{#if show}
<p>
{translate('schedules', 'start-time')}
{spec?.startTime ?? translate('none')}
</p>
<p>
{translate('schedules', 'end-time')}{spec?.endTime ?? translate('none')}
</p>
<p>{translate('schedules', 'jitter')}{spec?.jitter ?? translate('none')}</p>
<p>
{translate('schedules', 'exclusion-calendar')}{spec
?.excludeCalendar?.[0] ?? translate('none')}
</p>
{#if state?.limitedActions}
<p>
{translate('schedules', 'remaining-actions')}{state?.remainingActions ??
translate('none')}
</p>
{/if}
<p>
{translate('schedules', 'remaining-actions')}{state?.remainingActions ??
{translate('schedules', 'overlap-policy')}{policies?.overlapPolicy ??
translate('none')}
</p>
{/if}
<p>
{translate('schedules', 'overlap-policy')}{policies?.overlapPolicy ??
translate('none')}
</p>
{/if}
</div>

<style lang="postcss">
.settings {
Expand Down
7 changes: 3 additions & 4 deletions src/lib/components/schedule/schedule-frequency-panel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
import Panel from '$lib/components/panel.svelte';
import { translate } from '$lib/i18n/translate';
import type { StructuredCalendar } from '$lib/types/schedule';

import ScheduleFrequency from './schedule-frequency.svelte';



import type { IntervalSpec } from '$types';

export let calendar: StructuredCalendar | undefined = undefined;
export let interval: IntervalSpec | undefined = undefined;
</script>

<Panel>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we want this Panel to come after Upcoming Runs (or above Recent Runs) instead of Advanced Settings on smaller screens

Screenshot 2023-08-30 at 11 43 58 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah makes sense

<h2 class="mb-4 text-2xl">{translate('schedules', 'frequency')}</h2>
<h2 class="mb-4 text-2xl">{translate('schedules', 'schedule-spec')}</h2>
<div class="pr-2">
<ScheduleFrequency {calendar} {interval} class="text-base" />
</div>
Expand Down
28 changes: 10 additions & 18 deletions src/lib/components/schedule/schedule-frequency.svelte
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
<script lang="ts">
import CodeBlock from '$lib/holocene/code-block.svelte';
import type { StructuredCalendar } from '$lib/types/schedule';
import { intervalToComment } from '$lib/utilities/schedule-comment-formatting';
import { commentOrCalendarToFrequency } from '$lib/utilities/schedule-frequency-formatting';


import type { IntervalSpec } from '$types';

export let calendar: StructuredCalendar | undefined = undefined;
export let interval: IntervalSpec | undefined = undefined;

const intervalSecs = interval?.interval as string;
const phaseSecs = interval?.phase as string;
export let inline = false;
</script>

<div class="flex flex-col {$$props.class}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding a max height here on xl screens?

Suggested change
<div class="flex flex-col {$$props.class}">
<div class="flex flex-col h-full xl:max-h-96 overflow-scroll {$$props.class}">
Screenshot 2023-08-30 at 12 03 15 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah I want to show the whole thing, and with this layout we get quite a bit of height on the right side so there's no reason to not take it up.

{#if calendar}
<p data-testid="schedule-calendar-frequency">
{commentOrCalendarToFrequency(calendar)}
</p>
{:else}
<p data-testid="schedule-interval-frequency">
{intervalToComment(intervalSecs)}
</p>
<p data-testid="schedule-phase-frequency">
{intervalToComment(phaseSecs, true)}
</p>
{/if}
<CodeBlock
copyable
{inline}
testId="schedule-calendar"
language="json"
content={JSON.stringify(calendar || interval, null, 2)}
/>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
export let notes = '';
</script>

<h2 class="mb-4 text-2xl">{translate('memo')}</h2>
<p>{notes}</p>
<div>
<h2 class="mb-4 text-2xl">{translate('notes')}</h2>
<p>{notes}</p>
</div>
6 changes: 3 additions & 3 deletions src/lib/components/schedule/schedule-recent-runs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { decodeURIForSvelte } from '$lib/utilities/encode-uri';
import { formatDate } from '$lib/utilities/format-date';
import { routeForEventHistory } from '$lib/utilities/route-for';

import WorkflowStatus from '../workflow-status.svelte';

import type { ScheduleActionResult } from '$types';

export let recentRuns: ScheduleActionResult[] = [];
Expand All @@ -29,7 +29,7 @@
};
</script>

<Panel>
<Panel class="w-full">
<h2 class="mb-4 text-2xl">{translate('schedules', 'recent-runs')}</h2>
{#each sortRecentRuns(recentRuns) as run (run?.startWorkflowResult?.workflowId)}
{#await fetchWorkflowForSchedule({ namespace, workflowId: decodeURIForSvelte(run.startWorkflowResult.workflowId), runId: run.startWorkflowResult.runId }, fetch) then workflow}
Expand Down
9 changes: 4 additions & 5 deletions src/lib/components/schedule/schedules-calendar-view.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import { page } from '$app/stores';

import Input from '$lib/holocene/input/input.svelte';
import TabList from '$lib/holocene/tab/tab-list.svelte';
import TabPanel from '$lib/holocene/tab/tab-panel.svelte';
import Tab from '$lib/holocene/tab/tab.svelte';
import Tabs from '$lib/holocene/tab/tabs.svelte';
import { translate } from '$lib/i18n/translate';
import type { FullSchedule, SchedulePreset } from '$lib/types/schedule';

import ScheduleDayOfMonthView from './schedule-day-of-month-view.svelte';
import ScheduleDayOfWeekView from './schedule-day-of-week-view.svelte';
import ScheduleFrequency from './schedule-frequency.svelte';
Expand Down Expand Up @@ -45,7 +45,7 @@
</script>

<Tabs class="mt-8 w-full">
<h2 class="mb-4 text-2xl">{translate('schedules', 'frequency')}</h2>
<h2 class="mb-4 text-2xl">{translate('schedules', 'schedule-spec')}</h2>
<TabList label="Schedule Tabs" class="flex flex-wrap gap-6">
{#if schedule}
<Tab
Expand Down Expand Up @@ -82,11 +82,10 @@
</TabList>
<div class="mt-4 flex w-full flex-wrap gap-6">
{#if schedule}
<TabPanel id="existing-panel" tabId="existing-tab">
<TabPanel id="existing-panel" tabId="existing-tab" class="w-full">
<ScheduleFrequency
calendar={schedule?.spec?.structuredCalendar?.[0]}
interval={schedule?.spec?.interval?.[0]}
class="text-base"
/>
</TabPanel>
{/if}
Expand Down
21 changes: 14 additions & 7 deletions src/lib/components/schedule/schedules-table-row.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';

import WorkflowStatus from '$lib/components/workflow-status.svelte';
import Link from '$lib/holocene/link.svelte';
import TableRow from '$lib/holocene/table/table-row.svelte';
Expand All @@ -15,10 +15,9 @@
routeForEventHistory,
routeForSchedule,
} from '$lib/utilities/route-for';

import ScheduleFrequency from './schedule-frequency.svelte';



import type { ScheduleActionResult, ScheduleListEntry } from '$types';

let { namespace } = $page.params;
Expand Down Expand Up @@ -53,9 +52,6 @@
</td>
<td class="cell whitespace-pre-line break-words">
<p class="text-base">{schedule.scheduleId}</p>
<p>
<ScheduleFrequency {calendar} {interval} class="text-sm" />
</p>
</td>
<td class="cell whitespace-pre-line break-words max-md:hidden">
{schedule?.info?.workflowType?.name ?? ''}
Expand Down Expand Up @@ -87,6 +83,17 @@
{/each}
</td>
</TableRow>
<TableRow>
Copy link
Contributor

@laurakwhit laurakwhit Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do users need to see the entire Schedule Spec in this view? Or would even something smaller like this be adequate? Accessibility wise, it's not great that this is it's own separate row with no relation to the last.

Screenshot 2023-08-30 at 11 58 01 AM

Or, at the very least, maybe we could add a !border-t-0 to remove the top border so the row is more visually connected?

Screenshot 2023-08-30 at 12 01 51 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really hard to read the spec when it's small, so we wanted to give it as much width as possible. I'll remove the top border though.

<td colspan="5" class="hidden xl:table-cell !p-0">
<ScheduleFrequency {calendar} {interval} inline class="text-sm w-auto" />
</td>
<td colspan="3" class="hidden md:table-cell xl:hidden !p-0">
<ScheduleFrequency {calendar} {interval} inline class="text-sm w-auto" />
</td>
<td colspan="2" class="md:hidden !p-0">
<ScheduleFrequency {calendar} {interval} inline class="text-sm w-auto" />
</td>
</TableRow>

<style lang="postcss">
.cell {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/schedule/schedules-table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { translate } from '$lib/i18n/translate';
</script>

<Table class="table-fixed">
<Table class="table-fixed w-full">
<caption class="sr-only" slot="caption">{translate('schedules')}</caption>
<TableHeaderRow slot="headers">
<th class="w-28">{translate('status')}</th>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/holocene/code-block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
async?: boolean;
testId?: string;
copyable?: boolean;
copyIconTitle: string;
copySuccessIconTitle: string;
copyIconTitle?: string;
copySuccessIconTitle?: string;
};

type CopyableProps = Omit<
Expand Down
4 changes: 2 additions & 2 deletions src/lib/holocene/menu/menu.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { fly } from 'svelte/transition';

import { getContext } from 'svelte';

import { MENU_CONTEXT, type MenuContext } from './menu-container.svelte';

interface $$Props extends HTMLAttributes<HTMLUListElement> {
Expand Down
1 change: 1 addition & 0 deletions src/lib/i18n/locales/en/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const Strings = {
edit: 'Edit',
delete: 'Delete',
memo: 'Memo',
notes: 'Notes',
add: 'Add',
'from-now': 'from now',
'hours-abbreviated': 'hrs.',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/i18n/locales/en/schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export const Strings = {
name: 'Schedule Name',
schedule: 'Schedule',
frequency: 'Frequency',
'schedule-spec': 'Schedule Spec',
'empty-state-title': 'No Schedules Found',
'empty-state-description': 'Try a different search',
'recent-runs': 'Recent Runs',
'recent-runs-empty-state-title': 'No Recent Runs',
'upcoming-runs': 'Upcoming Runs',
loading: 'Loading Schedule...',
deleting: 'Deleting Schedule...',
delete: 'Delete Schedule',
'delete-schedule-error': 'Cannot delete schedule. {{error}}',
pause: 'Pause',
unpause: 'Unpause',
Expand Down
35 changes: 14 additions & 21 deletions src/lib/pages/schedule-view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import ScheduleAdvancedSettings from '$lib/components/schedule/schedule-advanced-settings.svelte';
import ScheduleError from '$lib/components/schedule/schedule-error.svelte';
import ScheduleFrequencyPanel from '$lib/components/schedule/schedule-frequency-panel.svelte';
import ScheduleMemo from '$lib/components/schedule/schedule-memo.svelte';
import ScheduleRecentRuns from '$lib/components/schedule/schedule-recent-runs.svelte';
import ScheduleUpcomingRuns from '$lib/components/schedule/schedule-upcoming-runs.svelte';
import WorkflowStatus from '$lib/components/workflow-status.svelte';
Expand Down Expand Up @@ -192,7 +191,7 @@
destructive
on:click={() => (deleteConfirmationModalOpen = true)}
>
{translate('schedules', 'delete')}
{translate('delete')}
</MenuItem>
</SplitButton>
</header>
Expand All @@ -202,34 +201,28 @@
<ScheduleError error={schedule?.info?.invalidScheduleError} />
</div>
{/if}
<div class="w-full xl:w-1/2">
<ScheduleFrequencyPanel
calendar={schedule?.schedule?.spec?.structuredCalendar?.[0]}
interval={schedule?.schedule?.spec?.interval?.[0]}
/>
</div>
<div class="flex flex-col xl:flex-row gap-4">
<div class="w-full xl:w-3/4">
<div class="w-full flex flex-col items-start gap-4 xl:w-2/3">
<ScheduleRecentRuns
{namespace}
recentRuns={schedule?.info?.recentActions}
/>
</div>
<div class="w-full xl:w-1/4 xl:min-w-[320px]">
<ScheduleUpcomingRuns
futureRuns={schedule?.info?.futureActionTimes}
/>
<ScheduleAdvancedSettings
spec={schedule?.schedule?.spec}
state={schedule?.schedule?.state}
policies={schedule?.schedule?.policies}
notes={schedule?.schedule?.state?.notes}
/>
</div>
<div class="w-full xl:w-1/3">
<ScheduleFrequencyPanel
calendar={schedule?.schedule?.spec?.structuredCalendar?.[0]}
interval={schedule?.schedule?.spec?.interval?.[0]}
/>
</div>
</div>
<div class="w-full xl:w-1/2">
<ScheduleAdvancedSettings
spec={schedule?.schedule?.spec}
state={schedule?.schedule?.state}
policies={schedule?.schedule?.policies}
/>
</div>
<div class="w-full xl:w-1/2">
<ScheduleMemo notes={schedule?.schedule?.state?.notes} />
</div>
</div>
<Modal
Expand Down