@devtron-labs/devtron-fe-common-lib 1.17.0-beta-5 → 1.17.0-beta-7

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 (24) hide show
  1. package/dist/{@code-editor-BuOe4OPL.js → @code-editor-CuHkeuO1.js} +5071 -4982
  2. package/dist/{@common-rjsf-DgYgQ4tX.js → @common-rjsf-COvKctSh.js} +2 -2
  3. package/dist/{@framer-motion-rKKsQaE-.js → @framer-motion-j6RIjEIR.js} +1 -1
  4. package/dist/{@react-dates-CiTDEWTa.js → @react-dates-BVyHiOGU.js} +213 -213
  5. package/dist/{@react-select-CWq3RFmB.js → @react-select-BQNFZu0Y.js} +1 -1
  6. package/dist/{@react-virtualized-sticky-tree-BHVxyXG4.js → @react-virtualized-sticky-tree-CuElh0mS.js} +1 -1
  7. package/dist/{@vendor-BNG16Dqc.js → @vendor-DbxoIktR.js} +15448 -17164
  8. package/dist/Common/API/index.d.ts +0 -2
  9. package/dist/Shared/Components/ContextSwitcher/ContextSwitcher.d.ts +2 -0
  10. package/dist/Shared/Components/ContextSwitcher/index.d.ts +3 -0
  11. package/dist/Shared/Components/ContextSwitcher/types.d.ts +14 -0
  12. package/dist/Shared/Components/ContextSwitcher/utils.d.ts +5 -0
  13. package/dist/Shared/Components/index.d.ts +1 -0
  14. package/dist/Shared/Hooks/useUserPreferences/constants.d.ts +2 -0
  15. package/dist/Shared/Hooks/useUserPreferences/index.d.ts +1 -1
  16. package/dist/Shared/Hooks/useUserPreferences/service.d.ts +22 -2
  17. package/dist/Shared/Hooks/useUserPreferences/types.d.ts +24 -11
  18. package/dist/Shared/Hooks/useUserPreferences/useUserPrefrences.d.ts +5 -3
  19. package/dist/Shared/Hooks/useUserPreferences/utils.d.ts +3 -4
  20. package/dist/index.d.ts +0 -16
  21. package/dist/index.js +781 -782
  22. package/package.json +2 -4
  23. package/dist/Common/API/QueryClientProvider.d.ts +0 -2
  24. package/dist/Common/API/useQueryClient.d.ts +0 -6
@@ -1,5 +1,3 @@
1
1
  export declare const post: <T = any, K = object>(url: string, data: K, options?: import('..').APIOptions, isMultipartRequest?: boolean) => Promise<import('..').ResponseType<T>>, put: <T = any, K = object>(url: string, data: K, options?: import('..').APIOptions) => Promise<import('..').ResponseType<T>>, patch: <T = any, K = object>(url: string, data: K, options?: import('..').APIOptions) => Promise<import('..').ResponseType<T>>, get: <T = any>(url: string, options?: import('..').APIOptions) => Promise<import('..').ResponseType<T>>, trash: <T = any, K = object>(url: string, data?: K, options?: import('..').APIOptions) => Promise<import('..').ResponseType<T>>;
2
2
  export { default as CoreAPI } from './CoreAPI';
3
- export { QueryClientProvider } from './QueryClientProvider';
4
- export * from './useQueryClient';
5
3
  export { abortPreviousRequests, getIsRequestAborted, handleRedirectToLicenseActivation } from './utils';
@@ -0,0 +1,2 @@
1
+ import { ContextSwitcherTypes } from './types';
2
+ export declare const ContextSwitcher: ({ inputId, options, inputValue, onInputChange, isLoading, value, onChange, placeholder, filterOption, formatOptionLabel, optionListError, reloadOptionList, classNamePrefix, }: ContextSwitcherTypes) => JSX.Element;
@@ -0,0 +1,3 @@
1
+ export { ContextSwitcher } from './ContextSwitcher';
2
+ export type { ContextSwitcherTypes, RecentlyVisitedGroupedOptionsType, RecentlyVisitedOptions } from './types';
3
+ export { getMinCharSearchPlaceholderGroup } from './utils';
@@ -0,0 +1,14 @@
1
+ import { GroupBase } from 'react-select';
2
+ import { SelectPickerOptionType, SelectPickerProps } from '../SelectPicker';
3
+ export interface ContextSwitcherTypes extends Pick<SelectPickerProps, 'placeholder' | 'onChange' | 'value' | 'isLoading' | 'onInputChange' | 'inputValue' | 'inputId' | 'formatOptionLabel' | 'filterOption' | 'optionListError' | 'reloadOptionList' | 'classNamePrefix'> {
4
+ options: GroupBase<SelectPickerOptionType<string | number>>[];
5
+ isAppDataAvailable?: boolean;
6
+ }
7
+ export interface RecentlyVisitedOptions extends SelectPickerOptionType<number> {
8
+ isDisabled?: boolean;
9
+ isRecentlyVisited?: boolean;
10
+ }
11
+ export interface RecentlyVisitedGroupedOptionsType extends GroupBase<SelectPickerOptionType<number>> {
12
+ label: string;
13
+ options: RecentlyVisitedOptions[];
14
+ }
@@ -0,0 +1,5 @@
1
+ import { SelectPickerProps } from '../SelectPicker';
2
+ import { RecentlyVisitedGroupedOptionsType, RecentlyVisitedOptions } from './types';
3
+ export declare const getDisabledOptions: (option: RecentlyVisitedOptions) => SelectPickerProps["isDisabled"];
4
+ export declare const customSelectFilterOption: SelectPickerProps['filterOption'];
5
+ export declare const getMinCharSearchPlaceholderGroup: (resourceKind: string) => RecentlyVisitedGroupedOptionsType;
@@ -21,6 +21,7 @@ export * from './CollapsibleList';
21
21
  export * from './CommitChipCell';
22
22
  export * from './Confetti';
23
23
  export * from './ConfirmationModal';
24
+ export * from './ContextSwitcher';
24
25
  export * from './CountrySelect';
25
26
  export * from './CustomInput';
26
27
  export * from './DatePicker';
@@ -1 +1,3 @@
1
+ import { PreferredResourceKindType } from './types';
1
2
  export declare const USER_PREFERENCES_ATTRIBUTE_KEY = "userPreferences";
3
+ export declare const DEFAULT_RESOURCES_MAP: Record<PreferredResourceKindType, null>;
@@ -1,4 +1,4 @@
1
1
  export * from './constants';
2
- export { getUserPreferences, updateUserPreferences } from './service';
2
+ export { getUserPreferences, updateAndPersistUserPreferences, updateUserPreferences } from './service';
3
3
  export * from './types';
4
4
  export { useUserPreferences } from './useUserPrefrences';
@@ -1,8 +1,28 @@
1
- import { UserPreferenceResourceProps, UserPreferencesType } from './types';
1
+ import { PreferredResourceKindType, UserPreferenceFilteredListTypes, UserPreferenceResourceProps, UserPreferencesType } from './types';
2
2
  /**
3
3
  * @returns UserPreferencesType
4
4
  * @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.
5
5
  * @throws Will throw an error if the request fails or if the result is not in the expected format.
6
6
  */
7
7
  export declare const getUserPreferences: () => Promise<UserPreferencesType>;
8
- export declare const updateUserPreferences: ({ path, value, shouldThrowError, }: UserPreferenceResourceProps) => Promise<boolean>;
8
+ export declare const updateUserPreferences: ({ path, value, resourceKind, shouldThrowError, userPreferencesResponse, }: UserPreferenceResourceProps) => Promise<boolean>;
9
+ /**
10
+ * Optimized function to get updated user preferences with resource filtering
11
+ * Can work with provided userPreferences or fetch from server/localStorage
12
+ * Centralizes all resource updating logic
13
+ */
14
+ export declare const getUpdatedUserPreferences: ({ id, name, resourceKind, userPreferencesResponse, }: UserPreferenceFilteredListTypes & {
15
+ userPreferencesResponse?: UserPreferencesType;
16
+ }) => Promise<UserPreferencesType>;
17
+ /**
18
+ * Centralized function to update and persist user preferences
19
+ * Handles both local state and server updates automatically
20
+ * Eliminates the need for manual resource management in multiple places
21
+ */
22
+ export declare const updateAndPersistUserPreferences: ({ id, name, resourceKind, shouldThrowError, updateLocalStorage, }: {
23
+ id?: number;
24
+ name?: string;
25
+ resourceKind?: PreferredResourceKindType;
26
+ shouldThrowError?: boolean;
27
+ updateLocalStorage?: boolean;
28
+ }) => Promise<UserPreferencesType>;
@@ -1,6 +1,5 @@
1
1
  import { USER_PREFERENCES_ATTRIBUTE_KEY } from './constants';
2
2
  import { AppThemeType, ThemeConfigType, ThemePreferenceType } from '../../Providers/ThemeProvider/types';
3
- import { BaseAppMetaData } from '../../Services';
4
3
  import { ResourceKindType } from '../../types';
5
4
  export interface GetUserPreferencesQueryParamsType {
6
5
  key: typeof USER_PREFERENCES_ATTRIBUTE_KEY;
@@ -12,12 +11,18 @@ export declare enum ViewIsPipelineRBACConfiguredRadioTabs {
12
11
  export declare enum UserPreferenceResourceActions {
13
12
  RECENTLY_VISITED = "recently-visited"
14
13
  }
15
- export interface UserResourceKindActionType {
16
- [UserPreferenceResourceActions.RECENTLY_VISITED]: BaseAppMetaData[];
14
+ export type PreferredResourceKindType = ResourceKindType.devtronApplication | ResourceKindType.job | 'app-group' | ResourceKindType.cluster;
15
+ export interface BaseRecentlyVisitedEntitiesTypes {
16
+ id: number;
17
+ name: string;
18
+ }
19
+ export interface UserPreferenceRecentlyVisitedAppsTypes extends BaseRecentlyVisitedEntitiesTypes {
20
+ resourceKind: PreferredResourceKindType;
17
21
  }
18
- export interface UserPreferenceResourceType {
19
- [ResourceKindType.devtronApplication]: UserResourceKindActionType;
22
+ export interface UserResourceKindActionType {
23
+ [UserPreferenceResourceActions.RECENTLY_VISITED]: BaseRecentlyVisitedEntitiesTypes[];
20
24
  }
25
+ export type UserPreferenceResourceType = Partial<Record<PreferredResourceKindType, UserResourceKindActionType>>;
21
26
  export interface GetUserPreferencesParsedDTO {
22
27
  viewPermittedEnvOnly?: boolean;
23
28
  /**
@@ -56,26 +61,34 @@ export interface UserPreferencesType {
56
61
  }
57
62
  export interface UpdatedUserPreferencesType extends UserPreferencesType, Pick<ThemeConfigType, 'appTheme'> {
58
63
  }
64
+ export interface RecentlyVisitedFetchConfigType extends UserPreferenceRecentlyVisitedAppsTypes {
65
+ isDataAvailable?: boolean;
66
+ }
59
67
  export interface UseUserPreferencesProps {
68
+ userPreferenceResourceKind?: PreferredResourceKindType;
60
69
  migrateUserPreferences?: (userPreferencesResponse: UserPreferencesType) => Promise<UserPreferencesType>;
70
+ recentlyVisitedFetchConfig?: RecentlyVisitedFetchConfigType;
61
71
  }
62
72
  export type UserPathValueMapType = {
63
73
  path: 'themePreference';
64
74
  value: Required<Pick<UpdatedUserPreferencesType, 'themePreference' | 'appTheme'>>;
75
+ resourceKind?: never;
76
+ userPreferencesResponse?: never;
65
77
  } | {
66
78
  path: 'pipelineRBACViewSelectedTab';
67
79
  value: Required<Pick<UserPreferencesType, 'pipelineRBACViewSelectedTab'>>;
80
+ resourceKind?: never;
81
+ userPreferencesResponse?: never;
68
82
  } | {
69
83
  path: 'resources';
70
- value: Required<BaseAppMetaData[]>;
84
+ value: Required<BaseRecentlyVisitedEntitiesTypes[]>;
85
+ resourceKind: PreferredResourceKindType;
86
+ userPreferencesResponse?: UserPreferencesType;
71
87
  };
72
88
  export type UserPreferenceResourceProps = UserPathValueMapType & {
73
89
  shouldThrowError?: boolean;
90
+ userPreferencesResponse?: UserPreferencesType;
74
91
  };
75
- export interface UserPreferenceRecentlyVisitedAppsTypes {
76
- appId: number;
77
- appName: string;
78
- }
79
92
  export interface UserPreferenceFilteredListTypes extends UserPreferenceRecentlyVisitedAppsTypes {
80
- userPreferencesResponse: UserPreferencesType;
93
+ userPreferencesResponse?: UserPreferencesType;
81
94
  }
@@ -1,10 +1,12 @@
1
1
  import { ServerErrors } from '../../../Common/ServerError';
2
- import { UserPreferenceRecentlyVisitedAppsTypes, UserPreferencesType, UseUserPreferencesProps, ViewIsPipelineRBACConfiguredRadioTabs } from './types';
3
- export declare const useUserPreferences: ({ migrateUserPreferences }: UseUserPreferencesProps) => {
2
+ import { BaseRecentlyVisitedEntitiesTypes, UserPreferencesType, UseUserPreferencesProps, ViewIsPipelineRBACConfiguredRadioTabs } from './types';
3
+ export declare const useUserPreferences: ({ migrateUserPreferences, recentlyVisitedFetchConfig }: UseUserPreferencesProps) => {
4
4
  userPreferences: UserPreferencesType;
5
5
  userPreferencesError: ServerErrors;
6
6
  handleFetchUserPreferences: () => Promise<void>;
7
7
  handleUpdatePipelineRBACViewSelectedTab: (selectedTab: ViewIsPipelineRBACConfiguredRadioTabs) => void;
8
8
  handleUpdateUserThemePreference: (themePreference: UserPreferencesType["themePreference"]) => void;
9
- fetchRecentlyVisitedParsedApps: ({ appId, appName }: UserPreferenceRecentlyVisitedAppsTypes) => Promise<void>;
9
+ fetchRecentlyVisitedParsedEntities: () => Promise<UserPreferencesType>;
10
+ recentlyVisitedResources: BaseRecentlyVisitedEntitiesTypes[];
11
+ recentResourcesLoading: boolean;
10
12
  };
@@ -1,4 +1,3 @@
1
- import { BaseAppMetaData } from '../../Services';
2
- import { UserPreferenceFilteredListTypes, UserPreferenceResourceType } from './types';
3
- export declare const getUserPreferenceResourcesMetadata: (recentlyVisited: BaseAppMetaData[]) => UserPreferenceResourceType;
4
- export declare const getFilteredUniqueAppList: ({ userPreferencesResponse, appId, appName, }: UserPreferenceFilteredListTypes) => BaseAppMetaData[];
1
+ import { GetUserPreferencesParsedDTO, UserPreferenceFilteredListTypes, UserPreferencesType } from './types';
2
+ export declare const getFilteredUniqueAppList: ({ userPreferencesResponse, id, name, resourceKind, }: UserPreferenceFilteredListTypes) => import('./types').BaseRecentlyVisitedEntitiesTypes[];
3
+ export declare const getParsedResourcesMap: (resources: GetUserPreferencesParsedDTO["resources"]) => UserPreferencesType["resources"];
package/dist/index.d.ts CHANGED
@@ -174,22 +174,6 @@ declare global {
174
174
  _env_: customEnv;
175
175
  }
176
176
  }
177
- declare module '@tanstack/react-query' {
178
- interface QueryMeta {
179
- /**
180
- * Optional flag indicating whether to display a toast notification for errors.
181
- * @default true
182
- */
183
- showToastError?: boolean;
184
- }
185
- interface MutationMeta {
186
- /**
187
- * Optional flag indicating whether to display a toast notification for errors.
188
- * @default true
189
- */
190
- showToastError?: boolean;
191
- }
192
- }
193
177
  export * from './Common';
194
178
  export * from './Pages';
195
179
  export * from './Shared';