From fa2ae6d8fc1524fa4088be1daa60636f3a108fe4 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Mon, 28 Nov 2022 10:19:49 +0100 Subject: [PATCH] feat(frontend): rework script detail (#952) Co-authored-by: Ruben Fiszel --- .../src/routes/scripts/get/[...hash].svelte | 553 +++++++++--------- 1 file changed, 283 insertions(+), 270 deletions(-) diff --git a/frontend/src/routes/scripts/get/[...hash].svelte b/frontend/src/routes/scripts/get/[...hash].svelte index 7d825f8c98..bf35bcc467 100644 --- a/frontend/src/routes/scripts/get/[...hash].svelte +++ b/frontend/src/routes/scripts/get/[...hash].svelte @@ -30,7 +30,8 @@ faSpinner, faGlobe, faCodeFork, - faClipboard + faClipboard, + faArrowLeft } from '@fortawesome/free-solid-svg-icons' import Tooltip from '$lib/components/Tooltip.svelte' import ShareModal from '$lib/components/ShareModal.svelte' @@ -42,7 +43,17 @@ import CenteredPage from '$lib/components/CenteredPage.svelte' import { onDestroy } from 'svelte' import HighlightCode from '$lib/components/HighlightCode.svelte' - import { Badge, Tabs, Tab, TabContent, Button, ActionRow, Alert } from '$lib/components/common' + import { + Badge, + Tabs, + Tab, + TabContent, + Button, + ActionRow, + Alert, + ButtonPopup, + ButtonPopupItem + } from '$lib/components/common' import Skeleton from '../../../lib/components/common/skeleton/Skeleton.svelte' import UserSettings from '$lib/components/UserSettings.svelte' import Icon from 'svelte-awesome' @@ -132,127 +143,53 @@ }) - - - {#if script} - - - { - 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) - } - ]}>delete... - - - - - - - - {#if !topHash} - - {/if} - - - -{/if} - - - {#if script} -
-
-
-

- {defaultIfEmptyString(script.summary, script.path)} -

- {#if !emptyString(script.summary)} -

{script.path}

- {/if} + + +
+
+
+

{defaultIfEmptyString(script.summary, script.path)}

+ +
+ + + {#if !topHash} + + {/if} +
+
+ + {script.path} + +
+

+ Edited {displayDaysAgo(script.created_at || '')} by {script.created_by || 'unknown'} +

- - {#if script} - Edited {displayDaysAgo(script.created_at || '')} by {script.created_by || 'unknown'} - {/if} - {truncateHash(script?.hash ?? '')} @@ -278,164 +215,240 @@
-
-
- {/if} - +
+ + + + + {#if Array.isArray(script.parent_hashes) && script.parent_hashes.length > 0} + + Previous version ({script.parent_hashes.length}) -
- - - {#if script} -
-
-

Description

- -
- -
+ {#each script.parent_hashes as hash} + + {hash} + + {/each} + + {/if}
-
-

Versions

- - {#if script} -
-

Current

-
- {script?.hash} + + {#if script.lock_error_logs || topHash || script.archived || script.deleted} +
+ {#if script.lock_error_logs} + -

Previous

- {#if script?.parent_hashes?.length} -
    - {#each script.parent_hashes as hash} -
  • - {hash} -
  • - {/each} -
- {:else} -

There are no previous versions

- {/if} -
- {/if} -
-
+ {/if} + {#if topHash} + + This hash is not HEAD (latest non-archived version at this path) : + Go to the HEAD of this path + + {/if} + {#if script.archived && !topHash} + This version was archived + {/if} + {#if script.deleted} + + {/if} +
+ {/if} - {#if script.lock_error_logs || topHash || script.archived || script.deleted} -
- {#if script.lock_error_logs} - - {/if} - {#if topHash} - - This hash is not HEAD (latest non-archived version at this path) : - Go to the HEAD of this path - - {/if} - {#if script.archived && !topHash} - This version was archived - {/if} - {#if script.deleted} - - {/if} +
+

Description

+
- {/if} - {/if} -
-

- Arguments JSON schema - - The jsonschema defines the constraints that the payload must respect to be compatible with - the input parameters of this script. The UI form is generated automatically from the - script jsonschema. See - jsonschema documentation - -

- - {#if script} -
+
+

+ Arguments JSON schema + + + The jsonschema defines the constraints that the payload must respect to be compatible + with the input parameters of this script. The UI form is generated automatically from + the script jsonschema. See + + jsonschema documentation + + +

+
- {/if} -
-
-

Code

- - {#if script} - - {/if} -
-
-

WebhooksTo trigger this script with a webhook, do a POST request to the endpoints below. Scripts are - not public and can only be run by users with at least view rights on them. You will need to - pass a bearer token to authentify as a user. You can either pass it as a Bearer token or as - query arg `?token=XXX`. See docs

- - {#if script} -
- - UUID - Result - - {#each Object.keys(webhooks) as key} - - -
- -
-
- {/each} -
-
+
+

Code

+ + + + + Code + Dependencies lock file + + +
+ +
+
+ +
+ {#if script?.lock} +
{script.lock}
+ {:else} +

There is no lock file for this script

+ {/if} +
+
+
+
+
+ +
+

+ Webhooks + + To trigger this script with a webhook, do a POST request to the endpoints below. + Scripts are not public and can only be run by users with at least view rights on them. + You will need to pass a bearer token to authentify as a user. You can either pass it + as a Bearer token or as query arg `?token=XXX`. + + See docs + + +

+ + + UUID + Result + + {#each Object.keys(webhooks) as key} + + +
+ +
+
+ {/each} +
+
+
+
+

Danger zone

+
+ + +
+
+
- {/if} -
-

Dependencies lock file

- - {#if script} - {#if script?.lock} -
{script.lock}
- {:else} -

There is no lock file for this script

- {/if} - {/if} -
- + +{/if} + + + +