Skip to content

Commit 5764d69

Browse files
authored
UI variables page: added option to view text as multi lines (#61679)
* Variables page added a button to set or unset text trim * ui variable page, fold and expand buttons: * reused expandCollapse component * used useDisclosure instead of useState * affect only the variable.value field * * Variable page fold/expand buttons affect also variable.description * tooltip text fixed * formatting issues resolved
1 parent e87d09e commit 5764d69

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

airflow-core/src/airflow/ui/src/pages/Variables/Variables.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { Box, Flex, HStack, Spacer, VStack } from "@chakra-ui/react";
19+
import { Box, Flex, HStack, Spacer, useDisclosure, VStack } from "@chakra-ui/react";
2020
import type { ColumnDef } from "@tanstack/react-table";
2121
import type { TFunction } from "i18next";
2222
import { useState } from "react";
@@ -29,6 +29,7 @@ import { DataTable } from "src/components/DataTable";
2929
import { useRowSelection, type GetColumnsParams } from "src/components/DataTable/useRowSelection";
3030
import { useTableURLState } from "src/components/DataTable/useTableUrlState";
3131
import { ErrorAlert } from "src/components/ErrorAlert";
32+
import { ExpandCollapseButtons } from "src/components/ExpandCollapseButtons";
3233
import { SearchBar } from "src/components/SearchBar";
3334
import { Tooltip } from "src/components/ui";
3435
import { ActionBar } from "src/components/ui/ActionBar";
@@ -43,14 +44,20 @@ import AddVariableButton from "./ManageVariable/AddVariableButton";
4344
import DeleteVariableButton from "./ManageVariable/DeleteVariableButton";
4445
import EditVariableButton from "./ManageVariable/EditVariableButton";
4546

47+
type ColumnProps = {
48+
readonly open: boolean;
49+
readonly translate: TFunction;
50+
};
51+
4652
const getColumns = ({
4753
allRowsSelected,
4854
multiTeam,
4955
onRowSelect,
5056
onSelectAll,
57+
open,
5158
selectedRows,
5259
translate,
53-
}: { translate: TFunction } & GetColumnsParams): Array<ColumnDef<VariableResponse>> => {
60+
}: ColumnProps & GetColumnsParams): Array<ColumnDef<VariableResponse>> => {
5461
const columns: Array<ColumnDef<VariableResponse>> = [
5562
{
5663
accessorKey: "select",
@@ -83,12 +90,24 @@ const getColumns = ({
8390
},
8491
{
8592
accessorKey: "value",
86-
cell: ({ row }) => <TrimText showTooltip text={row.original.value} />,
93+
cell: ({ row }) => (
94+
<TrimText
95+
charLimit={open ? row.original.value.length : undefined}
96+
showTooltip
97+
text={row.original.value}
98+
/>
99+
),
87100
header: translate("columns.value"),
88101
},
89102
{
90103
accessorKey: "description",
91-
cell: ({ row }) => <TrimText showTooltip text={row.original.description} />,
104+
cell: ({ row }) => (
105+
<TrimText
106+
charLimit={open ? row.original.description?.length : undefined}
107+
showTooltip
108+
text={row.original.description}
109+
/>
110+
),
92111
header: translate("columns.description"),
93112
},
94113
{
@@ -129,6 +148,7 @@ export const Variables = () => {
129148
sorting: [{ desc: false, id: "key" }],
130149
}); // To make multiselection smooth
131150
const [searchParams, setSearchParams] = useSearchParams();
151+
const { onClose, onOpen, open } = useDisclosure();
132152
const { NAME_PATTERN, OFFSET }: SearchParamsKeysType = SearchParamsKeys;
133153
const [variableKeyPattern, setVariableKeyPattern] = useState(searchParams.get(NAME_PATTERN) ?? undefined);
134154
const { pagination, sorting } = tableURLState;
@@ -154,6 +174,7 @@ export const Variables = () => {
154174
multiTeam: multiTeamEnabled,
155175
onRowSelect: handleRowSelect,
156176
onSelectAll: handleSelectAll,
177+
open,
157178
selectedRows,
158179
translate,
159180
});
@@ -184,6 +205,12 @@ export const Variables = () => {
184205
<HStack gap={4} mt={2}>
185206
<ImportVariablesButton disabled={selectedRows.size > 0} />
186207
<Spacer />
208+
<ExpandCollapseButtons
209+
collapseLabel={translate("common:expand.collapse")}
210+
expandLabel={translate("common:expand.expand")}
211+
onCollapse={onClose}
212+
onExpand={onOpen}
213+
/>
187214
<AddVariableButton disabled={selectedRows.size > 0} />
188215
</HStack>
189216
</VStack>

0 commit comments

Comments
 (0)