feat(tabsContext.tsx): add support for flow name and description in downloadFlow function to customize downloaded file name and content
fix(exportModal/index.tsx): update downloadFlow function calls to include flow name and description parameters fix(types/tabs/index.ts): update downloadFlow function signature to include flow name and description parameters
This commit is contained in:
parent
c544591f33
commit
369a4a59ca
3 changed files with 7 additions and 7 deletions
|
|
@ -275,16 +275,16 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
/**
|
/**
|
||||||
* Downloads the current flow as a JSON file
|
* Downloads the current flow as a JSON file
|
||||||
*/
|
*/
|
||||||
function downloadFlow(flow: FlowType) {
|
function downloadFlow(flow: FlowType,flowName:string,flowDescription?:string) {
|
||||||
// create a data URI with the current flow data
|
// create a data URI with the current flow data
|
||||||
const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
|
const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
|
||||||
JSON.stringify(flow)
|
JSON.stringify({...flow, name:flowName, description:flowDescription})
|
||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
// create a link element and set its properties
|
// create a link element and set its properties
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.href = jsonString;
|
link.href = jsonString;
|
||||||
link.download = `${flows.find((f) => f.id === tabId).name}.json`;
|
link.download = `${flowName}.json`;
|
||||||
|
|
||||||
// simulate a click on the link element to trigger the download
|
// simulate a click on the link element to trigger the download
|
||||||
link.click();
|
link.click();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export default function ExportModal() {
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
const { closePopUp } = useContext(PopUpContext);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
const { flows, tabId, updateFlow, downloadFlow } = useContext(TabsContext);
|
const { flows, tabId, updateFlow, downloadFlow,saveFlow } = useContext(TabsContext);
|
||||||
const [isMaxLength, setIsMaxLength] = useState(false);
|
const [isMaxLength, setIsMaxLength] = useState(false);
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean) {
|
||||||
setOpen(x);
|
setOpen(x);
|
||||||
|
|
@ -80,9 +80,9 @@ export default function ExportModal() {
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (checked) downloadFlow(flows.find((f) => f.id === tabId));
|
if (checked) downloadFlow(flows.find((f) => f.id === tabId),name,description);
|
||||||
else
|
else
|
||||||
downloadFlow(removeApiKeys(flows.find((f) => f.id === tabId)));
|
downloadFlow(removeApiKeys(flows.find((f) => f.id === tabId)),name,description);
|
||||||
|
|
||||||
closePopUp();
|
closePopUp();
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export type TabsContextType = {
|
||||||
addFlow: (flowData?: FlowType, newProject?: boolean) => Promise<String>;
|
addFlow: (flowData?: FlowType, newProject?: boolean) => Promise<String>;
|
||||||
updateFlow: (newFlow: FlowType) => void;
|
updateFlow: (newFlow: FlowType) => void;
|
||||||
incrementNodeId: () => string;
|
incrementNodeId: () => string;
|
||||||
downloadFlow: (flow: FlowType) => void;
|
downloadFlow: (flow: FlowType,flowName:string,flowDescription?:string) => void;
|
||||||
downloadFlows: () => void;
|
downloadFlows: () => void;
|
||||||
uploadFlows: () => void;
|
uploadFlows: () => void;
|
||||||
uploadFlow: (newFlow?: boolean) => void;
|
uploadFlow: (newFlow?: boolean) => void;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue