refactor(CommandPalette): remove unused visualizer actions and simplify action handling

This commit is contained in:
Ivan
2026-05-02 23:09:08 -05:00
parent fbacdc2621
commit 313a66102e
2 changed files with 5 additions and 131 deletions
@@ -115,14 +115,6 @@ import LxmfUserIcon from "./LxmfUserIcon.vue";
import GlobalEmitter from "../js/GlobalEmitter";
import ToastUtils from "../js/ToastUtils";
const VISUALISER_ONLY_ACTIONS = new Set([
"toggle-orbit",
"toggle-bouncing-balls",
"toggle-falling-skies",
"toggle-snake",
"toggle-pong",
]);
export default {
name: "CommandPalette",
components: { MaterialDesignIcon, LxmfUserIcon },
@@ -318,46 +310,6 @@ export default {
type: "action",
action: "compose",
},
{
id: "action-orbit",
title: "action_orbit",
description: "action_orbit_desc",
icon: "orbit",
type: "action",
action: "toggle-orbit",
},
{
id: "action-bouncing-balls",
title: "action_bouncing_balls",
description: "action_bouncing_balls_desc",
icon: "bounce",
type: "action",
action: "toggle-bouncing-balls",
},
{
id: "action-falling-skies",
title: "action_falling_skies",
description: "action_falling_skies_desc",
icon: "weather-pouring",
type: "action",
action: "toggle-falling-skies",
},
{
id: "action-snake",
title: "action_snake",
description: "action_snake_desc",
icon: "snake",
type: "action",
action: "toggle-snake",
},
{
id: "action-pong",
title: "action_pong",
description: "action_pong_desc",
icon: "table-tennis",
type: "action",
action: "toggle-pong",
},
{
id: "action-getting-started",
title: "action_getting_started",
@@ -379,19 +331,11 @@ export default {
},
computed: {
allResults() {
const onVisualiser = this.$route?.name === "network-visualiser";
const results = this.actions
.filter((action) => {
if (action.type === "action" && VISUALISER_ONLY_ACTIONS.has(action.action)) {
return onVisualiser;
}
return true;
})
.map((action) => ({
...action,
title: this.$t(`command_palette.${action.title}`),
description: this.$t(`command_palette.${action.description}`),
}));
const results = this.actions.map((action) => ({
...action,
title: this.$t(`command_palette.${action.title}`),
description: this.$t(`command_palette.${action.description}`),
}));
// add peers
if (Array.isArray(this.peers)) {
@@ -536,16 +480,6 @@ export default {
const input = document.getElementById("compose-input");
input?.focus();
});
} else if (result.action === "toggle-orbit") {
GlobalEmitter.emit("toggle-orbit");
} else if (result.action === "toggle-bouncing-balls") {
GlobalEmitter.emit("toggle-bouncing-balls");
} else if (result.action === "toggle-falling-skies") {
GlobalEmitter.emit("toggle-falling-skies");
} else if (result.action === "toggle-snake") {
GlobalEmitter.emit("toggle-snake");
} else if (result.action === "toggle-pong") {
GlobalEmitter.emit("toggle-pong");
} else if (result.action === "show-tutorial") {
GlobalEmitter.emit("show-tutorial");
} else if (result.action === "show-changelog") {
-60
View File
@@ -23,19 +23,11 @@ describe("CommandPalette.vue", () => {
};
GlobalEmitter.off("sync-propagation-node");
GlobalEmitter.off("toggle-orbit");
GlobalEmitter.off("toggle-falling-skies");
GlobalEmitter.off("toggle-snake");
GlobalEmitter.off("toggle-pong");
});
afterEach(() => {
delete window.api;
GlobalEmitter.off("sync-propagation-node");
GlobalEmitter.off("toggle-orbit");
GlobalEmitter.off("toggle-falling-skies");
GlobalEmitter.off("toggle-snake");
GlobalEmitter.off("toggle-pong");
vi.clearAllMocks();
});
@@ -254,58 +246,6 @@ describe("CommandPalette.vue", () => {
}
});
it("emits toggle-orbit event when orbit action is executed", async () => {
const wrapper = mountCommandPalette({ name: "network-visualiser" });
const emitSpy = vi.spyOn(GlobalEmitter, "emit");
wrapper.vm.isOpen = true;
await wrapper.vm.$nextTick();
const orbitResult = wrapper.vm.filteredResults.find((r) => r.action === "toggle-orbit");
if (orbitResult) {
wrapper.vm.executeResult(orbitResult);
expect(emitSpy).toHaveBeenCalledWith("toggle-orbit");
}
});
it("emits toggle-falling-skies when falling skies action is executed", async () => {
const wrapper = mountCommandPalette({ name: "network-visualiser" });
const emitSpy = vi.spyOn(GlobalEmitter, "emit");
wrapper.vm.isOpen = true;
await wrapper.vm.$nextTick();
const result = wrapper.vm.filteredResults.find((r) => r.action === "toggle-falling-skies");
if (result) {
wrapper.vm.executeResult(result);
expect(emitSpy).toHaveBeenCalledWith("toggle-falling-skies");
}
});
it("emits toggle-snake when mesh snake action is executed", async () => {
const wrapper = mountCommandPalette({ name: "network-visualiser" });
const emitSpy = vi.spyOn(GlobalEmitter, "emit");
wrapper.vm.isOpen = true;
await wrapper.vm.$nextTick();
const result = wrapper.vm.filteredResults.find((r) => r.action === "toggle-snake");
if (result) {
wrapper.vm.executeResult(result);
expect(emitSpy).toHaveBeenCalledWith("toggle-snake");
}
});
it("emits toggle-pong when mesh pong action is executed", async () => {
const wrapper = mountCommandPalette({ name: "network-visualiser" });
const emitSpy = vi.spyOn(GlobalEmitter, "emit");
wrapper.vm.isOpen = true;
await wrapper.vm.$nextTick();
const result = wrapper.vm.filteredResults.find((r) => r.action === "toggle-pong");
if (result) {
wrapper.vm.executeResult(result);
expect(emitSpy).toHaveBeenCalledWith("toggle-pong");
}
});
it("closes when ESC key is pressed", async () => {
const wrapper = mountCommandPalette();
wrapper.vm.isOpen = true;