From de9212eec77a59b9187d9e4ae889a395cf6aed0a Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 10 Mar 2023 22:36:10 -0800 Subject: [PATCH] exclusions editor fix: (#692) - backend: fix updating model after exclusions change - frontend: don't check for new_cid, just success - fixes #691 --- backend/btrixcloud/crawls.py | 2 +- frontend/src/components/exclusion-editor.ts | 12 ++++-------- frontend/src/pages/org/workflows-new.ts | 2 +- frontend/src/types/crawler.ts | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/backend/btrixcloud/crawls.py b/backend/btrixcloud/crawls.py index 04ba058a4..405442adc 100644 --- a/backend/btrixcloud/crawls.py +++ b/backend/btrixcloud/crawls.py @@ -619,7 +619,7 @@ async def add_or_remove_exclusion(self, crawl_id, regex, org, user, add): ) await self.crawls.find_one_and_update( - {"_id": crawl_id, "oid": org.id}, {"$set": {"config": new_config}} + {"_id": crawl_id, "oid": org.id}, {"$set": {"config": new_config.dict()}} ) resp = {"success": True} diff --git a/frontend/src/components/exclusion-editor.ts b/frontend/src/components/exclusion-editor.ts index 846270cdf..fb3d45a66 100644 --- a/frontend/src/components/exclusion-editor.ts +++ b/frontend/src/components/exclusion-editor.ts @@ -157,7 +157,7 @@ export class ExclusionEditor extends LiteElement { } ); - if (data.new_cid) { + if (data.success) { this.notify({ message: msg(html`Removed exclusion: ${regex}`), variant: "success", @@ -165,9 +165,7 @@ export class ExclusionEditor extends LiteElement { }); this.dispatchEvent( - new CustomEvent("on-success", { - detail: { cid: data.new_cid }, - }) + new CustomEvent("on-success") ); } else { throw data; @@ -229,7 +227,7 @@ export class ExclusionEditor extends LiteElement { } ); - if (data.new_cid) { + if (data.success) { this.notify({ message: msg("Exclusion added."), variant: "success", @@ -242,9 +240,7 @@ export class ExclusionEditor extends LiteElement { onSuccess(); this.dispatchEvent( - new CustomEvent("on-success", { - detail: { cid: data.new_cid }, - }) + new CustomEvent("on-success") ); } else { throw data; diff --git a/frontend/src/pages/org/workflows-new.ts b/frontend/src/pages/org/workflows-new.ts index d87816029..1be151f99 100644 --- a/frontend/src/pages/org/workflows-new.ts +++ b/frontend/src/pages/org/workflows-new.ts @@ -22,7 +22,7 @@ const defaultValue = { }, tags: [], crawlTimeout: null, - jobType: "custom", + jobType: undefined, scale: 1, } as WorkflowParams; diff --git a/frontend/src/types/crawler.ts b/frontend/src/types/crawler.ts index c368d9cf2..ae44b7455 100644 --- a/frontend/src/types/crawler.ts +++ b/frontend/src/types/crawler.ts @@ -31,7 +31,7 @@ export type SeedConfig = Pick< export type JobType = "url-list" | "seed-crawl" | "custom"; export type WorkflowParams = { - jobType: JobType; + jobType?: JobType; name: string; schedule: string; scale: number;