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.
This commit is contained in:
parent
3a05002491
commit
7047cbeda9
@ -9,6 +9,8 @@ import { guard } from "lit/directives/guard.js";
|
|||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
import { ifDefined } from "lit/directives/if-defined.js";
|
||||||
import { until } from "lit/directives/until.js";
|
import { until } from "lit/directives/until.js";
|
||||||
import { when } from "lit/directives/when.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 queryString from "query-string";
|
||||||
|
|
||||||
import type { Crawl, CrawlLog, Seed, Workflow } from "./types";
|
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;
|
const isLoading = (task: Task) => task.status === TaskStatus.PENDING;
|
||||||
|
|
||||||
|
// Omit null or undefined values from object
|
||||||
|
const omitNil = omitBy(isNil);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage:
|
* Usage:
|
||||||
* ```ts
|
* ```ts
|
||||||
@ -789,16 +794,40 @@ export class WorkflowDetail extends BtrixElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.workflowTab === WorkflowTab.Settings && this.isCrawler) {
|
if (this.workflowTab === WorkflowTab.Settings) {
|
||||||
return html` <sl-tooltip content=${msg("Edit Workflow Settings")}>
|
return html`
|
||||||
<sl-icon-button
|
${this.appState.isAdmin
|
||||||
name="pencil"
|
? html`<btrix-copy-button
|
||||||
class="text-base"
|
name="filetype-json"
|
||||||
href="${this.basePath}?edit"
|
value=${ifDefined(
|
||||||
@click=${this.navigate.link}
|
this.workflow &&
|
||||||
>
|
this.seeds &&
|
||||||
</sl-icon-button>
|
JSON.stringify(
|
||||||
</sl-tooltip>`;
|
{
|
||||||
|
...omitNil(this.workflow.config),
|
||||||
|
seeds: this.seeds.items.map(omitNil),
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
content=${msg("Copy as JSON")}
|
||||||
|
size="medium"
|
||||||
|
>
|
||||||
|
</btrix-copy-button>`
|
||||||
|
: nothing}
|
||||||
|
${this.isCrawler
|
||||||
|
? html`<sl-tooltip content=${msg("Edit Workflow Settings")}>
|
||||||
|
<sl-icon-button
|
||||||
|
name="gear"
|
||||||
|
class="text-base"
|
||||||
|
href="${this.basePath}?edit"
|
||||||
|
@click=${this.navigate.link}
|
||||||
|
>
|
||||||
|
</sl-icon-button>
|
||||||
|
</sl-tooltip>`
|
||||||
|
: nothing}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nothing;
|
return nothing;
|
||||||
|
Loading…
Reference in New Issue
Block a user