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" ;
2020import type { ColumnDef } from "@tanstack/react-table" ;
2121import type { TFunction } from "i18next" ;
2222import { useState } from "react" ;
@@ -29,6 +29,7 @@ import { DataTable } from "src/components/DataTable";
2929import { useRowSelection , type GetColumnsParams } from "src/components/DataTable/useRowSelection" ;
3030import { useTableURLState } from "src/components/DataTable/useTableUrlState" ;
3131import { ErrorAlert } from "src/components/ErrorAlert" ;
32+ import { ExpandCollapseButtons } from "src/components/ExpandCollapseButtons" ;
3233import { SearchBar } from "src/components/SearchBar" ;
3334import { Tooltip } from "src/components/ui" ;
3435import { ActionBar } from "src/components/ui/ActionBar" ;
@@ -43,14 +44,20 @@ import AddVariableButton from "./ManageVariable/AddVariableButton";
4344import DeleteVariableButton from "./ManageVariable/DeleteVariableButton" ;
4445import EditVariableButton from "./ManageVariable/EditVariableButton" ;
4546
47+ type ColumnProps = {
48+ readonly open : boolean ;
49+ readonly translate : TFunction ;
50+ } ;
51+
4652const 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