@devtron-labs/devtron-fe-common-lib 1.17.0-pre-7 → 1.17.0-pre-9

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.
@@ -1,7 +1,7 @@
1
1
  import { j as n, at as y, av as k, au as M } from "./@vendor-DbxoIktR.js";
2
2
  import W, { forwardRef as J, useMemo as P } from "react";
3
3
  import V, { getDefaultRegistry as K } from "@rjsf/core";
4
- import { T as N, j as w, c as v, b as F, S as q, i as Y, a as G, d as C, e as z } from "./@code-editor-CsKzSw6Y.js";
4
+ import { T as N, j as w, c as v, b as F, S as q, i as Y, a as G, d as C, e as z } from "./@code-editor-DcQ7PPhd.js";
5
5
  import { getUiOptions as I, getTemplate as D, getSubmitButtonOptions as Q, ADDITIONAL_PROPERTY_FLAG as B, errorId as X, englishStringTranslator as Z, TranslatableString as ee, titleId as te, canExpand as ne, deepEquals as re } from "@rjsf/utils";
6
6
  import { ReactComponent as se } from "./assets/ic-add.cfaa779b.svg";
7
7
  import { ReactComponent as ae } from "./assets/ic-warning.ecf7ff97.svg";
@@ -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"];