@devtron-labs/devtron-fe-common-lib 0.0.61 → 0.0.62-beta-2

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 (39) hide show
  1. package/dist/Common/Api.d.ts +9 -0
  2. package/dist/Common/Constants.d.ts +14 -0
  3. package/dist/Common/Hooks/index.d.ts +1 -0
  4. package/dist/Common/Hooks/useUrlFilters/constants.d.ts +8 -0
  5. package/dist/Common/Hooks/useUrlFilters/index.d.ts +2 -0
  6. package/dist/Common/Hooks/useUrlFilters/types.d.ts +6 -0
  7. package/dist/Common/Hooks/useUrlFilters/useUrlFilters.d.ts +32 -0
  8. package/dist/Common/SortableTableHeaderCell/SortableTableHeaderCell.d.ts +18 -0
  9. package/dist/Common/SortableTableHeaderCell/index.d.ts +2 -0
  10. package/dist/Common/SortableTableHeaderCell/types.d.ts +25 -0
  11. package/dist/Common/Types.d.ts +14 -1
  12. package/dist/Common/index.d.ts +1 -0
  13. package/dist/Pages/GlobalConfigurations/Authorization/constants.d.ts +15 -0
  14. package/dist/Pages/GlobalConfigurations/Authorization/index.d.ts +1 -0
  15. package/dist/Pages/GlobalConfigurations/index.d.ts +1 -0
  16. package/dist/Pages/index.d.ts +1 -0
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.js +322 -103
  19. package/package.json +1 -1
  20. package/src/Assets/Icon/ic-arrow-up-down.svg +3 -0
  21. package/src/Assets/Icon/ic-sort-arrow-down.svg +3 -0
  22. package/src/Common/Api.ts +21 -0
  23. package/src/Common/Constants.ts +17 -1
  24. package/src/Common/Hooks/index.ts +1 -0
  25. package/src/Common/Hooks/useUrlFilters/constants.ts +9 -0
  26. package/src/Common/Hooks/useUrlFilters/index.ts +2 -0
  27. package/src/Common/Hooks/useUrlFilters/types.ts +6 -0
  28. package/src/Common/Hooks/useUrlFilters/useUrlFilters.ts +121 -0
  29. package/src/Common/SearchBar/SearchBar.component.tsx +1 -0
  30. package/src/Common/SortableTableHeaderCell/SortableTableHeaderCell.tsx +44 -0
  31. package/src/Common/SortableTableHeaderCell/index.ts +2 -0
  32. package/src/Common/SortableTableHeaderCell/types.ts +26 -0
  33. package/src/Common/Types.ts +14 -1
  34. package/src/Common/index.ts +1 -0
  35. package/src/Pages/GlobalConfigurations/Authorization/constants.ts +16 -0
  36. package/src/Pages/GlobalConfigurations/Authorization/index.ts +1 -0
  37. package/src/Pages/GlobalConfigurations/index.ts +1 -0
  38. package/src/Pages/index.ts +1 -0
  39. package/src/index.ts +2 -1
@@ -1,5 +1,14 @@
1
1
  import { ResponseType, APIOptions } from './Types';
2
+ import { MutableRefObject } from 'react';
2
3
  export declare const post: (url: string, data: object, options?: APIOptions, isMultipartRequest?: boolean) => Promise<ResponseType>;
3
4
  export declare const put: (url: string, data: object, options?: APIOptions) => Promise<ResponseType>;
4
5
  export declare const get: (url: string, options?: APIOptions) => Promise<ResponseType>;
5
6
  export declare const trash: (url: string, data?: object, options?: APIOptions) => Promise<ResponseType>;
7
+ /**
8
+ * Aborts the previous request before triggering next request
9
+ */
10
+ export declare const abortPreviousRequests: <T>(callback: () => Promise<T>, abortControllerRef: MutableRefObject<AbortController>) => Promise<T>;
11
+ /**
12
+ * Returns true if the error is due to a aborted request
13
+ */
14
+ export declare const getIsRequestAborted: (error: any) => boolean;
@@ -73,3 +73,17 @@ export declare const SELECTED_APPROVAL_TAB_STATE: {
73
73
  APPROVAL: string;
74
74
  PENDING: string;
75
75
  };
76
+ export declare enum SortingOrder {
77
+ /**
78
+ * Ascending order
79
+ */
80
+ ASC = "ASC",
81
+ /**
82
+ * Descending order
83
+ */
84
+ DESC = "DESC"
85
+ }
86
+ /**
87
+ * Base page size for pagination
88
+ */
89
+ export declare const DEFAULT_BASE_PAGE_SIZE = 20;
@@ -1,3 +1,4 @@
1
1
  export { useSuperAdmin } from './UseSuperAdmin/UseSuperAdmin';
2
2
  export { useClickOutside } from './UseClickOutside/UseClickOutside';
3
3
  export { useWindowSize } from './UseWindowSize/UseWindowSize';
4
+ export * from './useUrlFilters';
@@ -0,0 +1,8 @@
1
+ export declare const DEFAULT_PAGE_NUMBER = 1;
2
+ export declare const URL_FILTER_KEYS: {
3
+ readonly PAGE_SIZE: "pageSize";
4
+ readonly PAGE_NUMBER: "pageNumber";
5
+ readonly SEARCH_KEY: "searchKey";
6
+ readonly SORT_BY: "sortBy";
7
+ readonly SORT_ORDER: "sortOrder";
8
+ };
@@ -0,0 +1,2 @@
1
+ export { default as useUrlFilters } from './useUrlFilters';
2
+ export type { UseUrlFiltersProps } from './types';
@@ -0,0 +1,6 @@
1
+ export interface UseUrlFiltersProps<T> {
2
+ /**
3
+ * The key on which the sorting should be applied
4
+ */
5
+ initialSortKey?: T;
6
+ }
@@ -0,0 +1,32 @@
1
+ import { SortingOrder } from '../../Constants';
2
+ import { UseUrlFiltersProps } from './types';
3
+ /**
4
+ * Generic hook for implementing URL based filters.
5
+ * eg: pagination, search, sort.
6
+ *
7
+ * The exposed handlers can be consumed directly without the need for explicit state management
8
+ *
9
+ * @example Default Usage:
10
+ * ```tsx
11
+ * const { pageSize, changePage, ...rest } = useUrlFilters()
12
+ * ```
13
+ *
14
+ * @example Usage with custom type for sort keys and initial sort key:
15
+ * ```tsx
16
+ * const { sortBy, sortOrder } = useUrlFilters<'email' | 'name'>({ initialSortKey: 'email' })
17
+ * ```
18
+ *
19
+ */
20
+ declare const useUrlFilters: <T = string>({ initialSortKey }?: UseUrlFiltersProps<T>) => {
21
+ pageSize: number;
22
+ changePage: (page: number) => void;
23
+ changePageSize: (_pageSize: number) => void;
24
+ searchKey: string;
25
+ handleSearch: (searchTerm: string) => void;
26
+ offset: number;
27
+ sortBy: T;
28
+ sortOrder: SortingOrder;
29
+ handleSorting: (_sortBy: T) => void;
30
+ clearFilters: () => void;
31
+ };
32
+ export default useUrlFilters;
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { SortableTableHeaderCellProps } from './types';
3
+ /**
4
+ * Reusable component for the table header cell with support for sorting icons
5
+ *
6
+ * @example Usage
7
+ * ```tsx
8
+ * <SortableTableHeaderCell
9
+ * isSorted={currentSortedCell === 'cell'}
10
+ * triggerSorting={() => {}}
11
+ * sortOrder={SortingOrder.ASC}
12
+ * title="Header Cell"
13
+ * disabled={isDisabled}
14
+ * />
15
+ * ```
16
+ */
17
+ declare const SortableTableHeaderCell: ({ isSorted, triggerSorting, sortOrder, title, disabled, }: SortableTableHeaderCellProps) => JSX.Element;
18
+ export default SortableTableHeaderCell;
@@ -0,0 +1,2 @@
1
+ export { default as SortableTableHeaderCell } from './SortableTableHeaderCell';
2
+ export type { SortableTableHeaderCellProps } from './types';
@@ -0,0 +1,25 @@
1
+ import { SortingOrder } from '../Constants';
2
+ export interface SortableTableHeaderCellProps {
3
+ /**
4
+ * If true, the cell is sorted
5
+ */
6
+ isSorted: boolean;
7
+ /**
8
+ * Callback for handling the sorting of the cell
9
+ */
10
+ triggerSorting: () => void;
11
+ /**
12
+ * Current sort order
13
+ *
14
+ * Note: On click, the sort order should be updated as required
15
+ */
16
+ sortOrder: SortingOrder;
17
+ /**
18
+ * Label for the cell
19
+ */
20
+ title: string;
21
+ /**
22
+ * If true, the cell is disabled
23
+ */
24
+ disabled: boolean;
25
+ }
@@ -1,7 +1,7 @@
1
1
  import React, { ReactNode, CSSProperties } from 'react';
2
2
  import { Placement } from 'tippy.js';
3
3
  import { ImageComment, ReleaseTag } from './ImageTags.Types';
4
- import { DockerConfigOverrideType, TaskErrorObj } from '.';
4
+ import { DockerConfigOverrideType, SortingOrder, TaskErrorObj } from '.';
5
5
  /**
6
6
  * Generic response type object with support for overriding the result type
7
7
  *
@@ -340,6 +340,7 @@ export interface CommonNodeAttr {
340
340
  };
341
341
  appReleaseTagNames?: string[];
342
342
  tagsEditable?: boolean;
343
+ isGitOpsRepoNotConfigured?: boolean;
343
344
  deploymentAppCreated?: boolean;
344
345
  isLast?: boolean;
345
346
  downstreamEnvironments?: DownstreamNodesEnvironmentsType[];
@@ -688,4 +689,16 @@ export interface EdgeNodeType {
688
689
  export interface EdgeEndNodeType extends EdgeNodeType {
689
690
  userApprovalConfig?: UserApprovalConfigType;
690
691
  }
692
+ /**
693
+ * Search params for sorting configuration
694
+ *
695
+ * Note: Either both sortOrder and sortBy are required or none
696
+ */
697
+ export type SortingParams<T = string> = {
698
+ sortOrder: SortingOrder;
699
+ sortBy: T;
700
+ } | {
701
+ sortOrder?: never;
702
+ sortBy?: never;
703
+ };
691
704
  export {};
@@ -27,6 +27,7 @@ export * from './Checkbox';
27
27
  export { default as EmptyState } from './EmptyState/EmptyState';
28
28
  export { default as GenericEmptyState } from './EmptyState/GenericEmptyState';
29
29
  export * from './SearchBar';
30
+ export * from './SortableTableHeaderCell';
30
31
  export { default as Toggle } from './Toggle/Toggle';
31
32
  export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable';
32
33
  export { default as StyledRadioGroup } from './RadioGroup/RadioGroup';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * User Status received from the API
3
+ */
4
+ export declare enum UserStatusDto {
5
+ active = "active",
6
+ inactive = "inactive"
7
+ }
8
+ /**
9
+ * User status for the frontend
10
+ */
11
+ export declare enum UserStatus {
12
+ active = "active",
13
+ inactive = "inactive",
14
+ temporary = "temporary"
15
+ }
@@ -0,0 +1 @@
1
+ export * from './constants';
@@ -0,0 +1 @@
1
+ export * from './Authorization';
@@ -0,0 +1 @@
1
+ export * from './GlobalConfigurations';
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export * from "./Common";
1
+ export * from './Common';
2
+ export * from './Pages';