@ws-ui/roles-editor 1.14.1 → 1.14.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.
package/dist/NavBar.d.ts CHANGED
@@ -4,9 +4,13 @@ interface INavbarProps {
4
4
  activeTab: TabType;
5
5
  forceLogin?: boolean;
6
6
  restrictedByDefault?: boolean;
7
+ canUndo?: boolean;
8
+ canRedo?: boolean;
9
+ onUndo: () => void;
10
+ onRedo: () => void;
7
11
  onTabChange: (value: TabType) => void;
8
12
  onRestrictedByDefaultChange: (value: boolean) => void;
9
13
  onForceLoginChange: (value: boolean) => void;
10
14
  }
11
- export default function Navbar({ qodly, activeTab, forceLogin, onTabChange, restrictedByDefault, onRestrictedByDefaultChange, onForceLoginChange, }: INavbarProps): import("react/jsx-runtime").JSX.Element;
15
+ export default function Navbar({ qodly, activeTab, forceLogin, canUndo, canRedo, onUndo, onRedo, onTabChange, restrictedByDefault, onRestrictedByDefaultChange, onForceLoginChange, }: INavbarProps): import("react/jsx-runtime").JSX.Element;
12
16
  export {};
@@ -1,9 +1,18 @@
1
1
  import { FC } from 'react';
2
2
  import { IContainerProps } from '../Container';
3
+ import { TabType } from '../types';
4
+ import { THistoryControls } from '../adapter';
3
5
  interface IStandaloneProps extends IContainerProps {
4
6
  initialValue?: string;
5
7
  catalog?: datasources.ICatalog;
6
8
  onChange?: (newValue: string) => void;
9
+ history?: THistoryControls;
10
+ activeTab?: TabType;
11
+ onTabChange?: (tab: TabType) => void;
12
+ selectedRole?: string | null;
13
+ onSelectRole?: (role: string | null) => void;
14
+ selectedPrivilege?: string | null;
15
+ onSelectPrivilege?: (id: string | null) => void;
7
16
  }
8
17
  declare const StandaloneWithReducerAdapter: FC<IStandaloneProps>;
9
18
  export { StandaloneWithReducerAdapter as Standalone };
@@ -0,0 +1,14 @@
1
+ import { TRawData } from '@ws-ui/shared';
2
+ export interface IRolesHistory {
3
+ canUndo: boolean;
4
+ canRedo: boolean;
5
+ undo: () => void;
6
+ redo: () => void;
7
+ /**
8
+ * Flags the next state change as a user edit so it gets recorded in the
9
+ * history stack. Changes that are not flagged (initial load, external
10
+ * reloads, ...) re-baseline the history instead.
11
+ */
12
+ markEdit: () => void;
13
+ }
14
+ export declare function useRolesHistory(current: TRawData, restore: (content: TRawData) => void): IRolesHistory;
@@ -6,3 +6,4 @@ export * from './redux/adapter';
6
6
  export * from './provider';
7
7
  export * from './reducer/adapter';
8
8
  export * from './reducer/use-modals';
9
+ export * from './history';
@@ -1,6 +1,6 @@
1
1
  import { FC, ReactNode, Dispatch } from 'react';
2
2
  import { ITabFlags, IModal, ModalCloseReason, TRolesDict, TById, TRawData, IRolesState } from '@ws-ui/shared';
3
- import { IEditorStateAdapter, TEditorHost } from '../types';
3
+ import { IEditorStateAdapter, TEditorHost, THistoryControls } from '../types';
4
4
  /**
5
5
  * Modal state interface
6
6
  */
@@ -13,6 +13,8 @@ interface IModalsState {
13
13
  */
14
14
  interface IReducerState extends IRolesState {
15
15
  modals: IModalsState;
16
+ selectedRole: string | null;
17
+ selectedPrivilege: string | null;
16
18
  }
17
19
  /**
18
20
  * Action types for the reducer
@@ -33,6 +35,12 @@ type ReducerAction = {
33
35
  } | {
34
36
  type: 'TOGGLE_TAB';
35
37
  payload: 'privileges' | 'roles';
38
+ } | {
39
+ type: 'SELECT_ROLE';
40
+ payload: string | null;
41
+ } | {
42
+ type: 'SELECT_PRIVILEGE';
43
+ payload: string | null;
36
44
  } | {
37
45
  type: 'TOGGLE_FORCE_LOGIN';
38
46
  payload: boolean;
@@ -68,12 +76,26 @@ interface IExternalData {
68
76
  qodly?: boolean;
69
77
  host?: TEditorHost;
70
78
  onSetTabFlags?: (path: string, flags: ITabFlags) => void;
79
+ history?: THistoryControls;
80
+ selectedTab?: 'privileges' | 'roles';
81
+ onTabChange?: (tab: 'privileges' | 'roles') => void;
82
+ selectedRole?: string | null;
83
+ onSelectRole?: (role: string | null) => void;
84
+ selectedPrivilege?: string | null;
85
+ onSelectPrivilege?: (id: string | null) => void;
71
86
  }
72
87
  interface IReducerAdapterExternalProps {
73
88
  catalog?: datasources.ICatalog | null;
74
89
  qodly?: boolean;
75
90
  host?: TEditorHost;
76
91
  onSetTabFlags?: (path: string, flags: ITabFlags) => void;
92
+ history?: THistoryControls;
93
+ selectedTab?: 'privileges' | 'roles';
94
+ onTabChange?: (tab: 'privileges' | 'roles') => void;
95
+ selectedRole?: string | null;
96
+ onSelectRole?: (role: string | null) => void;
97
+ selectedPrivilege?: string | null;
98
+ onSelectPrivilege?: (id: string | null) => void;
77
99
  }
78
100
  /**
79
101
  * Reducer value interface
@@ -1,5 +1,11 @@
1
1
  import { ITabFlags, TRolesDict, TSanitizedPrivilege, TById, TRawData, IOpenModalPayload, IOpenModalReturnValue, TEditorAdapter } from '@ws-ui/shared';
2
2
  export type TEditorHost = 'web' | 'vscode';
3
+ export type THistoryControls = {
4
+ onUndo?: () => void;
5
+ onRedo?: () => void;
6
+ canUndo?: boolean;
7
+ canRedo?: boolean;
8
+ };
3
9
  /**
4
10
  * Editor State Adapter Interface
5
11
  *
@@ -14,6 +20,8 @@ type TEditorStateGetters = {
14
20
  getCatalog(): datasources.IEnhancedCatalog | null;
15
21
  getQodly(): boolean;
16
22
  getSelectedTab(): 'privileges' | 'roles';
23
+ getSelectedRole(): string | null;
24
+ getSelectedPrivilege(): string | null;
17
25
  getForceLogin(): boolean;
18
26
  getRestrictedByDefault(): boolean;
19
27
  getGuestPrivilege(): TSanitizedPrivilege | null;
@@ -21,6 +29,10 @@ type TEditorStateGetters = {
21
29
  getDataclasses(): datasources.IDataClasses;
22
30
  getSingletons(): datasources.ISingletons;
23
31
  getHost(): TEditorHost;
32
+ getHistory(): {
33
+ canUndo: boolean;
34
+ canRedo: boolean;
35
+ };
24
36
  };
25
37
  type TEditorStateActions = {
26
38
  updateRoles(roles: TRolesDict): void;
@@ -31,10 +43,14 @@ type TEditorStateActions = {
31
43
  flags?: ITabFlags;
32
44
  }): void;
33
45
  toggleTab(tab: 'privileges' | 'roles'): void;
46
+ selectRole(role: string | null): void;
47
+ selectPrivilege(id: string | null): void;
34
48
  toggleForceLogin(value: boolean): void;
35
49
  toggleRestrictedByDefault(value: boolean): void;
36
50
  setTabFlags(path: string, flags: ITabFlags): void;
37
51
  openModal(config: IOpenModalPayload): Promise<IOpenModalReturnValue>;
52
+ undo(): void;
53
+ redo(): void;
38
54
  };
39
55
  export type IEditorStateAdapter = TEditorAdapter<TEditorStateGetters, TEditorStateActions>;
40
56
  export {};