MCPcopy
hub / github.com/CapSoftware/Cap / Dialogs

Function Dialogs

apps/desktop/src/routes/editor/Editor.tsx:764–1386  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

762}
763
764function Dialogs() {
765 const { dialog, setDialog, presets, project } = useEditorContext();
766
767 const isDialogType = () => isModalDialog(dialog());
768
769 return (
770 <Dialog.Root
771 size="sm"
772 contentClass={(() => {
773 const d = dialog();
774 if ("type" in d && d.type === "export") return "max-w-[740px]";
775 if ("type" in d && d.type === "crop") return "max-w-[1180px]";
776 return "";
777 })()}
778 open={isDialogType()}
779 onOpenChange={(o) => {
780 if (!o) setDialog((d) => ({ ...d, open: false }));
781 }}
782 >
783 <Show
784 when={(() => {
785 const d = dialog();
786 if (isModalDialog(d)) return d;
787 })()}
788 >
789 {(dialog) => (
790 <Switch>
791 <Match when={dialog().type === "createPreset"}>
792 {(_) => {
793 const [form, setForm] = createStore({
794 name: "",
795 default: false,
796 });
797
798 const createPreset = createMutation(() => ({
799 mutationFn: async () => {
800 await presets.createPreset({ ...form, config: project });
801 },
802 onSuccess: () => {
803 setDialog((d) => ({ ...d, open: false }));
804 },
805 }));
806
807 return (
808 <DialogContent
809 title="Create Preset"
810 confirm={
811 <Dialog.ConfirmButton
812 disabled={createPreset.isPending}
813 onClick={() => createPreset.mutate()}
814 >
815 Create
816 </Dialog.ConfirmButton>
817 }
818 >
819 <Subfield name="Name" required />
820 <Input
821 class="mt-2"

Callers

nothing calls this directly

Calls 9

isModalDialogFunction · 0.90
isDialogTypeFunction · 0.85
createStoreFunction · 0.85
onFunction · 0.85
drawPreviewFunction · 0.85
queueConfigFunction · 0.85
addEventListenerMethod · 0.80
removeEventListenerMethod · 0.80
showCropOptionsMenuFunction · 0.70

Tested by

no test coverage detected