Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions airflow-core/src/airflow/ui/src/pages/Variables/Variables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Flex, HStack, Spacer, VStack } from "@chakra-ui/react";
import { Flex, HStack, Spacer, VStack, useDisclosure } from "@chakra-ui/react";
import type { ColumnDef } from "@tanstack/react-table";
import type { TFunction } from "i18next";
import { useEffect, useMemo, useState } from "react";
Expand All @@ -30,6 +30,7 @@ import { DataTable } from "src/components/DataTable";
import { useRowSelection, type GetColumnsParams } from "src/components/DataTable/useRowSelection";
import { useTableURLState } from "src/components/DataTable/useTableUrlState";
import { ErrorAlert } from "src/components/ErrorAlert";
import { ExpandCollapseButtons } from "src/components/ExpandCollapseButtons";
import { SearchBar } from "src/components/SearchBar";
import { Button, Tooltip } from "src/components/ui";
import { ActionBar } from "src/components/ui/ActionBar";
Expand All @@ -44,13 +45,19 @@ import AddVariableButton from "./ManageVariable/AddVariableButton";
import DeleteVariableButton from "./ManageVariable/DeleteVariableButton";
import EditVariableButton from "./ManageVariable/EditVariableButton";

type ColumnProps = {
readonly open: boolean;
readonly translate: TFunction;
};

const getColumns = ({
allRowsSelected,
onRowSelect,
onSelectAll,
open,
selectedRows,
translate,
}: { translate: TFunction } & GetColumnsParams): Array<ColumnDef<VariableResponse>> => [
}: ColumnProps & GetColumnsParams): Array<ColumnDef<VariableResponse>> => [
{
accessorKey: "select",
cell: ({ row }) => (
Expand Down Expand Up @@ -82,12 +89,24 @@ const getColumns = ({
},
{
accessorKey: "value",
cell: ({ row }) => <TrimText showTooltip text={row.original.value} />,
cell: ({ row }) => (
<TrimText
charLimit={open ? row.original.value.length : undefined}
showTooltip
text={row.original.value}
/>
),
header: translate("columns.value"),
},
{
accessorKey: "description",
cell: ({ row }) => <TrimText showTooltip text={row.original.description} />,
cell: ({ row }) => (
<TrimText
charLimit={open ? row.original.description?.length : undefined}
showTooltip
text={row.original.description}
/>
),
header: translate("columns.description"),
},
{
Expand Down Expand Up @@ -117,6 +136,7 @@ export const Variables = () => {
sorting: [{ desc: false, id: "key" }],
}); // To make multiselection smooth
const [searchParams, setSearchParams] = useSearchParams();
const { onClose, onOpen, open } = useDisclosure();
const { NAME_PATTERN, OFFSET }: SearchParamsKeysType = SearchParamsKeys;
const [variableKeyPattern, setVariableKeyPattern] = useState(searchParams.get(NAME_PATTERN) ?? undefined);
const [selectedVariables, setSelectedVariables] = useState<Record<string, string | undefined>>({});
Expand All @@ -143,10 +163,11 @@ export const Variables = () => {
allRowsSelected,
onRowSelect: handleRowSelect,
onSelectAll: handleSelectAll,
open,
selectedRows,
translate,
}),
[allRowsSelected, handleRowSelect, handleSelectAll, selectedRows, translate],
[allRowsSelected, handleRowSelect, handleSelectAll, open, selectedRows, translate],
);

const handleSearchChange = (value: string) => {
Expand Down Expand Up @@ -199,6 +220,12 @@ export const Variables = () => {
<HStack gap={4} mt={2}>
<ImportVariablesButton disabled={selectedRows.size > 0} />
<Spacer />
<ExpandCollapseButtons
collapseLabel={translate("common:expand.collapse")}
expandLabel={translate("common:expand.expand")}
onCollapse={onClose}
onExpand={onOpen}
/>
<AddVariableButton disabled={selectedRows.size > 0} />
</HStack>
</VStack>
Expand Down