Changed flowSettings to new type of popup
This commit is contained in:
parent
e0f9b3419e
commit
3a9a89840d
2 changed files with 27 additions and 51 deletions
|
|
@ -6,8 +6,7 @@ import {
|
||||||
Settings2,
|
Settings2,
|
||||||
Undo,
|
Undo,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useContext } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { PopUpContext } from "../../../../contexts/popUpContext";
|
|
||||||
import { TabsContext } from "../../../../contexts/tabsContext";
|
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
|
@ -26,8 +25,8 @@ import { Button } from "../../../ui/button";
|
||||||
export const MenuBar = ({ flows, tabId }) => {
|
export const MenuBar = ({ flows, tabId }) => {
|
||||||
const { updateFlow, setTabId, addFlow } = useContext(TabsContext);
|
const { updateFlow, setTabId, addFlow } = useContext(TabsContext);
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
const { openPopUp } = useContext(PopUpContext);
|
|
||||||
const { undo, redo } = useContext(undoRedoContext);
|
const { undo, redo } = useContext(undoRedoContext);
|
||||||
|
const [openSettings, setOpenSettings] = useState(false);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
|
@ -69,15 +68,17 @@ export const MenuBar = ({ flows, tabId }) => {
|
||||||
<Plus className="header-menu-options" />
|
<Plus className="header-menu-options" />
|
||||||
New
|
New
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(<FlowSettingsModal />);
|
setOpenSettings(true);
|
||||||
}}
|
}}
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
>
|
>
|
||||||
<Settings2 className="header-menu-options " />
|
<Settings2 className="header-menu-options " />
|
||||||
Settings
|
Settings
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
undo();
|
undo();
|
||||||
|
|
@ -96,32 +97,12 @@ export const MenuBar = ({ flows, tabId }) => {
|
||||||
<Redo className="header-menu-options " />
|
<Redo className="header-menu-options " />
|
||||||
Redo
|
Redo
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
{/* <DropdownMenuSeparator /> */}
|
|
||||||
{/* <DropdownMenuLabel>Projects</DropdownMenuLabel> */}
|
|
||||||
{/* <DropdownMenuRadioGroup className="max-h-full overflow-scroll"
|
|
||||||
value={tabId}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
setTabId(value);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{flows.map((flow, idx) => {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
to={"/flow/" + flow.id}
|
|
||||||
className="flex w-full items-center"
|
|
||||||
>
|
|
||||||
<DropdownMenuRadioItem
|
|
||||||
value={flow.id}
|
|
||||||
className="flex-1 w-full inline-block truncate break-words mr-2"
|
|
||||||
>
|
|
||||||
{flow.name}
|
|
||||||
</DropdownMenuRadioItem>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</DropdownMenuRadioGroup> */}
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
<FlowSettingsModal
|
||||||
|
open={openSettings}
|
||||||
|
setOpen={setOpenSettings}
|
||||||
|
></FlowSettingsModal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,18 @@ import { Settings2 } from "lucide-react";
|
||||||
import { useContext, useRef, useState } from "react";
|
import { useContext, useRef, useState } from "react";
|
||||||
import EditFlowSettings from "../../components/EditFlowSettingsComponent";
|
import EditFlowSettings from "../../components/EditFlowSettingsComponent";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
import { DialogTitle } from "../../components/ui/dialog";
|
|
||||||
import { SETTINGS_DIALOG_SUBTITLE } from "../../constants";
|
import { SETTINGS_DIALOG_SUBTITLE } from "../../constants";
|
||||||
import { alertContext } from "../../contexts/alertContext";
|
import { alertContext } from "../../contexts/alertContext";
|
||||||
import { PopUpContext } from "../../contexts/popUpContext";
|
|
||||||
import { TabsContext } from "../../contexts/tabsContext";
|
import { TabsContext } from "../../contexts/tabsContext";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
|
|
||||||
export default function FlowSettingsModal() {
|
export default function FlowSettingsModal({
|
||||||
const [open, setOpen] = useState(true);
|
open,
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
setOpen,
|
||||||
|
}: {
|
||||||
|
open: boolean;
|
||||||
|
setOpen: (open: boolean) => void;
|
||||||
|
}) {
|
||||||
const { setErrorData, setSuccessData } = useContext(alertContext);
|
const { setErrorData, setSuccessData } = useContext(alertContext);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const { flows, tabId, updateFlow, setTabsState, saveFlow } =
|
const { flows, tabId, updateFlow, setTabsState, saveFlow } =
|
||||||
|
|
@ -21,33 +23,26 @@ export default function FlowSettingsModal() {
|
||||||
const [description, setDescription] = useState(
|
const [description, setDescription] = useState(
|
||||||
flows.find((f) => f.id === tabId).description
|
flows.find((f) => f.id === tabId).description
|
||||||
);
|
);
|
||||||
function setModalOpen(x: boolean) {
|
|
||||||
setOpen(x);
|
|
||||||
if (x === false) {
|
|
||||||
setTimeout(() => {
|
|
||||||
closePopUp();
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
let savedFlow = flows.find((f) => f.id === tabId);
|
let savedFlow = flows.find((f) => f.id === tabId);
|
||||||
savedFlow.name = name;
|
savedFlow.name = name;
|
||||||
savedFlow.description = description;
|
savedFlow.description = description;
|
||||||
saveFlow(savedFlow);
|
saveFlow(savedFlow);
|
||||||
setSuccessData({ title: "Changes saved successfully" });
|
setSuccessData({ title: "Changes saved successfully" });
|
||||||
closePopUp();
|
setOpen(false);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<BaseModal open={true} setOpen={setModalOpen} size="smaller">
|
<BaseModal open={open} setOpen={setOpen} size="smaller">
|
||||||
|
<BaseModal.Trigger>
|
||||||
|
<></>
|
||||||
|
</BaseModal.Trigger>
|
||||||
<BaseModal.Header description={SETTINGS_DIALOG_SUBTITLE}>
|
<BaseModal.Header description={SETTINGS_DIALOG_SUBTITLE}>
|
||||||
<DialogTitle className="flex items-center">
|
<span className="pr-2">Settings</span>
|
||||||
<span className="pr-2">Settings</span>
|
<Settings2
|
||||||
<Settings2
|
strokeWidth={1.5}
|
||||||
strokeWidth={1.5}
|
className="h-6 w-6 pl-1 text-primary "
|
||||||
className="h-6 w-6 pl-1 text-primary "
|
aria-hidden="true"
|
||||||
aria-hidden="true"
|
/>
|
||||||
/>
|
|
||||||
</DialogTitle>
|
|
||||||
</BaseModal.Header>
|
</BaseModal.Header>
|
||||||
<BaseModal.Content>
|
<BaseModal.Content>
|
||||||
<EditFlowSettings
|
<EditFlowSettings
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue