🔧 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
className={
(disabled ? "pointer-events-none cursor-not-allowed" : "") +
"flex flex-col gap-3 py-2"
"flex flex-col gap-3"
}
>
{inputList.map((i, idx) => (

View file

@ -268,7 +268,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
/**
* 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
const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
JSON.stringify(flow)
@ -277,7 +277,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
// create a link element and set its properties
const link = document.createElement("a");
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
link.click();

View file

@ -80,9 +80,9 @@ export default function ExportModal() {
<DialogFooter>
<Button
onClick={() => {
if (checked) downloadFlow(flows.find((f) => f.id === tabId));
if (checked) downloadFlow(flows.find((f) => f.id === tabId), name);
else
downloadFlow(removeApiKeys(flows.find((f) => f.id === tabId)));
downloadFlow(removeApiKeys(flows.find((f) => f.id === tabId)), name);
closePopUp();
}}

View file

@ -11,7 +11,7 @@ export type TabsContextType = {
addFlow: (flowData?: FlowType, newProject?: boolean) => Promise<String>;
updateFlow: (newFlow: FlowType) => void;
incrementNodeId: () => string;
downloadFlow: (flow: FlowType) => void;
downloadFlow: (flow: FlowType, fileName?: string) => void;
downloadFlows: () => void;
uploadFlows: () => void;
uploadFlow: (newFlow?: boolean) => void;