fix: detect unsaved changes in FlowPage Component to enable save button when auto-save is off (nightly fix) (#7668)
This commit is contained in:
parent
dc35b4ec9e
commit
b6f54ee681
10 changed files with 16 additions and 13 deletions
|
|
@ -21,7 +21,7 @@ import { UPLOAD_ERROR_ALERT } from "@/constants/alerts_constants";
|
||||||
import { SAVED_HOVER } from "@/constants/constants";
|
import { SAVED_HOVER } from "@/constants/constants";
|
||||||
import { useGetRefreshFlowsQuery } from "@/controllers/API/queries/flows/use-get-refresh-flows-query";
|
import { useGetRefreshFlowsQuery } from "@/controllers/API/queries/flows/use-get-refresh-flows-query";
|
||||||
import { useGetFoldersQuery } from "@/controllers/API/queries/folders/use-get-folders";
|
import { useGetFoldersQuery } from "@/controllers/API/queries/folders/use-get-folders";
|
||||||
import { useUnsavedChanges } from "@/hooks/useUnsavedChanges";
|
import { useUnsavedChanges } from "@/hooks/use-unsaved-changes";
|
||||||
import ExportModal from "@/modals/exportModal";
|
import ExportModal from "@/modals/exportModal";
|
||||||
import FlowLogsModal from "@/modals/flowLogsModal";
|
import FlowLogsModal from "@/modals/flowLogsModal";
|
||||||
import FlowSettingsModal from "@/modals/flowSettingsModal";
|
import FlowSettingsModal from "@/modals/flowSettingsModal";
|
||||||
|
|
@ -535,7 +535,7 @@ export const MenuBar = ({}: {}): JSX.Element => {
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
<a
|
<a
|
||||||
href="https://docs.langflow.org/configuration-auto-save"
|
href="https://docs.langflow.org/configuration-auto-save"
|
||||||
className="text-primary underline"
|
className="text-secondary underline"
|
||||||
>
|
>
|
||||||
Enable auto-saving
|
Enable auto-saving
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ export default function Dropdown({
|
||||||
dialogInputs,
|
dialogInputs,
|
||||||
handleOnNewValue,
|
handleOnNewValue,
|
||||||
toggle,
|
toggle,
|
||||||
|
hasRefreshButton,
|
||||||
...baseInputProps
|
...baseInputProps
|
||||||
}: BaseInputProps & DropDownComponent): JSX.Element {
|
}: BaseInputProps & DropDownComponent): JSX.Element {
|
||||||
const validOptions = useMemo(
|
const validOptions = useMemo(
|
||||||
|
|
@ -236,7 +237,10 @@ export default function Dropdown({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className="flex w-full items-center gap-2 overflow-hidden"
|
className={cn(
|
||||||
|
"flex w-full items-center gap-2 overflow-hidden",
|
||||||
|
hasRefreshButton && "max-w-[11rem]",
|
||||||
|
)}
|
||||||
data-testid={`value-dropdown-${id}`}
|
data-testid={`value-dropdown-${id}`}
|
||||||
>
|
>
|
||||||
{optionsMetaData?.[
|
{optionsMetaData?.[
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export default function DropdownComponent({
|
||||||
toggle,
|
toggle,
|
||||||
toggleValue,
|
toggleValue,
|
||||||
toggleDisable,
|
toggleDisable,
|
||||||
|
hasRefreshButton,
|
||||||
...baseInputProps
|
...baseInputProps
|
||||||
}: InputProps<string, DropDownComponentType>) {
|
}: InputProps<string, DropDownComponentType>) {
|
||||||
const onChange = (value: any, dbValue?: boolean, skipSnapshot?: boolean) => {
|
const onChange = (value: any, dbValue?: boolean, skipSnapshot?: boolean) => {
|
||||||
|
|
@ -43,6 +44,7 @@ export default function DropdownComponent({
|
||||||
name={name}
|
name={name}
|
||||||
dialogInputs={dialogInputs}
|
dialogInputs={dialogInputs}
|
||||||
handleOnNewValue={handleOnNewValue}
|
handleOnNewValue={handleOnNewValue}
|
||||||
|
hasRefreshButton={hasRefreshButton}
|
||||||
{...baseInputProps}
|
{...baseInputProps}
|
||||||
/>
|
/>
|
||||||
{toggle && toggleDisable !== true ? (
|
{toggle && toggleDisable !== true ? (
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ export function StrRenderComponent({
|
||||||
toggle={templateData.toggle}
|
toggle={templateData.toggle}
|
||||||
toggleValue={templateData.toggle_value}
|
toggleValue={templateData.toggle_value}
|
||||||
toggleDisable={templateData.toggle_disable}
|
toggleDisable={templateData.toggle_disable}
|
||||||
|
hasRefreshButton={templateData.refresh_button}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,5 @@ export function useUnsavedChanges() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((currentFlow?.data?.nodes?.length ?? 0) > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return customStringify(currentFlow) !== customStringify(savedFlow);
|
return customStringify(currentFlow) !== customStringify(savedFlow);
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ export function SaveChangesModal({
|
||||||
Unsaved changes will be permanently lost.{" "}
|
Unsaved changes will be permanently lost.{" "}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="underline"
|
className="text-secondary underline"
|
||||||
href="https://docs.langflow.org/configuration-auto-save"
|
href="https://docs.langflow.org/configuration-auto-save"
|
||||||
>
|
>
|
||||||
Enable auto-saving
|
Enable auto-saving
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import CustomLoader from "@/customization/components/custom-loader";
|
||||||
import { track } from "@/customization/utils/analytics";
|
import { track } from "@/customization/utils/analytics";
|
||||||
import useAutoSaveFlow from "@/hooks/flows/use-autosave-flow";
|
import useAutoSaveFlow from "@/hooks/flows/use-autosave-flow";
|
||||||
import useUploadFlow from "@/hooks/flows/use-upload-flow";
|
import useUploadFlow from "@/hooks/flows/use-upload-flow";
|
||||||
import { useAddComponent } from "@/hooks/useAddComponent";
|
import { useAddComponent } from "@/hooks/use-add-component";
|
||||||
import { nodeColorsName } from "@/utils/styleUtils";
|
import { nodeColorsName } from "@/utils/styleUtils";
|
||||||
import { cn, isSupportedNodeTypes } from "@/utils/utils";
|
import { cn, isSupportedNodeTypes } from "@/utils/utils";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { convertTestName } from "@/components/common/storeCardComponent/utils/co
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import useDeleteFlow from "@/hooks/flows/use-delete-flow";
|
import useDeleteFlow from "@/hooks/flows/use-delete-flow";
|
||||||
import { useAddComponent } from "@/hooks/useAddComponent";
|
import { useAddComponent } from "@/hooks/use-add-component";
|
||||||
import { DragEventHandler, forwardRef, useRef, useState } from "react";
|
import { DragEventHandler, forwardRef, useRef, useState } from "react";
|
||||||
import IconComponent, {
|
import IconComponent, {
|
||||||
ForwardedIconComponent,
|
ForwardedIconComponent,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
useSidebar,
|
useSidebar,
|
||||||
} from "@/components/ui/sidebar";
|
} from "@/components/ui/sidebar";
|
||||||
import SkeletonGroup from "@/components/ui/skeletonGroup";
|
import SkeletonGroup from "@/components/ui/skeletonGroup";
|
||||||
import { useAddComponent } from "@/hooks/useAddComponent";
|
import { useAddComponent } from "@/hooks/use-add-component";
|
||||||
import { useShortcutsStore } from "@/stores/shortcuts";
|
import { useShortcutsStore } from "@/stores/shortcuts";
|
||||||
import { useStoreStore } from "@/stores/storeStore";
|
import { useStoreStore } from "@/stores/storeStore";
|
||||||
import { checkChatInput, checkWebhookInput } from "@/utils/reactflowUtils";
|
import { checkChatInput, checkWebhookInput } from "@/utils/reactflowUtils";
|
||||||
|
|
@ -43,8 +43,8 @@ const BUNDLES = SIDEBAR_BUNDLES;
|
||||||
|
|
||||||
interface FlowSidebarComponentProps {
|
interface FlowSidebarComponentProps {
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
showLegacy: boolean;
|
showLegacy?: boolean;
|
||||||
setShowLegacy: (value: boolean) => void;
|
setShowLegacy?: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FlowSidebarComponent({ isLoading }: FlowSidebarComponentProps) {
|
export function FlowSidebarComponent({ isLoading }: FlowSidebarComponentProps) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue