Fixed saving issue and implemented saved message
This commit is contained in:
parent
4a89470cee
commit
b2598165a6
2 changed files with 62 additions and 55 deletions
|
|
@ -43,14 +43,7 @@ export const MenuBar = ({flows, tabId }) => {
|
||||||
const { openPopUp } = useContext(PopUpContext);
|
const { openPopUp } = useContext(PopUpContext);
|
||||||
const { undo, redo } = useContext(undoRedoContext);
|
const { undo, redo } = useContext(undoRedoContext);
|
||||||
|
|
||||||
function handleSaveFlow(flow) {
|
|
||||||
try {
|
|
||||||
updateFlowInDatabase(flow);
|
|
||||||
// updateFlowStyleInDataBase(flow);
|
|
||||||
} catch (err) {
|
|
||||||
setErrorData(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleAddFlow() {
|
function handleAddFlow() {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
import { Bars2Icon, PencilSquareIcon, Square2StackIcon, TrashIcon } from "@heroicons/react/24/outline";
|
import {
|
||||||
|
Bars2Icon,
|
||||||
|
PencilSquareIcon,
|
||||||
|
Square2StackIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from "@heroicons/react/24/outline";
|
||||||
import DisclosureComponent from "../DisclosureComponent";
|
import DisclosureComponent from "../DisclosureComponent";
|
||||||
import {
|
import {
|
||||||
classNames,
|
classNames,
|
||||||
|
|
@ -18,11 +23,14 @@ import ExportModal from "../../../../modals/exportModal";
|
||||||
import ApiModal from "../../../../modals/ApiModal";
|
import ApiModal from "../../../../modals/ApiModal";
|
||||||
import { TabsContext } from "../../../../contexts/tabsContext";
|
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||||
import { Separator } from "../../../../components/ui/separator";
|
import { Separator } from "../../../../components/ui/separator";
|
||||||
|
import { alertContext } from "../../../../contexts/alertContext";
|
||||||
|
import { updateFlowInDatabase } from "../../../../controllers/API";
|
||||||
|
|
||||||
export default function ExtraSidebar() {
|
export default function ExtraSidebar() {
|
||||||
const { data } = useContext(typesContext);
|
const { data } = useContext(typesContext);
|
||||||
const { openPopUp } = useContext(PopUpContext);
|
const { openPopUp } = useContext(PopUpContext);
|
||||||
const { flows, tabId } = useContext(TabsContext);
|
const { flows, tabId } = useContext(TabsContext);
|
||||||
|
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||||
const [dataFilter, setFilterData] = useState(data);
|
const [dataFilter, setFilterData] = useState(data);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
||||||
|
|
@ -57,57 +65,65 @@ export default function ExtraSidebar() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveFlow(current_flow: any) {
|
function handleSaveFlow(flow) {
|
||||||
throw new Error("Function not implemented.");
|
try {
|
||||||
|
updateFlowInDatabase(flow);
|
||||||
|
// updateFlowStyleInDataBase(flow);
|
||||||
|
} catch (err) {
|
||||||
|
setErrorData(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col overflow-hidden scrollbar-hide h-full border-r">
|
<div className="flex flex-col overflow-hidden scrollbar-hide h-full border-r">
|
||||||
<div className="mt-2 mb-2 w-full flex gap-2 justify-between px-2 items-center">
|
<div className="mt-2 mb-2 w-full flex gap-2 justify-between px-2 items-center">
|
||||||
<ShadTooltip delayDuration={1000} content="Import" side="top">
|
<ShadTooltip delayDuration={1000} content="Import" side="top">
|
||||||
<button
|
<button
|
||||||
className="hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center shadow-sm transition-all duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center rounded-md bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
className="hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center shadow-sm transition-all duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center rounded-md bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(<ImportModal />);
|
openPopUp(<ImportModal />);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FileUp className="w-5 h-5 dark:text-gray-300"></FileUp>
|
<FileUp className="w-5 h-5 dark:text-gray-300"></FileUp>
|
||||||
</button>
|
</button>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
|
|
||||||
<ShadTooltip delayDuration={1000} content="Export" side="top">
|
<ShadTooltip delayDuration={1000} content="Export" side="top">
|
||||||
<button
|
<button
|
||||||
className={classNames("hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center shadow-sm transition-all duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 rounded-md"
|
className={classNames(
|
||||||
)}
|
"hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center shadow-sm transition-all duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 rounded-md"
|
||||||
onClick={(event) => {
|
)}
|
||||||
openPopUp(<ExportModal />);
|
onClick={(event) => {
|
||||||
}}
|
openPopUp(<ExportModal />);
|
||||||
>
|
}}
|
||||||
<FileDown className="w-5 h-5 dark:text-gray-300"></FileDown>
|
>
|
||||||
</button>
|
<FileDown className="w-5 h-5 dark:text-gray-300"></FileDown>
|
||||||
</ShadTooltip>
|
</button>
|
||||||
<ShadTooltip delayDuration={1000} content="Code" side="top">
|
</ShadTooltip>
|
||||||
<button
|
<ShadTooltip delayDuration={1000} content="Code" side="top">
|
||||||
className={classNames("hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center shadow-sm transition-all duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 rounded-md"
|
<button
|
||||||
)}
|
className={classNames(
|
||||||
onClick={(event) => {
|
"hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center shadow-sm transition-all duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 rounded-md"
|
||||||
openPopUp(<ApiModal flow={flows.find((f) => f.id === tabId)} />);
|
)}
|
||||||
}}
|
onClick={(event) => {
|
||||||
>
|
openPopUp(<ApiModal flow={flows.find((f) => f.id === tabId)} />);
|
||||||
<Code2 className="w-5 h-5 dark:text-gray-300"></Code2>
|
}}
|
||||||
</button>
|
>
|
||||||
</ShadTooltip>
|
<Code2 className="w-5 h-5 dark:text-gray-300"></Code2>
|
||||||
|
</button>
|
||||||
|
</ShadTooltip>
|
||||||
|
|
||||||
<ShadTooltip delayDuration={1000} content="Save" side="top">
|
<ShadTooltip delayDuration={1000} content="Save" side="top">
|
||||||
<button
|
<button
|
||||||
className="hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center transition-all shadow-sm duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 rounded-md"
|
className="hover:dark:hover:bg-[#242f47] text-gray-700 w-full justify-center transition-all shadow-sm duration-500 ease-in-out dark:bg-gray-800 dark:text-gray-300 relative inline-flex items-center bg-white px-2 py-2 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 rounded-md"
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
handleSaveFlow(flows.find((f) => f.id === tabId));
|
handleSaveFlow(flows.find((f) => f.id === tabId));
|
||||||
}}
|
setSuccessData({ title: "Changes saved successfully" });
|
||||||
>
|
}}
|
||||||
<Save className="w-5 h-5 dark:text-gray-300"></Save>
|
>
|
||||||
</button>
|
<Save className="w-5 h-5 dark:text-gray-300"></Save>
|
||||||
</ShadTooltip>
|
</button>
|
||||||
|
</ShadTooltip>
|
||||||
</div>
|
</div>
|
||||||
<Separator />
|
<Separator />
|
||||||
<div className="relative mt-2 flex items-center mb-2 mx-2">
|
<div className="relative mt-2 flex items-center mb-2 mx-2">
|
||||||
|
|
@ -127,8 +143,6 @@ export default function ExtraSidebar() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="w-full overflow-auto scrollbar-hide">
|
<div className="w-full overflow-auto scrollbar-hide">
|
||||||
{Object.keys(dataFilter)
|
{Object.keys(dataFilter)
|
||||||
.sort()
|
.sort()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue