diff --git a/airflow/ui/src/components/ui/ActionButton.tsx b/airflow/ui/src/components/ui/ActionButton.tsx index 9820775223d74..0f921826989b5 100644 --- a/airflow/ui/src/components/ui/ActionButton.tsx +++ b/airflow/ui/src/components/ui/ActionButton.tsx @@ -34,6 +34,7 @@ type Props = { const ActionButton = ({ actionName, colorPalette, + disabled = false, icon, onClick, text, @@ -47,6 +48,7 @@ const ActionButton = ({ ; +}; + +const DeleteVariablesButton = ({ clearSelections, deleteKeys: variableKeys }: Props) => { + const { onClose, onOpen, open } = useDisclosure(); + const { error, isPending, mutate } = useBulkDeleteVariables({ clearSelections, onSuccessConfirm: onClose }); + + return ( + <> + + + + + + + Delete Variable{variableKeys.length > 1 ? "s" : ""} + + + + + + + + You are about to delete{" "} + + {variableKeys.length} variable{variableKeys.length > 1 ? "s" : ""}. + +
+ + {variableKeys.join(", ")} + +
+ This action is permanent and cannot be undone.{" "} + Are you sure you want to proceed? +
+ + + + +
+
+
+ + ); +}; + +export default DeleteVariablesButton; diff --git a/airflow/ui/src/pages/Variables/ImportVariablesButton.tsx b/airflow/ui/src/pages/Variables/ImportVariablesButton.tsx index a662ffb1ea478..4f23d32d77298 100644 --- a/airflow/ui/src/pages/Variables/ImportVariablesButton.tsx +++ b/airflow/ui/src/pages/Variables/ImportVariablesButton.tsx @@ -23,12 +23,16 @@ import { Button, Dialog } from "src/components/ui"; import ImportVariablesForm from "./ImportVariablesForm"; -const ImportVariablesButton = () => { +type Props = { + readonly disabled: boolean; +}; + +const ImportVariablesButton = ({ disabled }: Props) => { const { onClose, onOpen, open } = useDisclosure(); return ( <> - diff --git a/airflow/ui/src/pages/Variables/ManageVariable/AddVariableButton.tsx b/airflow/ui/src/pages/Variables/ManageVariable/AddVariableButton.tsx index 2771ebd2dd485..c3b3c3a551900 100644 --- a/airflow/ui/src/pages/Variables/ManageVariable/AddVariableButton.tsx +++ b/airflow/ui/src/pages/Variables/ManageVariable/AddVariableButton.tsx @@ -24,7 +24,11 @@ import { useAddVariable } from "src/queries/useAddVariable"; import VariableForm, { type VariableBody } from "./VariableForm"; -const AddVariableButton = () => { +type Props = { + readonly disabled: boolean; +}; + +const AddVariableButton = ({ disabled }: Props) => { const { onClose, onOpen, open } = useDisclosure(); const { addVariable, error, isPending, setError } = useAddVariable({ onSuccessConfirm: onClose, @@ -44,7 +48,7 @@ const AddVariableButton = () => { return ( <> - diff --git a/airflow/ui/src/pages/Variables/ManageVariable/DeleteVariableButton.tsx b/airflow/ui/src/pages/Variables/ManageVariable/DeleteVariableButton.tsx index d8d2efbecae70..fab939d73cc28 100644 --- a/airflow/ui/src/pages/Variables/ManageVariable/DeleteVariableButton.tsx +++ b/airflow/ui/src/pages/Variables/ManageVariable/DeleteVariableButton.tsx @@ -25,32 +25,20 @@ import { useDeleteVariable } from "src/queries/useDeleteVariable"; type Props = { readonly deleteKey: string; + readonly disabled: boolean; }; -const DeleteVariableButton = ({ deleteKey: variableKey }: Props) => { +const DeleteVariableButton = ({ deleteKey: variableKey, disabled }: Props) => { const { onClose, onOpen, open } = useDisclosure(); const { isPending, mutate } = useDeleteVariable({ onSuccessConfirm: onClose, }); - const renderDeleteButton = () => ( - - ); - return ( <> } onClick={() => { onOpen(); @@ -70,9 +58,24 @@ const DeleteVariableButton = ({ deleteKey: variableKey }: Props) => { - Are you sure you want to delete the variable key: `{variableKey}`? + + You are about to delete variable with key {variableKey}. +
+ This action is permanent and cannot be undone.{" "} + Are you sure you want to proceed? +
- {renderDeleteButton()} +
diff --git a/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx b/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx index 3fee33d461e2f..5138cefb6fe0a 100644 --- a/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx +++ b/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx @@ -28,10 +28,11 @@ import type { VariableBody } from "./VariableForm"; import VariableForm from "./VariableForm"; type Props = { + readonly disabled: boolean; readonly variable: VariableResponse; }; -const EditVariableButton = ({ variable }: Props) => { +const EditVariableButton = ({ disabled, variable }: Props) => { const { onClose, onOpen, open } = useDisclosure(); const initialVariableValue: VariableBody = { description: variable.description ?? "", @@ -51,6 +52,7 @@ const EditVariableButton = ({ variable }: Props) => { <> } onClick={() => { onOpen(); diff --git a/airflow/ui/src/pages/Variables/Variables.tsx b/airflow/ui/src/pages/Variables/Variables.tsx index 94ae08f760dc2..51a0c8c35cc27 100644 --- a/airflow/ui/src/pages/Variables/Variables.tsx +++ b/airflow/ui/src/pages/Variables/Variables.tsx @@ -19,7 +19,7 @@ import { Box, Flex, HStack, Spacer, VStack } from "@chakra-ui/react"; import type { ColumnDef } from "@tanstack/react-table"; import { useMemo, useState } from "react"; -import { FiShare, FiTrash2 } from "react-icons/fi"; +import { FiShare } from "react-icons/fi"; import { useSearchParams } from "react-router-dom"; import { useVariableServiceGetVariables } from "openapi/queries"; @@ -35,6 +35,7 @@ import { Checkbox } from "src/components/ui/Checkbox"; import { SearchParamsKeys, type SearchParamsKeysType } from "src/constants/searchParams"; import { TrimText } from "src/utils/TrimText"; +import DeleteVariablesButton from "./DeleteVariablesButton"; import ImportVariablesButton from "./ImportVariablesButton"; import AddVariableButton from "./ManageVariable/AddVariableButton"; import DeleteVariableButton from "./ManageVariable/DeleteVariableButton"; @@ -51,12 +52,17 @@ const getColumns = ({ cell: ({ row }) => ( onRowSelect(row.original.key, Boolean(event.checked))} /> ), enableSorting: false, header: () => ( - onSelectAll(Boolean(event.checked))} /> + onSelectAll(Boolean(event.checked))} + /> ), meta: { skeletonWidth: 10, @@ -85,8 +91,8 @@ const getColumns = ({ accessorKey: "actions", cell: ({ row: { original } }) => ( - - + 0} variable={original} /> + 0} /> ), enableSorting: false, @@ -98,7 +104,9 @@ const getColumns = ({ ]; export const Variables = () => { - const { setTableURLState, tableURLState } = useTableURLState(); + const { setTableURLState, tableURLState } = useTableURLState({ + pagination: { pageIndex: 0, pageSize: 30 }, + }); // To make multiselection smooth const [searchParams, setSearchParams] = useSearchParams(); const { NAME_PATTERN: NAME_PATTERN_PARAM }: SearchParamsKeysType = SearchParamsKeys; const [variableKeyPattern, setVariableKeyPattern] = useState( @@ -156,9 +164,9 @@ export const Variables = () => { placeHolder="Search Keys" /> - + 0} /> - + 0} /> @@ -178,12 +186,9 @@ export const Variables = () => { {selectedRows.size} selected - {/* TODO: Implement the delete and export selected */} - - + {/* TODO: Implement the export selected */} + +