diff --git a/backend/profiles.py b/backend/profiles.py
index a47ac949..72a67d12 100644
--- a/backend/profiles.py
+++ b/backend/profiles.py
@@ -361,7 +361,7 @@ class ProfileOps:
# delete profile.pathname
res = await self.profiles.delete_one(query)
- if not res or res.get("deleteCount") != 1:
+ if not res or res.deleted_count != 1:
raise HTTPException(status_code=404, detail="profile_not_found")
return {"success": True}
diff --git a/frontend/src/pages/archive/browser-profiles-detail.ts b/frontend/src/pages/archive/browser-profiles-detail.ts
index ea1c369b..15b4384f 100644
--- a/frontend/src/pages/archive/browser-profiles-detail.ts
+++ b/frontend/src/pages/archive/browser-profiles-detail.ts
@@ -6,6 +6,7 @@ import type { AuthState } from "../../utils/AuthService";
import LiteElement, { html } from "../../utils/LiteElement";
import { ProfileBrowser } from "../../components/profile-browser";
import { Profile } from "./types";
+import { F } from "lodash/fp";
/**
* Usage:
@@ -287,6 +288,20 @@ export class BrowserProfilesDetail extends LiteElement {
>${msg("Duplicate profile")}
+
+ {
+ this.deleteProfile();
+ }}
+ >
+
+ ${msg("Delete")}
+
`;
@@ -404,6 +419,50 @@ export class BrowserProfilesDetail extends LiteElement {
}
}
+ private async deleteProfile() {
+ const profileName = this.profile!.name;
+
+ try {
+ const data = await this.apiFetch(
+ `/archives/${this.archiveId}/profiles/${this.profile!.id}`,
+ this.authState!,
+ {
+ method: "DELETE",
+ }
+ );
+
+ if (data.error && data.crawlconfigs) {
+ this.notify({
+ message: msg(
+ html`Could not delete ${profileName}, in use by
+ ${data.crawlconfigs
+ .map(({ name }: any) => name)
+ .join(", ")}. Please remove browser profile from crawl template to continue.`
+ ),
+ type: "warning",
+ icon: "exclamation-triangle",
+ duration: 15000,
+ });
+ } else {
+ this.navTo(`/archives/${this.archiveId}/browser-profiles`);
+
+ this.notify({
+ message: msg(html`Deleted ${profileName}.`),
+ type: "success",
+ icon: "check2-circle",
+ });
+ }
+ } catch (e) {
+ this.notify({
+ message: msg("Sorry, couldn't delete browser profile at this time."),
+ type: "danger",
+ icon: "exclamation-octagon",
+ });
+ }
+ }
+
private createBrowser({ url }: { url: string }) {
const params = {
url,
diff --git a/frontend/src/pages/archive/browser-profiles-list.ts b/frontend/src/pages/archive/browser-profiles-list.ts
index 25ad1789..873abbac 100644
--- a/frontend/src/pages/archive/browser-profiles-list.ts
+++ b/frontend/src/pages/archive/browser-profiles-list.ts
@@ -170,7 +170,29 @@ export class BrowserProfilesList extends LiteElement {
e.target.closest("sl-dropdown").hide();
}}
>
- ${msg("Duplicate browser profile")}
+
+ ${msg("Duplicate profile")}
+
+ {
+ // Close dropdown before deleting template
+ e.target.closest("sl-dropdown").hide();
+
+ this.deleteProfile(data);
+ }}
+ >
+
+ ${msg("Delete")}
@@ -300,6 +322,50 @@ export class BrowserProfilesList extends LiteElement {
}
}
+ private async deleteProfile(profile: Profile) {
+ try {
+ const data = await this.apiFetch(
+ `/archives/${this.archiveId}/profiles/${profile.id}`,
+ this.authState!,
+ {
+ method: "DELETE",
+ }
+ );
+
+ if (data.error && data.crawlconfigs) {
+ this.notify({
+ message: msg(
+ html`Could not delete ${profile.name}, in use by
+ ${data.crawlconfigs
+ .map(({ name }: any) => name)
+ .join(", ")}. Please remove browser profile from crawl template to continue.`
+ ),
+ type: "warning",
+ icon: "exclamation-triangle",
+ duration: 15000,
+ });
+ } else {
+ this.notify({
+ message: msg(html`Deleted ${profile.name}.`),
+ type: "success",
+ icon: "check2-circle",
+ });
+
+ this.browserProfiles = this.browserProfiles!.filter(
+ (p) => p.id !== profile.id
+ );
+ }
+ } catch (e) {
+ this.notify({
+ message: msg("Sorry, couldn't delete browser profile at this time."),
+ type: "danger",
+ icon: "exclamation-octagon",
+ });
+ }
+ }
+
private createBrowser({ url }: { url: string }) {
const params = {
url,