@devtron-labs/devtron-fe-common-lib 1.10.8 → 1.10.9-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{@code-editor-D7ZRptJX.js → @code-editor-CpmCW1QX.js} +8203 -7616
  2. package/dist/{@common-rjsf-ChTpxn4v.js → @common-rjsf-D28-wZG-.js} +1 -1
  3. package/dist/Common/Constants.d.ts +1 -0
  4. package/dist/Common/Hooks/UseRegisterShortcut/types.d.ts +14 -0
  5. package/dist/Common/Hooks/UseRegisterShortcut/utils.d.ts +1 -1
  6. package/dist/Common/Hooks/useStateFilters/types.d.ts +1 -1
  7. package/dist/Common/Hooks/useUrlFilters/types.d.ts +4 -3
  8. package/dist/Common/Hooks/useUrlFilters/useUrlFilters.d.ts +1 -1
  9. package/dist/Common/Hooks/useUrlFilters/utils.d.ts +1 -0
  10. package/dist/Shared/Components/ConfirmationModal/index.d.ts +1 -1
  11. package/dist/Shared/Components/DatePicker/constants.d.ts +0 -9
  12. package/dist/Shared/Components/ReactSelect/constants.d.ts +11 -0
  13. package/dist/Shared/Components/SelectPicker/SelectPicker.component.d.ts +1 -1
  14. package/dist/Shared/Components/SelectPicker/type.d.ts +7 -1
  15. package/dist/Shared/Components/Table/BulkSelectionActionWidget.d.ts +3 -0
  16. package/dist/Shared/Components/Table/InternalTable.d.ts +3 -0
  17. package/dist/Shared/Components/Table/Table.component.d.ts +3 -0
  18. package/dist/Shared/Components/Table/constants.d.ts +7 -0
  19. package/dist/Shared/Components/Table/index.d.ts +3 -0
  20. package/dist/Shared/Components/Table/types.d.ts +193 -0
  21. package/dist/Shared/Components/Table/useTableWithKeyboardShortcuts.d.ts +6 -0
  22. package/dist/Shared/Components/Table/utils.d.ts +6 -0
  23. package/dist/Shared/Components/index.d.ts +1 -0
  24. package/dist/Shared/Hooks/index.d.ts +1 -0
  25. package/dist/Shared/Hooks/useUserPreferences/index.d.ts +4 -0
  26. package/dist/Shared/Hooks/useUserPreferences/service.d.ts +30 -0
  27. package/dist/Shared/Hooks/useUserPreferences/types.d.ts +60 -0
  28. package/dist/Shared/Hooks/useUserPreferences/useUserPrefrences.d.ts +10 -0
  29. package/dist/Shared/Services/common.service.d.ts +1 -3
  30. package/dist/Shared/Services/types.d.ts +5 -30
  31. package/dist/Shared/constants.d.ts +12 -0
  32. package/dist/Shared/types.d.ts +0 -4
  33. package/dist/assets/@code-editor.css +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +657 -646
  36. package/package.json +1 -1
  37. /package/dist/Shared/{Services → Hooks/useUserPreferences}/constants.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import { j as n, au as y, aw as k, av as W } from "./@vendor-DZHtXPTX.js";
2
2
  import V, { forwardRef as J, useMemo as P } from "react";
3
3
  import K, { getDefaultRegistry as q } from "@rjsf/core";
4
- import { T as F, j as N, c as v, b as S, a as Y, i as z, d as w, e as E, S as G } from "./@code-editor-D7ZRptJX.js";
4
+ import { T as F, j as N, c as v, b as S, a as Y, i as z, d as w, e as E, S as G } from "./@code-editor-CpmCW1QX.js";
5
5
  import Q, { components as D } from "react-select";
6
6
  import { ReactComponent as X } from "./assets/ic-chevron-down.fc70d7a7.svg";
7
7
  import { getUiOptions as B, getTemplate as $, getSubmitButtonOptions as Z, ADDITIONAL_PROPERTY_FLAG as L, errorId as ee, englishStringTranslator as te, TranslatableString as ne, titleId as re, canExpand as se, deepEquals as ae } from "@rjsf/utils";
@@ -90,6 +90,7 @@ export declare const ROUTES: {
90
90
  readonly ATTRIBUTES_USER: "attributes/user";
91
91
  readonly GET: "get";
92
92
  readonly UPDATE: "update";
93
+ readonly PATCH: "patch";
93
94
  readonly ENVIRONMENT_LIST_MIN: "env/autocomplete";
94
95
  readonly CLUSTER: "cluster";
95
96
  readonly API_RESOURCE: "k8s/api-resources";
@@ -7,8 +7,22 @@ export declare const KEYBOARD_KEYS_MAP: {
7
7
  readonly E: "E";
8
8
  readonly R: "R";
9
9
  readonly K: "K";
10
+ readonly X: "X";
11
+ readonly A: "A";
10
12
  readonly Escape: "Esc";
11
13
  readonly Enter: "↩";
14
+ readonly ArrowLeft: "←";
15
+ readonly ArrowRight: "→";
16
+ readonly ArrowUp: "↑";
17
+ readonly ArrowDown: "↓";
18
+ readonly PageUp: "PgUp";
19
+ readonly PageDown: "PgDn";
20
+ readonly Home: "Home";
21
+ readonly End: "End";
22
+ readonly Backspace: "⌫";
23
+ readonly Delete: "⌦";
24
+ readonly '.': ".";
25
+ readonly Space: "Space";
12
26
  };
13
27
  export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP;
14
28
  export interface ShortcutType {
@@ -1,6 +1,6 @@
1
1
  import { ShortcutType } from './types';
2
2
  export declare const preprocessKeys: (keys: ShortcutType["keys"]) => {
3
- keys: ("Escape" | "Control" | "Alt" | "F" | "E" | "R" | "K" | "Shift" | "Meta" | "Enter")[];
3
+ keys: ("Escape" | "Control" | "Alt" | "F" | "E" | "R" | "K" | "X" | "A" | "Home" | "End" | "." | "Space" | "Shift" | "Meta" | "Enter" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "ArrowDown" | "PageUp" | "PageDown" | "Backspace" | "Delete")[];
4
4
  id: string;
5
5
  };
6
6
  export declare const verifyCallbackStack: (stack: ShortcutType["callbackStack"]) => void;
@@ -1,7 +1,7 @@
1
1
  import { UseUrlFiltersProps, UseUrlFiltersReturnType } from '../useUrlFilters';
2
2
  export interface UseStateFiltersProps<T> extends Pick<UseUrlFiltersProps<T, never>, 'initialSortKey'> {
3
3
  }
4
- export interface UseStateFiltersReturnType<T> extends Pick<UseUrlFiltersReturnType<T>, 'sortBy' | 'sortOrder' | 'handleSorting' | 'clearFilters' | 'changePage' | 'changePageSize' | 'offset' | 'pageSize' | 'searchKey' | 'handleSearch'> {
4
+ export interface UseStateFiltersReturnType<T> extends Pick<UseUrlFiltersReturnType<T>, 'sortBy' | 'sortOrder' | 'handleSorting' | 'clearFilters' | 'changePage' | 'changePageSize' | 'offset' | 'pageSize' | 'searchKey' | 'handleSearch' | 'isFilterApplied'> {
5
5
  }
6
6
  export interface PaginationType<T> extends Pick<UseUrlFiltersReturnType<T>, 'pageSize'> {
7
7
  pageNumber: number;
@@ -1,5 +1,5 @@
1
1
  import { SortingOrder } from '../../Constants';
2
- export interface UseUrlFiltersProps<T, K> {
2
+ export interface UseUrlFiltersProps<T, K extends {}> {
3
3
  /**
4
4
  * The key on which the sorting should be applied
5
5
  */
@@ -19,8 +19,8 @@ export interface UseUrlFiltersProps<T, K> {
19
19
  */
20
20
  redirectionMethod?: 'replace' | 'push';
21
21
  }
22
- export type UpdateSearchParamsOptionsType<T, K = unknown> = Partial<Pick<UseUrlFiltersProps<T, K>, 'redirectionMethod'>>;
23
- export type UseUrlFiltersReturnType<T, K = unknown> = K & {
22
+ export type UpdateSearchParamsOptionsType<T, K = {}> = Partial<Pick<UseUrlFiltersProps<T, K>, 'redirectionMethod'>>;
23
+ export type UseUrlFiltersReturnType<T, K = {}> = K & {
24
24
  /**
25
25
  * Currently applied page size
26
26
  */
@@ -67,4 +67,5 @@ export type UseUrlFiltersReturnType<T, K = unknown> = K & {
67
67
  * Update the search params with the passed object
68
68
  */
69
69
  updateSearchParams: (paramsToSerialize: Partial<K>, options?: UpdateSearchParamsOptionsType<T, K>) => void;
70
+ isFilterApplied: boolean;
70
71
  };
@@ -16,5 +16,5 @@ import { UseUrlFiltersProps, UseUrlFiltersReturnType } from './types';
16
16
  * ```
17
17
  *
18
18
  */
19
- declare const useUrlFilters: <T = string, K = unknown>({ initialSortKey, parseSearchParams, localStorageKey, redirectionMethod, }?: UseUrlFiltersProps<T, K>) => UseUrlFiltersReturnType<T, K>;
19
+ declare const useUrlFilters: <T = string, K = {}>({ initialSortKey, parseSearchParams, localStorageKey, redirectionMethod, }?: UseUrlFiltersProps<T, K>) => UseUrlFiltersReturnType<T, K>;
20
20
  export default useUrlFilters;
@@ -1 +1,2 @@
1
1
  export declare const setItemInLocalStorageIfKeyExists: (localStorageKey: string, value: string) => void;
2
+ export declare const areAnyAdditionalFiltersApplied: (parsedParams: Record<string | number, any>) => boolean;
@@ -2,5 +2,5 @@ export { default as ConfirmationModal, BaseConfirmationModal } from './Confirmat
2
2
  export { DeleteConfirmationModal } from './DeleteConfirmationModal';
3
3
  export { ForceDeleteConfirmationModal } from './ForceDeleteConfirmationModal';
4
4
  export { CannotDeleteModal } from './CannotDeleteModal';
5
- export { ConfirmationModalVariantType, type ConfirmationModalProps } from './types';
5
+ export { ConfirmationModalVariantType, type ConfirmationModalProps, type DeleteConfirmationModalProps } from './types';
6
6
  export { ConfirmationModalProvider } from './ConfirmationModalContext';
@@ -132,12 +132,3 @@ export declare const DATE_PICKER_IDS: {
132
132
  MONTH: string;
133
133
  TIME: string;
134
134
  };
135
- export declare const reactSelectStyles: {
136
- container: (base: any) => any;
137
- control: (base: any, state: any) => any;
138
- valueContainer: (base: any) => any;
139
- input: (base: any) => any;
140
- dropdownIndicator: (base: any, state: any) => any;
141
- option: (base: any) => any;
142
- menuList: (base: any) => any;
143
- };
@@ -2,6 +2,17 @@ import { DropdownIndicatorProps, StylesConfig } from 'react-select';
2
2
  export declare const CommonGroupedDropdownStyles: StylesConfig;
3
3
  export declare const APP_SELECTOR_STYLES: StylesConfig;
4
4
  export declare const AppSelectorDropdownIndicator: (props: DropdownIndicatorProps) => JSX.Element;
5
+ /**
6
+ *
7
+ * @returns {string}
8
+ * @description Returns the no matching result text for the select component.
9
+ */
10
+ export declare const getNoMatchingResultText: () => string;
11
+ /**
12
+ * @param inputObj
13
+ * @returns {string}
14
+ * @description Returns the no options message for the select component.
15
+ */
5
16
  export declare const AppSelectorNoOptionsMessage: (inputObj: {
6
17
  inputValue: string;
7
18
  }) => string;
@@ -133,5 +133,5 @@ import { SelectPickerProps } from './type';
133
133
  * />
134
134
  * ```
135
135
  */
136
- declare const SelectPicker: <OptionValue, IsMulti extends boolean>({ error, icon, helperText, placeholder, label, showSelectedOptionIcon, size, disabledTippyContent, showSelectedOptionsCount, menuSize, optionListError, reloadOptionList, menuPosition, variant, disableDescriptionEllipsis, multiSelectProps, isMulti, name, classNamePrefix, shouldRenderCustomOptions, isSearchable, selectRef: refFromConsumer, shouldMenuAlignRight, fullWidth, customSelectedOptionsCount, menuListFooterConfig, isCreatable, onCreateOption, closeMenuOnSelect, shouldShowNoOptionsMessage, shouldRenderTextArea, onKeyDown, shouldHideMenu, warningText, layout, ariaLabel, borderConfig, borderRadiusConfig, labelTippyCustomizedConfig, labelTooltipConfig, hideFormFieldInfo, ...props }: SelectPickerProps<OptionValue, IsMulti>) => JSX.Element;
136
+ declare const SelectPicker: <OptionValue, IsMulti extends boolean>({ error, icon, helperText, placeholder, label, showSelectedOptionIcon, size, disabledTippyContent, showSelectedOptionsCount, menuSize, optionListError, reloadOptionList, menuPosition, variant, disableDescriptionEllipsis, multiSelectProps, isMulti, name, classNamePrefix, shouldRenderCustomOptions, isSearchable, selectRef: refFromConsumer, shouldMenuAlignRight, fullWidth, customSelectedOptionsCount, menuListFooterConfig, isCreatable, onCreateOption, closeMenuOnSelect, shouldShowNoOptionsMessage, shouldRenderTextArea, onKeyDown, shouldHideMenu, warningText, layout, ariaLabel, borderConfig, borderRadiusConfig, labelTippyCustomizedConfig, labelTooltipConfig, shouldShowLoadingMessage, hideFormFieldInfo, ...props }: SelectPickerProps<OptionValue, IsMulti>) => JSX.Element;
137
137
  export default SelectPicker;
@@ -182,6 +182,12 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
182
182
  * @default true
183
183
  */
184
184
  shouldShowNoOptionsMessage?: boolean;
185
+ /**
186
+ * If true, the loading message is shown when loading
187
+ *
188
+ * @default false
189
+ */
190
+ shouldShowLoadingMessage?: boolean;
185
191
  /**
186
192
  * If true, the menu list and the dropdown indicator are hidden. Suitable for use cases like multi-inputs
187
193
  *
@@ -215,5 +221,5 @@ export interface FilterSelectPickerProps extends Required<Pick<SelectPickerProps
215
221
  appliedFilterOptions: SelectPickerOptionType[];
216
222
  handleApplyFilter: (filtersToApply: SelectPickerOptionType<number | string>[]) => void;
217
223
  }
218
- export type SelectPickerTextAreaProps = Omit<SelectPickerProps<string, false>, 'selectRef' | 'inputValue' | 'onInputChange' | 'controlShouldRenderValue' | 'onKeyDown' | 'onCreateOption' | 'shouldRenderTextArea'> & Pick<ResizableTagTextAreaProps, 'maxHeight' | 'minHeight' | 'refVar' | 'dependentRefs'>;
224
+ export type SelectPickerTextAreaProps = Omit<SelectPickerProps<string, false>, 'selectRef' | 'inputValue' | 'onInputChange' | 'controlShouldRenderValue' | 'onKeyDown' | 'onCreateOption' | 'shouldRenderTextArea' | 'placeholder'> & Pick<ResizableTagTextAreaProps, 'maxHeight' | 'minHeight' | 'refVar' | 'dependentRefs'>;
219
225
  export {};
@@ -0,0 +1,3 @@
1
+ import { BulkSelectionActionWidgetProps } from './types';
2
+ declare const BulkSelectionActionWidget: ({ count, handleClearBulkSelection, parentRef, BulkActionsComponent, }: BulkSelectionActionWidgetProps) => JSX.Element;
3
+ export default BulkSelectionActionWidget;
@@ -0,0 +1,3 @@
1
+ import { InternalTableProps } from './types';
2
+ declare const InternalTable: ({ filtersVariant, filterData, rows, getRows, columns, ViewWrapper, resizableConfig, emptyStateConfig, additionalProps, areColumnsConfigurable, filter, setVisibleColumns, visibleColumns, stylesConfig, loading, bulkSelectionConfig, bulkSelectionReturnValue, handleClearBulkSelection, handleToggleBulkSelectionOnRow, paginationVariant, RowActionsOnHoverComponent, }: InternalTableProps) => JSX.Element;
3
+ export default InternalTable;
@@ -0,0 +1,3 @@
1
+ import { TableProps } from './types';
2
+ declare const TableWrapper: (tableProps: TableProps) => JSX.Element;
3
+ export default TableWrapper;
@@ -0,0 +1,7 @@
1
+ export declare const SEARCH_SORT_CHANGE_DEBOUNCE_TIME = 350; /** in ms */
2
+ export declare const LOCAL_STORAGE_EXISTS: boolean;
3
+ export declare const LOCAL_STORAGE_KEY_FOR_VISIBLE_COLUMNS = "generic-table-configurable-columns";
4
+ export declare const BULK_ACTION_GUTTER_LABEL = "bulk-action-gutter";
5
+ export declare const EVENT_TARGET: EventTarget;
6
+ export declare const DRAG_SELECTOR_IDENTIFIER = "table-drag-selector";
7
+ export declare const SHIMMER_DUMMY_ARRAY: number[];
@@ -0,0 +1,3 @@
1
+ export { default as Table } from './Table.component';
2
+ export { FiltersTypeEnum, PaginationEnum, SignalEnum as TableSignalEnum } from './types';
3
+ export type { ViewWrapperProps as TableViewWrapperProps, Column as TableColumnType, TableProps, CellComponentProps as TableCellComponentProps, } from './types';
@@ -0,0 +1,193 @@
1
+ import { Dispatch, FunctionComponent, PropsWithChildren, SetStateAction } from 'react';
2
+ import { SortableTableHeaderCellProps, useResizableTableConfig } from '../../../Common/SortableTableHeaderCell';
3
+ import { UseStateFiltersProps, UseStateFiltersReturnType, UseUrlFiltersProps } from '../../../Common/Hooks';
4
+ import { GenericEmptyStateType } from '../../../Common/index';
5
+ import { GenericFilterEmptyStateProps } from '@Common/EmptyState/types';
6
+ import { useBulkSelection, UseBulkSelectionProps } from '../BulkSelection';
7
+ export interface UseFiltersReturnType extends UseStateFiltersReturnType<string> {
8
+ }
9
+ export declare enum SignalEnum {
10
+ ENTER_PRESSED = "enter-pressed",
11
+ DELETE_PRESSED = "delete-pressed",
12
+ ESCAPE_PRESSED = "escape-pressed",
13
+ OPEN_CONTEXT_MENU = "open-context-menu",
14
+ ROW_CLICKED = "row-clicked"
15
+ }
16
+ export interface SignalsType<T extends string = SignalEnum> extends Pick<EventTarget, 'addEventListener' | 'removeEventListener'> {
17
+ addEventListener: (type: T, callback: (event: CustomEvent) => void, options?: Parameters<EventTarget['addEventListener']>[2]) => ReturnType<EventTarget['addEventListener']>;
18
+ removeEventListener: (type: T, callback: (event: CustomEvent) => void, options?: Parameters<EventTarget['removeEventListener']>[2]) => ReturnType<EventTarget['removeEventListener']>;
19
+ }
20
+ type SizeType = {
21
+ /** This signifies this column is resizable */
22
+ range: {
23
+ startWidth: number;
24
+ minWidth: number;
25
+ maxWidth: number | 'infinite';
26
+ };
27
+ /** If we want a fixed width */
28
+ fixed?: never;
29
+ } | {
30
+ range?: never;
31
+ fixed: number;
32
+ } | null;
33
+ type BaseColumnType = {
34
+ /** This is the key using which we will fetch the data of */
35
+ field: string;
36
+ /** This is the string that will be displayed to the user as header text */
37
+ label?: string;
38
+ /**
39
+ * If we want resizable columns, then every column has to have a fixed height
40
+ * If we specify size to be null then the size be will set to 1fr
41
+ */
42
+ size: SizeType;
43
+ horizontallySticky?: boolean;
44
+ };
45
+ interface AdditionalProps {
46
+ [key: string]: unknown;
47
+ }
48
+ export type RowType = {
49
+ id: string;
50
+ data: Record<string, unknown>;
51
+ };
52
+ export type RowsType = RowType[];
53
+ export interface CellComponentProps extends Pick<BaseColumnType, 'field'>, AdditionalProps {
54
+ signals: SignalsType;
55
+ value: unknown;
56
+ row: RowType;
57
+ filterData: UseFiltersReturnType;
58
+ isRowActive: boolean;
59
+ }
60
+ export type Column = Pick<SortableTableHeaderCellProps, 'showTippyOnTruncate'> & BaseColumnType & {
61
+ CellComponent?: FunctionComponent<CellComponentProps>;
62
+ } & ({
63
+ isSortable: true;
64
+ /**
65
+ * Compare two rows when sorting is triggered on this column
66
+ * Values fed are from the field key in the row's data object
67
+ * @returns -1 if a < b, 0 if a === b, 1 if a > b
68
+ */
69
+ comparator?: (a: unknown, b: unknown) => number;
70
+ } | {
71
+ isSortable?: false;
72
+ comparator?: never;
73
+ });
74
+ type BulkSelectionConfigType = Pick<UseBulkSelectionProps<unknown>, 'getSelectAllDialogStatus'> & {
75
+ /** Make sure to wrap it in useCallback */
76
+ onBulkSelectionChanged: (selectedRows: RowsType) => void;
77
+ BulkActionsComponent: FunctionComponent<{}>;
78
+ };
79
+ export declare enum PaginationEnum {
80
+ PAGINATED = "paginated",
81
+ INFINITE = "infinite",
82
+ NOT_PAGINATED = "not-paginated"
83
+ }
84
+ export declare enum FiltersTypeEnum {
85
+ STATE = "state",
86
+ URL = "url",
87
+ NONE = "none"
88
+ }
89
+ export interface ConfigurableColumnsType {
90
+ allColumns: Column[];
91
+ visibleColumns: Column[];
92
+ setVisibleColumns: Dispatch<SetStateAction<ConfigurableColumnsType['visibleColumns']>>;
93
+ }
94
+ interface GetRowsProps extends Pick<UseFiltersReturnType, 'offset' | 'pageSize' | 'searchKey' | 'sortBy' | 'sortOrder'> {
95
+ }
96
+ type AdditionalFilterPropsType<T extends Exclude<FiltersTypeEnum, FiltersTypeEnum.NONE>> = T extends FiltersTypeEnum.URL ? Pick<UseUrlFiltersProps<string, unknown>, 'parseSearchParams' | 'localStorageKey' | 'redirectionMethod' | 'initialSortKey'> : Pick<UseStateFiltersProps<string>, 'initialSortKey'>;
97
+ export type ViewWrapperProps = PropsWithChildren<Pick<UseFiltersReturnType, 'offset' | 'handleSearch' | 'searchKey' | 'sortBy' | 'sortOrder' | 'clearFilters'> & AdditionalProps & Partial<ConfigurableColumnsType> & {
98
+ areRowsLoading: boolean;
99
+ }>;
100
+ export type InternalTableProps = Required<Pick<ConfigurableColumnsType, 'visibleColumns' | 'setVisibleColumns'>> & {
101
+ id: `table__${string}`;
102
+ loading?: boolean;
103
+ paginationVariant: PaginationEnum;
104
+ /**
105
+ * Memoize columns before passing as props.
106
+ *
107
+ * For columns from backend: initialize as empty array and set loading
108
+ * to true until API call completes.
109
+ */
110
+ columns: Column[];
111
+ /** If bulk selections are not a concern omit this prop */
112
+ bulkSelectionConfig?: BulkSelectionConfigType;
113
+ emptyStateConfig: {
114
+ noRowsConfig: Omit<GenericEmptyStateType, 'children'>;
115
+ noRowsForFilterConfig?: Pick<GenericFilterEmptyStateProps, 'title' | 'subTitle'> & {
116
+ clearFilters: () => void;
117
+ };
118
+ };
119
+ filterData: UseFiltersReturnType | null;
120
+ resizableConfig: ReturnType<typeof useResizableTableConfig> | null;
121
+ /**
122
+ * Enable this to let users choose which columns to display.
123
+ * Example: Resource Browser > Node Listing
124
+ *
125
+ * Using the provided id for this table, we will store the user's preference in localStorage
126
+ */
127
+ areColumnsConfigurable?: boolean;
128
+ additionalProps?: AdditionalProps;
129
+ /** Control the look of the table using this prop */
130
+ stylesConfig?: {
131
+ showSeparatorBetweenRows: boolean;
132
+ };
133
+ /**
134
+ * Use this component to display additional content at the end of a row when it is hovered over.
135
+ */
136
+ RowActionsOnHoverComponent?: FunctionComponent<{
137
+ row: RowType;
138
+ }>;
139
+ bulkSelectionReturnValue: ReturnType<typeof useBulkSelection> | null;
140
+ handleClearBulkSelection: () => void;
141
+ handleToggleBulkSelectionOnRow: (row: RowType) => void;
142
+ ViewWrapper?: FunctionComponent<ViewWrapperProps>;
143
+ } & ({
144
+ /**
145
+ * Direct rows data for frontend-only datasets like resource browser.
146
+ */
147
+ rows: RowsType;
148
+ /**
149
+ * Use `getRows` function instead for data that needs to be fetched from backend with pagination/sorting/filtering.
150
+ */
151
+ getRows?: never;
152
+ } | {
153
+ rows?: never;
154
+ /** NOTE: Sorting on frontend is only handled if rows is provided instead of getRows */
155
+ getRows: (props: GetRowsProps) => Promise<RowsType>;
156
+ }) & ({
157
+ filtersVariant: FiltersTypeEnum.URL;
158
+ /**
159
+ * props for useUrlFilters/useStateFilters hooks
160
+ */
161
+ additionalFilterProps?: AdditionalFilterPropsType<FiltersTypeEnum.URL>;
162
+ /**
163
+ * This func is used to filter the rows based on filter data.
164
+ * Only applicable if filtersVariant is NOT set to NONE
165
+ *
166
+ * If filter is only being used for sorting, then send `noop` in this prop
167
+ */
168
+ filter: (row: RowType, filterData: UseFiltersReturnType) => boolean;
169
+ } | {
170
+ filtersVariant: FiltersTypeEnum.STATE;
171
+ additionalFilterProps?: AdditionalFilterPropsType<FiltersTypeEnum.STATE>;
172
+ filter: (row: RowType, filterData: UseFiltersReturnType) => boolean;
173
+ } | {
174
+ filtersVariant: FiltersTypeEnum.NONE;
175
+ additionalFilterProps?: never;
176
+ filter?: never;
177
+ });
178
+ export type UseResizableTableConfigWrapperProps = Omit<InternalTableProps, 'resizableConfig'>;
179
+ export type TableWithBulkSelectionProps = Omit<UseResizableTableConfigWrapperProps, 'bulkSelectionReturnValue' | 'handleClearBulkSelection' | 'handleToggleBulkSelectionOnRow'>;
180
+ export type VisibleColumnsWrapperProps = Omit<TableWithBulkSelectionProps, 'visibleColumns' | 'setVisibleColumns'>;
181
+ export type FilterWrapperProps = Omit<VisibleColumnsWrapperProps, 'filterData'>;
182
+ export type TableProps = Pick<FilterWrapperProps, 'additionalFilterProps' | 'bulkSelectionConfig' | 'areColumnsConfigurable' | 'emptyStateConfig' | 'filtersVariant' | 'filter' | 'additionalProps' | 'columns' | 'getRows' | 'rows' | 'paginationVariant' | 'stylesConfig' | 'id' | 'RowActionsOnHoverComponent' | 'loading' | 'ViewWrapper'>;
183
+ export interface BulkSelectionActionWidgetProps extends Pick<BulkSelectionConfigType, 'BulkActionsComponent'> {
184
+ count: number;
185
+ handleClearBulkSelection: () => void;
186
+ parentRef: React.RefObject<HTMLDivElement>;
187
+ }
188
+ export type ConfigurableColumnsConfigType = Record<string, ConfigurableColumnsType['visibleColumns']>;
189
+ export interface GetFilteringPromiseProps {
190
+ searchSortTimeoutRef: React.MutableRefObject<number>;
191
+ callback: () => Promise<RowsType> | RowsType;
192
+ }
193
+ export {};
@@ -0,0 +1,6 @@
1
+ import { InternalTableProps, RowsType } from './types';
2
+ declare const useTableWithKeyboardShortcuts: ({ bulkSelectionConfig, handleToggleBulkSelectionOnRow, bulkSelectionReturnValue, }: Pick<InternalTableProps, "bulkSelectionConfig" | "bulkSelectionReturnValue" | "handleToggleBulkSelectionOnRow">, visibleRows: RowsType) => {
3
+ activeRowIndex: number;
4
+ setActiveRowIndex: import('react').Dispatch<import('react').SetStateAction<number>>;
5
+ };
6
+ export default useTableWithKeyboardShortcuts;
@@ -0,0 +1,6 @@
1
+ import { Column, ConfigurableColumnsType, GetFilteringPromiseProps, RowsType, TableProps, UseFiltersReturnType } from './types';
2
+ export declare const searchAndSortRows: (rows: TableProps["rows"], filter: TableProps["filter"], filterData: UseFiltersReturnType, comparator?: Column["comparator"]) => RowsType;
3
+ export declare const getVisibleColumnsFromLocalStorage: ({ allColumns, id, }: Pick<ConfigurableColumnsType, "allColumns"> & Pick<TableProps, "id">) => Column[];
4
+ export declare const setVisibleColumnsToLocalStorage: ({ id, visibleColumns, }: Pick<ConfigurableColumnsType, "visibleColumns"> & Pick<TableProps, "id">) => void;
5
+ export declare const getVisibleColumns: ({ areColumnsConfigurable, columns, id, }: Pick<TableProps, "areColumnsConfigurable" | "columns" | "id">) => Column[];
6
+ export declare const getFilteringPromise: ({ searchSortTimeoutRef, callback }: GetFilteringPromiseProps) => Promise<RowsType>;
@@ -69,6 +69,7 @@ export * from './CustomInput';
69
69
  export * from './InfoBlock';
70
70
  export * from './CodeEditorWrapper';
71
71
  export * from './SSOProviderIcon';
72
+ export * from './Table';
72
73
  export * from './Backdrop';
73
74
  export * from './CountrySelect';
74
75
  export * from './PhoneInput';
@@ -3,3 +3,4 @@ export * from './useGetResourceKindsOptions';
3
3
  export * from './UseDownload';
4
4
  export * from './useForm';
5
5
  export * from './useStickyEvent';
6
+ export * from './useUserPreferences';
@@ -0,0 +1,4 @@
1
+ export { useUserPreferences } from './useUserPrefrences';
2
+ export * from './constants';
3
+ export * from './types';
4
+ export * from './service';
@@ -0,0 +1,30 @@
1
+ import { ResourceKindType, BaseAppMetaData } from '../../index';
2
+ import { ThemeConfigType, ThemePreferenceType } from '@Shared/Providers/ThemeProvider/types';
3
+ import { UserPreferencesType, ViewIsPipelineRBACConfiguredRadioTabs, UpdatedUserPreferencesType } from './types';
4
+ /**
5
+ * @returns UserPreferencesType
6
+ * @description This function fetches the user preferences from the server. It uses the `get` method to make a request to the server and retrieves the user preferences based on the `USER_PREFERENCES_ATTRIBUTE_KEY`. The result is parsed and returned as a `UserPreferencesType` object.
7
+ * @throws Will throw an error if the request fails or if the result is not in the expected format.
8
+ */
9
+ export declare const getUserPreferences: () => Promise<UserPreferencesType>;
10
+ export declare const resourceTypes: ResourceKindType[];
11
+ /**
12
+ * @description This function updates the user preferences in the server. It constructs a payload with the updated user preferences and sends a PATCH request to the server. If the request is successful, it returns true. If an error occurs, it shows an error message and returns false.
13
+ * @param updatedUserPreferences - The updated user preferences to be sent to the server.
14
+ * @param recentlyVisitedDevtronApps - The recently visited Devtron apps to be sent to the server.
15
+ * @param shouldThrowError - A boolean indicating whether to throw an error if the request fails. Default is false.
16
+ * @returns A promise that resolves to true if the request is successful, or false if an error occurs.
17
+ * @throws Will throw an error if `shouldThrowError` is true and the request fails.
18
+ */
19
+ export type UpdateUserPreferencesProps = {
20
+ type: 'updateTheme';
21
+ value: ThemePreferenceType | null;
22
+ appTheme: ThemeConfigType['appTheme'];
23
+ } | {
24
+ type: 'updatePipelineRBACView';
25
+ value: ViewIsPipelineRBACConfiguredRadioTabs;
26
+ } | {
27
+ type: 'updateRecentlyVisitedApps';
28
+ value: BaseAppMetaData[];
29
+ };
30
+ export declare const updateUserPreferences: (updatedUserPreferences?: UpdatedUserPreferencesType, recentlyVisitedDevtronApps?: BaseAppMetaData[], shouldThrowError?: boolean) => Promise<boolean>;
@@ -0,0 +1,60 @@
1
+ import { AppThemeType, BaseAppMetaData, ResourceKindType } from '../../index';
2
+ import { ThemeConfigType, ThemePreferenceType } from '@Shared/Providers/ThemeProvider/types';
3
+ import { USER_PREFERENCES_ATTRIBUTE_KEY } from '@Shared/Hooks/useUserPreferences/constants';
4
+ export interface GetUserPreferencesQueryParamsType {
5
+ key: typeof USER_PREFERENCES_ATTRIBUTE_KEY;
6
+ }
7
+ export declare enum ViewIsPipelineRBACConfiguredRadioTabs {
8
+ ALL_ENVIRONMENTS = "All environments",
9
+ ACCESS_ONLY = "Access only"
10
+ }
11
+ export declare enum UserPreferenceResourceActions {
12
+ RECENTLY_VISITED = "recently-visited"
13
+ }
14
+ export interface UserResourceKindActionType {
15
+ [UserPreferenceResourceActions.RECENTLY_VISITED]: BaseAppMetaData[];
16
+ }
17
+ export interface UserPreferenceResourceType {
18
+ [ResourceKindType.devtronApplication]: UserResourceKindActionType;
19
+ }
20
+ export interface GetUserPreferencesParsedDTO {
21
+ viewPermittedEnvOnly?: boolean;
22
+ /**
23
+ * Computed app theme for the user
24
+ *
25
+ * Could be 'light' | 'dark' | 'system-light' | 'system-dark'
26
+ */
27
+ computedAppTheme?: AppThemeType | `system-${AppThemeType}`;
28
+ /**
29
+ * @description resources object with key as resource kind and value as ResourceType
30
+ *
31
+ */
32
+ resources?: UserPreferenceResourceType;
33
+ }
34
+ export interface UserPreferencesPayloadValueType extends GetUserPreferencesParsedDTO {
35
+ }
36
+ export interface UpdateUserPreferencesPayloadType extends Pick<GetUserPreferencesQueryParamsType, 'key'> {
37
+ value: string;
38
+ }
39
+ export interface UserPreferencesType {
40
+ /**
41
+ * Preferred theme for the user
42
+ * If null, would forcibly show user theme switcher dialog for user to select
43
+ */
44
+ themePreference?: ThemePreferenceType | null;
45
+ /**
46
+ * @type {ViewIsPipelineRBACConfiguredRadioTabs}
47
+ * @description pipelineRBACViewSelectedTab is used to store the selected tab in the pipeline RBAC view
48
+ * @default ViewIsPipelineRBACConfiguredRadioTabs.VIEW_PERMITTED_ENV
49
+ */
50
+ pipelineRBACViewSelectedTab?: ViewIsPipelineRBACConfiguredRadioTabs;
51
+ /**
52
+ * @description resources object
53
+ */
54
+ resources?: GetUserPreferencesParsedDTO['resources'];
55
+ }
56
+ export interface UpdatedUserPreferencesType extends UserPreferencesType, Pick<ThemeConfigType, 'appTheme'> {
57
+ }
58
+ export interface UseUserPreferencesProps {
59
+ migrateUserPreferences?: (userPreferencesResponse: UserPreferencesType) => Promise<UserPreferencesType>;
60
+ }
@@ -0,0 +1,10 @@
1
+ import { ServerErrors } from '../../../Common/ServerError';
2
+ import { UserPreferencesType, UseUserPreferencesProps, ViewIsPipelineRBACConfiguredRadioTabs } from './types';
3
+ export declare const useUserPreferences: ({ migrateUserPreferences }: UseUserPreferencesProps) => {
4
+ userPreferences: UserPreferencesType;
5
+ userPreferencesError: ServerErrors;
6
+ handleFetchUserPreferences: () => Promise<void>;
7
+ handleUpdatePipelineRBACViewSelectedTab: (selectedTab: ViewIsPipelineRBACConfiguredRadioTabs) => void;
8
+ handleUpdateUserThemePreference: (themePreference: UserPreferencesType["themePreference"]) => void;
9
+ fetchRecentlyVisitedParsedApps: (appId: number, appName: string, isInvalidAppId?: boolean) => Promise<void>;
10
+ };
@@ -1,8 +1,6 @@
1
1
  import { AppConfigProps } from '../../Pages/index';
2
- import { EnvironmentDataValuesDTO, GetPolicyApiUrlProps, GetResourceApiUrlProps, UpdatedUserPreferencesType, UserPreferencesType } from './types';
2
+ import { EnvironmentDataValuesDTO, GetPolicyApiUrlProps, GetResourceApiUrlProps } from './types';
3
3
  export declare const getResourceApiUrl: <T>({ baseUrl, kind, version, suffix, queryParams }: GetResourceApiUrlProps<T>) => string;
4
4
  export declare const getPolicyApiUrl: <T>({ kind, version, queryParams, suffix }: GetPolicyApiUrlProps<T>) => string;
5
5
  export declare const saveCDPipeline: (request: any, { isTemplateView }: Required<Pick<AppConfigProps, "isTemplateView">>) => Promise<import('../../Common').ResponseType<any>>;
6
6
  export declare const getEnvironmentData: () => Promise<import('../../Common').ResponseType<EnvironmentDataValuesDTO>>;
7
- export declare const getUserPreferences: () => Promise<UserPreferencesType>;
8
- export declare const updateUserPreferences: (updatedUserPreferences: UpdatedUserPreferencesType, shouldThrowError?: boolean) => Promise<boolean>;
@@ -1,8 +1,10 @@
1
1
  import { MainContext } from '../Providers';
2
- import { AppThemeType, ThemeConfigType, ThemePreferenceType } from '@Shared/Providers/ThemeProvider/types';
3
2
  import { getUrlWithSearchParams } from '../../Common';
4
- import { PolicyKindType, ResourceKindType, ResourceVersionType, ViewIsPipelineRBACConfiguredRadioTabs } from '../types';
5
- import { USER_PREFERENCES_ATTRIBUTE_KEY } from './constants';
3
+ import { PolicyKindType, ResourceKindType, ResourceVersionType } from '../types';
4
+ export interface BaseAppMetaData {
5
+ appId: number;
6
+ appName: string;
7
+ }
6
8
  export interface ClusterType {
7
9
  id: number;
8
10
  name: string;
@@ -36,31 +38,4 @@ export interface EnvironmentDataValuesDTO extends Pick<MainContext, 'featureGitO
36
38
  isManifestScanningEnabled: boolean;
37
39
  canOnlyViewPermittedEnvOrgLevel: boolean;
38
40
  }
39
- export interface GetUserPreferencesQueryParamsType {
40
- key: typeof USER_PREFERENCES_ATTRIBUTE_KEY;
41
- }
42
- export interface GetUserPreferencesParsedDTO {
43
- viewPermittedEnvOnly?: boolean;
44
- /**
45
- * Computed app theme for the user
46
- *
47
- * Could be 'light' | 'dark' | 'system-light' | 'system-dark'
48
- */
49
- computedAppTheme: AppThemeType | `system-${AppThemeType}`;
50
- }
51
- export interface UserPreferencesPayloadValueType extends GetUserPreferencesParsedDTO {
52
- }
53
- export interface UpdateUserPreferencesPayloadType extends Pick<GetUserPreferencesQueryParamsType, 'key'> {
54
- value: string;
55
- }
56
- export interface UserPreferencesType {
57
- /**
58
- * Preferred theme for the user
59
- * If null, would forcibly show user theme switcher dialog for user to select
60
- */
61
- themePreference: ThemePreferenceType | null;
62
- pipelineRBACViewSelectedTab: ViewIsPipelineRBACConfiguredRadioTabs;
63
- }
64
- export interface UpdatedUserPreferencesType extends UserPreferencesType, Pick<ThemeConfigType, 'appTheme'> {
65
- }
66
41
  export {};
@@ -72,6 +72,18 @@ export declare enum TIMELINE_STATUS {
72
72
  HELM_MANIFEST_PUSHED_TO_HELM_REPO = "HELM_MANIFEST_PUSHED_TO_HELM_REPO",
73
73
  HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED = "HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED"
74
74
  }
75
+ /**
76
+ * Constants for NO MATCHING result
77
+ */
78
+ export declare const NO_MATCHING_RESULT = "No matching results";
79
+ /**
80
+ * Constants for TYPE 3 CHARACTERS
81
+ */
82
+ export declare const TYPE_3_CHARACTERS_TO_SEE_MATCHING_RESULTS = "Type 3 chars to see matching results";
83
+ /**
84
+ * Constants for TYPE TO SEE MATCHING RESULTS
85
+ */
86
+ export declare const TYPE_TO_SEE_MATCHING_RESULTS = "Type to see matching results";
75
87
  export declare const EMPTY_STATE_STATUS: {
76
88
  DATA_NOT_AVAILABLE: string;
77
89
  API_TOKEN: {
@@ -841,10 +841,6 @@ export declare const TriggerType: {
841
841
  readonly Auto: "AUTOMATIC";
842
842
  readonly Manual: "MANUAL";
843
843
  };
844
- export declare enum ViewIsPipelineRBACConfiguredRadioTabs {
845
- ALL_ENVIRONMENTS = "All environments",
846
- ACCESS_ONLY = "Access only"
847
- }
848
844
  export type ComponentLayoutType = 'row' | 'column';
849
845
  export interface BorderConfigType {
850
846
  /**