From 7047cbeda917e8b4bdaa4efe7fc26dd60a1dc0d3 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Thu, 31 Jul 2025 22:59:31 -0700 Subject: [PATCH] feat: Copy workflow config as JSON (#2777) Partially addresses https://github.com/webrecorder/browsertrix/issues/2751 ## Changes - Enables copying workflow `config` to clipboard as JSON for superadmin. - Fixes "Edit Workflow Settings" icon inconsistency. --- frontend/src/pages/org/workflow-detail.ts | 49 ++++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/org/workflow-detail.ts b/frontend/src/pages/org/workflow-detail.ts index 5777f94f..76603d8a 100644 --- a/frontend/src/pages/org/workflow-detail.ts +++ b/frontend/src/pages/org/workflow-detail.ts @@ -9,6 +9,8 @@ import { guard } from "lit/directives/guard.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { until } from "lit/directives/until.js"; import { when } from "lit/directives/when.js"; +import omitBy from "lodash/fp/omitBy"; +import isNil from "lodash/isNil"; import queryString from "query-string"; import type { Crawl, CrawlLog, Seed, Workflow } from "./types"; @@ -51,6 +53,9 @@ const CRAWLS_PAGINATION_NAME = "crawlsPage"; const isLoading = (task: Task) => task.status === TaskStatus.PENDING; +// Omit null or undefined values from object +const omitNil = omitBy(isNil); + /** * Usage: * ```ts @@ -789,16 +794,40 @@ export class WorkflowDetail extends BtrixElement { `; } - if (this.workflowTab === WorkflowTab.Settings && this.isCrawler) { - return html` - - - `; + if (this.workflowTab === WorkflowTab.Settings) { + return html` + ${this.appState.isAdmin + ? html` + ` + : nothing} + ${this.isCrawler + ? html` + + + ` + : nothing} + `; } return nothing;