🔧 fix(inputListComponent): remove unnecessary padding from input list component to improve layout

🔧 fix(tabsContext): add optional fileName parameter to downloadFlow function to allow customizing the downloaded file name
🔧 fix(exportModal): add optional fileName parameter to downloadFlow function calls to allow customizing the downloaded file name
🔧 fix(tabsContext): update downloadFlow function signature to include optional fileName parameter
This commit is contained in:
Cristhian Zanforlin Lousa 2023-06-30 10:52:23 -03:00
commit 7be93653c3
4 changed files with 6 additions and 6 deletions

View file

@ -23,7 +23,7 @@ export default function InputListComponent({
<div <div
className={ className={
(disabled ? "pointer-events-none cursor-not-allowed" : "") + (disabled ? "pointer-events-none cursor-not-allowed" : "") +
"flex flex-col gap-3 py-2" "flex flex-col gap-3"
} }
> >
{inputList.map((i, idx) => ( {inputList.map((i, idx) => (

View file

@ -268,7 +268,7 @@ 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, fileName?: 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)
@ -277,7 +277,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
// 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 = `${fileName && fileName != "" ? fileName : flows.find((f) => f.id === tabId).name}.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();

View file

@ -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);
else else
downloadFlow(removeApiKeys(flows.find((f) => f.id === tabId))); downloadFlow(removeApiKeys(flows.find((f) => f.id === tabId)), name);
closePopUp(); closePopUp();
}} }}

View file

@ -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, fileName?: string) => void;
downloadFlows: () => void; downloadFlows: () => void;
uploadFlows: () => void; uploadFlows: () => void;
uploadFlow: (newFlow?: boolean) => void; uploadFlow: (newFlow?: boolean) => void;