From dc2bbca2695acd93c7147047adedfb0c31b9c31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= <43071496+adam-kov@users.noreply.github.com> Date: Mon, 26 Sep 2022 17:18:17 +0200 Subject: [PATCH] feat(frontend): Script page action row (#626) * feat(frontend): Update button component styles * feat(frontend): Use button component * fix(frontend): Re-export button types * feat(frontend): Use action row in script page * fix(frontend): Center the action row * fix(frontend): Revert to previous event forwarding * feature(frontend): Add action row to flow page * fix(frontend): Restore button red color --- .../common/actionRow/ActionRow.svelte | 27 +++ .../components/common/button/Button.svelte | 109 +++++---- .../src/lib/components/common/button/model.ts | 6 + frontend/src/lib/components/common/index.ts | 15 ++ .../src/routes/flows/get/[...path].svelte | 192 ++++++++------- .../src/routes/scripts/get/[...hash].svelte | 229 +++++++++--------- 6 files changed, 328 insertions(+), 250 deletions(-) create mode 100644 frontend/src/lib/components/common/actionRow/ActionRow.svelte create mode 100644 frontend/src/lib/components/common/button/model.ts create mode 100644 frontend/src/lib/components/common/index.ts diff --git a/frontend/src/lib/components/common/actionRow/ActionRow.svelte b/frontend/src/lib/components/common/actionRow/ActionRow.svelte new file mode 100644 index 0000000000..3203443ee0 --- /dev/null +++ b/frontend/src/lib/components/common/actionRow/ActionRow.svelte @@ -0,0 +1,27 @@ + + +
+
+ {#if $$slots.left} +
+ +
+ {/if} + {#if $$slots.middle} +
+ +
+ {/if} + {#if $$slots.right} +
+ +
+ {/if} +
+
diff --git a/frontend/src/lib/components/common/button/Button.svelte b/frontend/src/lib/components/common/button/Button.svelte index e2a0b108c9..c44de641ae 100644 --- a/frontend/src/lib/components/common/button/Button.svelte +++ b/frontend/src/lib/components/common/button/Button.svelte @@ -1,81 +1,108 @@ {#if href} - + {#if startIcon} - + {/if} {#if endIcon} - + {/if} {:else} {/if} diff --git a/frontend/src/lib/components/common/button/model.ts b/frontend/src/lib/components/common/button/model.ts new file mode 100644 index 0000000000..1f3a4e808f --- /dev/null +++ b/frontend/src/lib/components/common/button/model.ts @@ -0,0 +1,6 @@ +export namespace Button { + export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl' + export type Color = 'blue' | 'red' | 'dark' | 'light' + export type Variant = 'contained' | 'border' + export type Target = '_self' | '_blank' +} diff --git a/frontend/src/lib/components/common/index.ts b/frontend/src/lib/components/common/index.ts new file mode 100644 index 0000000000..5751954c59 --- /dev/null +++ b/frontend/src/lib/components/common/index.ts @@ -0,0 +1,15 @@ +export { default as ActionRow } from './actionRow/ActionRow.svelte' +export { default as Badge } from './badge/Badge.svelte' +export { default as Button } from './button/Button.svelte' +export { default as Drawer } from './drawer/Drawer.svelte' +export { default as DrawerContent } from './drawer/DrawerContent.svelte' +export { default as Menu } from './menu/Menu.svelte' +export { default as MenuItem } from './menu/MenuItem.svelte' +export { default as Tab } from './tabs/Tab.svelte' +export { default as TabContent } from './tabs/TabContent.svelte' +export { default as Tabs } from './tabs/Tabs.svelte' +export { default as ToggleButton } from './toggleButton/ToggleButton.svelte' +export { default as ToggleButtonGroup } from './toggleButton/ToggleButtonGroup.svelte' + +export * from './badge/model' +export * from './button/model' diff --git a/frontend/src/routes/flows/get/[...path].svelte b/frontend/src/routes/flows/get/[...path].svelte index 70376386d2..2a5326fb44 100644 --- a/frontend/src/routes/flows/get/[...path].svelte +++ b/frontend/src/routes/flows/get/[...path].svelte @@ -38,6 +38,7 @@ import CenteredPage from '$lib/components/CenteredPage.svelte' import FlowViewer from '$lib/components/FlowViewer.svelte' import ObjectViewer from '$lib/components/propertyPicker/ObjectViewer.svelte' + import { Button, ActionRow } from '$lib/components/common' let flow: Flow | undefined let schedule: Schedule | undefined @@ -45,6 +46,7 @@ let path = $page.params.path let shareModal: ShareModal + let scrollY: number $: { if ($workspaceStore && $userStore) { @@ -88,105 +90,101 @@ } + + +{#if flow} + = 30 ? 'border-b' : '')}> + + + + + + + + + { + shareModal.openModal() + }, + disabled: !can_write + }, + { + displayName: 'Schedule', + icon: faCalendar, + href: `/schedule/add?path=${flow.path}&isFlow=true` + }, + { + displayName: 'Archive', + icon: faArchive, + type: 'delete', + action: () => { + flow?.path && archiveFlow() + }, + disabled: flow.archived || !can_write + } + ]} + /> + + +{/if} + -
-

- {flow?.path ?? 'Loading...'} +

+ {flow?.path ?? 'Loading...'} - -

- - {#if flow} -
- { - shareModal.openModal() - }, - disabled: !can_write - }, - { - displayName: 'Schedule', - icon: faCalendar, - href: `/schedule/add?path=${flow.path}&isFlow=true` - }, - { - displayName: 'Archive', - icon: faArchive, - type: 'delete', - action: () => { - flow?.path && archiveFlow() - }, - disabled: flow.archived || !can_write - } - ]} - /> - - - - -
- {/if} -
+ + diff --git a/frontend/src/routes/scripts/get/[...hash].svelte b/frontend/src/routes/scripts/get/[...hash].svelte index aaeb69343a..a7628c6acf 100644 --- a/frontend/src/routes/scripts/get/[...hash].svelte +++ b/frontend/src/routes/scripts/get/[...hash].svelte @@ -18,7 +18,6 @@ scriptToHubUrl, copyToClipboard } from '$lib/utils' - import Icon from 'svelte-awesome' import { faPlay, faEdit, @@ -43,16 +42,14 @@ import CenteredPage from '$lib/components/CenteredPage.svelte' import { onDestroy } from 'svelte' import HighlightCode from '$lib/components/HighlightCode.svelte' - import Badge from '$lib/components/common/badge/Badge.svelte' - import Tabs from '$lib/components/common/tabs/Tabs.svelte' - import Tab from '$lib/components/common/tabs/Tab.svelte' - import TabContent from '$lib/components/common/tabs/TabContent.svelte' + import { Badge, Tabs, Tab, TabContent, Button, ActionRow } from '$lib/components/common' let script: Script | undefined let topHash: string | undefined let can_write = false let deploymentInProgress = false let intervalId: NodeJS.Timer + let scrollY: number let shareModal: ShareModal @@ -131,6 +128,111 @@ }) + + +{#if script} + = 30 ? 'border-b' : '')}> + + + + {#if !topHash} + + {/if} + + + + + { + shareModal.openModal() + }, + disabled: !can_write + }, + { + displayName: 'Schedule', + icon: faCalendar, + href: `/schedule/add?path=${script.path}` + }, + { + displayName: 'Archive', + icon: faArchive, + type: 'delete', + action: () => { + script?.hash && archiveScript(script.hash) + }, + disabled: script.archived || !can_write + }, + { + displayName: 'Delete', + icon: faTrash, + type: 'delete', + action: () => { + script?.hash && deleteScript(script.hash) + }, + disabled: script.deleted || !($userStore?.is_admin ?? false) + } + ]} + /> + + +{/if} +
@@ -169,115 +271,16 @@

- - {#if script} -
- -
- - Run -
-
- -
- - Edit -
-
- {#if !topHash} - -
- - Use as template/Fork -
-
- {/if} - -
- - View runs -
-
- -
- - Publish to Hub -
-
- { - shareModal.openModal() - }, - disabled: !can_write - }, - { - displayName: 'Schedule', - icon: faCalendar, - href: `/schedule/add?path=${script.path}` - }, - { - displayName: 'Archive', - icon: faArchive, - type: 'delete', - action: () => { - script?.hash && archiveScript(script.hash) - }, - disabled: script.archived || !can_write - }, - { - displayName: 'Delete', - icon: faTrash, - type: 'delete', - action: () => { - script?.hash && deleteScript(script.hash) - }, - disabled: script.deleted || !($userStore?.is_admin ?? false) - } - ]} - /> -
- {/if}
-
+
{#if script === undefined}

loading

{:else}
-

{script.summary}

+

{script.summary}

@@ -343,13 +346,15 @@ {type} - + Copy +
{/each}