Skip to content

Commit

Permalink
impr(commandline): show active tags with a check icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Mar 13, 2024
1 parent 0f6861d commit c1b71fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion frontend/src/ts/commandline/commandline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,14 @@ async function showCommands(): Promise<void> {
}
let configIcon = "";
const configKey = command.configKey ?? (await getSubgroup()).configKey;
if (configKey !== undefined) {
if (command.active !== undefined) {
if (command.active()) {
firstActive = firstActive ?? index;
configIcon = `<i class="fas fa-fw fa-check"></i>`;
} else {
configIcon = `<i class="fas fa-fw"></i>`;
}
} else if (configKey !== undefined) {
const valueIsIncluded =
command.configValueMode === "include" &&
(
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/ts/commandline/lists/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const subgroup: MonkeyTypes.CommandsSubgroup = {

const commands: MonkeyTypes.Command[] = [
{
visible: false,
id: "changeTags",
display: "Tags...",
icon: "fa-tag",
Expand Down Expand Up @@ -50,6 +49,7 @@ function update(): void {
id: "clearTags",
display: `Clear tags`,
icon: "fa-times",
sticky: true,
exec: (): void => {
const snapshot = DB.getSnapshot();
if (!snapshot) return;
Expand All @@ -71,6 +71,12 @@ function update(): void {
id: "toggleTag" + tag._id,
display: tag.display,
sticky: true,
active: () => {
return (
DB.getSnapshot()?.tags?.find((t) => t._id === tag._id)?.active ??
false
);
},
exec: async (): Promise<void> => {
TagController.toggle(tag._id);
void ModesNotice.update();
Expand Down
1 change: 1 addition & 0 deletions frontend/src/ts/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ declare namespace MonkeyTypes {
exec?: (input?: string) => void;
hover?: () => void;
available?: () => boolean;
active?: () => boolean;
shouldFocusTestUI?: boolean;
customData?: Record<string, string>;
};
Expand Down

0 comments on commit c1b71fb

Please sign in to comment.