chore(react/bulk_actions): clean up

This commit is contained in:
Elian Doran 2025-08-09 20:37:45 +03:00
parent 7c79fbefa6
commit 899f85f4e7
No known key found for this signature in database
2 changed files with 3 additions and 28 deletions

View File

@ -1,7 +1,5 @@
import { t } from "../../services/i18n.js";
import server from "../../services/server.js";
import ws from "../../services/ws.js";
import utils from "../../services/utils.js";
import type FAttribute from "../../entities/fattribute.js";
import { VNode } from "preact";
@ -28,29 +26,9 @@ export default abstract class AbstractBulkAction {
this.actionDef = actionDef;
}
render() {
try {
const $rendered = this.doRender();
if (Array.isArray($rendered)) {
$rendered
.find(".action-conf-del")
.on("click", () => this.deleteAction())
.attr("title", t("abstract_bulk_action.remove_this_search_action"));
utils.initHelpDropdown($rendered);
return $rendered;
} else {
return $rendered;
}
} catch (e: any) {
logError(`Failed rendering search action: ${JSON.stringify(this.attribute.dto)} with error: ${e.message} ${e.stack}`);
return null;
}
}
// to be overridden
abstract doRender(): JQuery<HTMLElement> | VNode;
abstract doRender(): VNode;
static get actionName() {
return "";
}
@ -70,9 +48,6 @@ export default abstract class AbstractBulkAction {
async deleteAction() {
await server.remove(`notes/${this.attribute.noteId}/attributes/${this.attribute.attributeId}`);
await ws.waitForMaxKnownEntityChangeId();
//await this.triggerCommand('refreshSearchDefinition');
}
}

View File

@ -104,7 +104,7 @@ function ExistingActionsList({ existingActions }: { existingActions?: RenameNote
<table class="bulk-existing-action-list">
{ existingActions
? existingActions
.map(action => action.render())
.map(action => action.doRender())
.filter(renderedAction => renderedAction !== null)
: <p>{t("bulk_actions.none_yet")}</p>
}