${msg(
"Are you sure you want to discard changes to this browser profile?",
@@ -323,52 +311,6 @@ export class BrowserProfilesDetail extends BtrixElement {
return pageNav(breadcrumbs);
}
- private renderCrawlWorkflows() {
- if (this.profile?.crawlconfigs?.length) {
- return html``;
- }
-
- return html`
- ${msg("Not used in any crawl workflows.")}
-
`;
- }
-
- private renderWorkflowName(workflow: ProfileWorkflow) {
- if (workflow.name)
- return html`${workflow.name}`;
- if (!workflow.firstSeed)
- return html`${workflow.id}
- ${msg("(no name)")}`;
- const remainder = workflow.seedCount - 1;
- let nameSuffix: string | TemplateResult<1> = "";
- if (remainder) {
- nameSuffix = html`+${this.localize.number(remainder, { notation: "compact" })}
- ${pluralOf("URLs", remainder)}`;
- }
- return html`
- ${workflow.firstSeed}${nameSuffix}
- `;
- }
-
private readonly renderVisitedSites = () => {
return html`
@@ -612,36 +554,36 @@ export class BrowserProfilesDetail extends BtrixElement {
const profileName = this.profile!.name;
try {
- const data = await this.api.fetch(
+ await this.api.fetch(
`/orgs/${this.orgId}/profiles/${this.profile!.id}`,
{
method: "DELETE",
},
);
- if (data.error && data.crawlconfigs) {
- this.notify.toast({
- message: msg(
- html`Could not delete ${profileName}, in use by
- ${data.crawlconfigs.map(({ name }) => name).join(", ")}. Please remove browser profile from Workflow to continue.`,
- ),
- variant: "warning",
- duration: 15000,
- });
- } else {
- this.navigate.to(`${this.navigate.orgBasePath}/browser-profiles`);
+ this.navigate.to(`${this.navigate.orgBasePath}/browser-profiles`);
- this.notify.toast({
- message: msg(html`Deleted ${profileName}.`),
- variant: "success",
- icon: "check2-circle",
- });
- }
+ this.notify.toast({
+ message: msg(html`Deleted ${profileName}.`),
+ variant: "success",
+ icon: "check2-circle",
+ });
} catch (e) {
+ let message = msg(
+ html`Sorry, couldn't delete browser profile at this time.`,
+ );
+
+ if (isApiError(e)) {
+ if (e.message === "profile_in_use") {
+ message = msg(
+ html`Could not delete ${profileName}, currently in
+ use. Please remove browser profile from all crawl workflows to
+ continue.`,
+ );
+ }
+ }
this.notify.toast({
- message: msg("Sorry, couldn't delete browser profile at this time."),
+ message: message,
variant: "danger",
icon: "exclamation-octagon",
id: "browser-profile-error",
diff --git a/frontend/src/pages/org/browser-profiles-list.ts b/frontend/src/pages/org/browser-profiles-list.ts
index 0cf59cfcbf..e0db104ea8 100644
--- a/frontend/src/pages/org/browser-profiles-list.ts
+++ b/frontend/src/pages/org/browser-profiles-list.ts
@@ -23,6 +23,7 @@ import type {
APISortQuery,
} from "@/types/api";
import type { Browser } from "@/types/browser";
+import { isApiError } from "@/utils/api";
import { html } from "@/utils/LiteElement";
import { isArchivingDisabled } from "@/utils/orgs";
import { tw } from "@/utils/tailwind";
@@ -382,40 +383,40 @@ export class BrowserProfilesList extends BtrixElement {
private async deleteProfile(profile: Profile) {
try {
- const data = await this.api.fetch(
+ await this.api.fetch<{ error?: boolean }>(
`/orgs/${this.orgId}/profiles/${profile.id}`,
{
method: "DELETE",
},
);
- if (data.error && data.crawlconfigs) {
- this.notify.toast({
- message: msg(
- html`Could not delete ${profile.name}, in use by
- ${data.crawlconfigs.map(({ name }) => name).join(", ")}. Please remove browser profile from Workflow to continue.`,
- ),
- variant: "warning",
- duration: 15000,
- });
- } else {
- this.notify.toast({
- message: msg(html`Deleted ${profile.name}.`),
- variant: "success",
- icon: "check2-circle",
- id: "browser-profile-deleted-status",
- });
-
- void this.fetchBrowserProfiles();
- }
+ this.notify.toast({
+ message: msg(html`Deleted ${profile.name}.`),
+ variant: "success",
+ icon: "check2-circle",
+ id: "browser-profile-deleted-status",
+ });
+
+ void this.fetchBrowserProfiles();
} catch (e) {
+ let message = msg(
+ html`Sorry, couldn't delete browser profile at this time.`,
+ );
+
+ if (isApiError(e)) {
+ if (e.message === "profile_in_use") {
+ message = msg(
+ html`Could not delete ${profile.name}, currently in
+ use. Please remove browser profile from all crawl workflows to
+ continue.`,
+ );
+ }
+ }
this.notify.toast({
- message: msg("Sorry, couldn't delete browser profile at this time."),
+ message: message,
variant: "danger",
icon: "exclamation-octagon",
- id: "browser-profile-deleted-status",
+ id: "browser-profile-error",
});
}
}
diff --git a/frontend/src/types/crawler.ts b/frontend/src/types/crawler.ts
index a903be965d..ea633240c0 100644
--- a/frontend/src/types/crawler.ts
+++ b/frontend/src/types/crawler.ts
@@ -113,13 +113,6 @@ export type ProfileReplica = {
custom?: boolean;
};
-export type ProfileWorkflow = {
- id: string;
- name: string;
- firstSeed: string;
- seedCount: number;
-};
-
export type Profile = {
id: string;
name: string;
@@ -132,7 +125,7 @@ export type Profile = {
profileId: string;
baseProfileName: string;
oid: string;
- crawlconfigs?: ProfileWorkflow[];
+ inUse: boolean;
resource?: {
name: string;
path: string;