mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 12:30:24 +00:00
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import React from "react";
|
|
import { GroupedStatuses, NoteStatus } from "@/types/noteStatus";
|
|
import {
|
|
StatusSelectorGroup,
|
|
Props as StatusSelectorGroupProps,
|
|
} from "./StatusSelectorGroup";
|
|
import { StatusTemplate } from "@/types/pluginSettings";
|
|
|
|
export interface Props {
|
|
currentStatuses: GroupedStatuses;
|
|
filesQuantity: number;
|
|
availableStatuses: NoteStatus[];
|
|
templates: StatusTemplate[];
|
|
iconFrameMode?: "always" | "never";
|
|
iconColorMode?: "status" | "theme";
|
|
onRemoveStatus: (
|
|
frontmatterTagName: string,
|
|
status: NoteStatus,
|
|
) => Promise<void>;
|
|
onSelectStatus: (
|
|
frontmatterTagName: string,
|
|
status: NoteStatus,
|
|
) => Promise<void>;
|
|
}
|
|
|
|
export const ChangeStatusModal: React.FC<Props> = ({
|
|
currentStatuses: initialStatuses,
|
|
filesQuantity,
|
|
availableStatuses,
|
|
templates,
|
|
iconFrameMode = "never",
|
|
iconColorMode = "status",
|
|
onRemoveStatus,
|
|
onSelectStatus,
|
|
}) => {
|
|
const currentStatuses = Object.entries(initialStatuses);
|
|
|
|
const handleSelectedState: StatusSelectorGroupProps["onSelectedState"] = (
|
|
frontmatterTagName,
|
|
status,
|
|
action,
|
|
) => {
|
|
if (action === "select") {
|
|
onSelectStatus(frontmatterTagName, status);
|
|
} else {
|
|
onRemoveStatus(frontmatterTagName, status);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<h1>
|
|
Change note status ({filesQuantity} file
|
|
{filesQuantity !== 1 ? "s" : ""})
|
|
</h1>
|
|
|
|
{currentStatuses.map(([frontmatterTagName, statusList]) => (
|
|
<StatusSelectorGroup
|
|
key={frontmatterTagName}
|
|
frontmatterTagName={frontmatterTagName}
|
|
availableStatuses={availableStatuses}
|
|
currentStatuses={statusList}
|
|
templates={templates}
|
|
iconFrameMode={iconFrameMode}
|
|
iconColorMode={iconColorMode}
|
|
onSelectedState={handleSelectedState}
|
|
/>
|
|
))}
|
|
</>
|
|
);
|
|
};
|