-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ integrate column management feature into apps table (#1767)
Resolves #1765 --------- Signed-off-by: Ian Bolton <ibolton@redhat.com>
- Loading branch information
1 parent
b966e22
commit c2361a9
Showing
34 changed files
with
394 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
client/src/app/hooks/table-controls/column/useColumnState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useLocalStorage } from "@migtools/lib-ui"; | ||
|
||
export interface ColumnState<TColumnKey extends string> { | ||
id: TColumnKey; | ||
label: string; | ||
isVisible: boolean; | ||
} | ||
|
||
export interface IColumnState<TColumnKey extends string> { | ||
columns: ColumnState<TColumnKey>[]; | ||
setColumns: (newColumns: ColumnState<TColumnKey>[]) => void; | ||
} | ||
|
||
interface IColumnStateArgs<TColumnKey extends string> { | ||
initialColumns: ColumnState<TColumnKey>[]; | ||
columnsKey: string; | ||
} | ||
|
||
export const useColumnState = <TColumnKey extends string>( | ||
args: IColumnStateArgs<TColumnKey> | ||
): IColumnState<TColumnKey> => { | ||
const [columns, setColumns] = useLocalStorage<ColumnState<TColumnKey>[]>({ | ||
key: args.columnsKey, | ||
defaultValue: args.initialColumns, | ||
}); | ||
|
||
return { columns, setColumns }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.