@nu-art/conflict-resolution-frontend 0.400.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 (29) hide show
  1. package/_ats/ATS_ConflictResolution/ATS_ConflictResolution.d.ts +15 -0
  2. package/_ats/ATS_ConflictResolution/ATS_ConflictResolution.js +39 -0
  3. package/_ats/ATS_ConflictResolution/ATS_ConflictResolution.scss +10 -0
  4. package/_ats/index.d.ts +2 -0
  5. package/_ats/index.js +4 -0
  6. package/_dispatchers/index.d.ts +1 -0
  7. package/_dispatchers/index.js +1 -0
  8. package/_dispatchers/show-conflict-resolution.d.ts +6 -0
  9. package/_dispatchers/show-conflict-resolution.js +2 -0
  10. package/_modules/ModuleFE_ConflictResolution.d.ts +13 -0
  11. package/_modules/ModuleFE_ConflictResolution.js +36 -0
  12. package/_ui/ConflictResolutionTree/ConflictResolutionTree.d.ts +15 -0
  13. package/_ui/ConflictResolutionTree/ConflictResolutionTree.js +25 -0
  14. package/_ui/ConflictResolutionTree/ConflictResolutionTree.scss +83 -0
  15. package/_ui/ConflictResolutionTree/tree-calculation.d.ts +3 -0
  16. package/_ui/ConflictResolutionTree/tree-calculation.js +47 -0
  17. package/_ui/ConflictResolutionTree/tree-rendering.d.ts +4 -0
  18. package/_ui/ConflictResolutionTree/tree-rendering.js +32 -0
  19. package/_ui/ConflictResolutionTree/types.d.ts +31 -0
  20. package/_ui/ConflictResolutionTree/types.js +1 -0
  21. package/_ui/Overlay_ConflictResolution/Overlay_ConflictResolution.d.ts +12 -0
  22. package/_ui/Overlay_ConflictResolution/Overlay_ConflictResolution.js +14 -0
  23. package/_ui/Overlay_ConflictResolution/Overlay_ConflictResolution.scss +0 -0
  24. package/_ui/Panel_ConflictResolution/Panel_ConflictResolution.d.ts +23 -0
  25. package/_ui/Panel_ConflictResolution/Panel_ConflictResolution.js +54 -0
  26. package/_ui/Panel_ConflictResolution/Panel_ConflictResolution.scss +71 -0
  27. package/_ui/index.d.ts +1 -0
  28. package/_ui/index.js +1 -0
  29. package/package.json +64 -0
@@ -0,0 +1,15 @@
1
+ import './ATS_ConflictResolution.scss';
2
+ import { AppToolsScreen, ComponentSync, ModuleFE_BaseApi } from '@nu-art/thunderstorm-frontend/index';
3
+ type State = {
4
+ upgradableModules: ModuleFE_BaseApi<any, any>[];
5
+ selectedModule?: ModuleFE_BaseApi<any>;
6
+ itemId?: string;
7
+ };
8
+ export declare class ATS_ConflictResolution extends ComponentSync<{}, State> {
9
+ static screen: AppToolsScreen;
10
+ protected deriveStateFromProps(nextProps: {}, state: State): State;
11
+ private getAdapter;
12
+ private checkUsage;
13
+ render(): import("react/jsx-runtime").JSX.Element;
14
+ }
15
+ export {};
@@ -0,0 +1,39 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { filterDuplicates, Minute, RuntimeModules, sortArray } from '@nu-art/ts-common';
3
+ import './ATS_ConflictResolution.scss';
4
+ import { ATS_Backend, Button, ComponentSync, LL_V_L, SimpleListAdapter, TS_DropDown, TS_Input, TS_PropRenderer } from '@nu-art/thunderstorm-frontend/index';
5
+ import { ModuleFE_CollectionActions } from '@nu-art/thunderstorm-frontend/modules/ModuleFE_CollectionActions';
6
+ import { ModuleFE_ConflictResolution } from '../../_modules/ModuleFE_ConflictResolution.js';
7
+ export class ATS_ConflictResolution extends ComponentSync {
8
+ static screen = {
9
+ name: 'Conflict Resolution',
10
+ key: 'conflict-resolution',
11
+ renderer: this,
12
+ group: ATS_Backend,
13
+ };
14
+ deriveStateFromProps(nextProps, state) {
15
+ state.upgradableModules ??= sortArray(filterDuplicates(RuntimeModules().filter((module) => {
16
+ return !!module.getCollectionName;
17
+ }), (module) => module.getCollectionName()), item => item.getCollectionName());
18
+ return state;
19
+ }
20
+ getAdapter = () => {
21
+ return SimpleListAdapter(this.state.upgradableModules, module => _jsx(_Fragment, { children: module.item.dbDef.dbKey }));
22
+ };
23
+ checkUsage = async () => {
24
+ const itemId = this.state.itemId;
25
+ const dbKey = this.state.selectedModule?.dbDef.dbKey;
26
+ if (!itemId || !dbKey)
27
+ return;
28
+ const response = await ModuleFE_CollectionActions.check.usage({
29
+ dbKey: dbKey,
30
+ itemIds: [itemId]
31
+ }).setTimeout(2 * Minute).executeSync();
32
+ if (response.dependencies)
33
+ ModuleFE_ConflictResolution.showDependencies(response.dependencies);
34
+ };
35
+ render() {
36
+ const adapter = this.getAdapter();
37
+ return _jsxs(LL_V_L, { id: 'page__check-usage', children: [_jsx(TS_PropRenderer.Vertical, { label: 'Collection', children: _jsx(TS_DropDown, { adapter: adapter, selected: this.state.selectedModule, onSelected: module => this.setState({ selectedModule: module }) }) }), _jsx(TS_PropRenderer.Vertical, { label: 'Item ID', children: _jsx(TS_Input, { type: 'text', value: this.state.itemId, onChange: val => this.setState({ itemId: val }) }) }), _jsx(Button, { onClick: this.checkUsage, children: "Check Usage" }, 'upgrade-all-test')] });
38
+ }
39
+ }
@@ -0,0 +1,10 @@
1
+ #page__check-usage {
2
+ width: 100%;
3
+ height: 100%;
4
+ padding: 20px;
5
+ gap: 20px;
6
+
7
+ .ts-dropdown {
8
+ width: 300px;
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ import { AppToolsScreen } from '@nu-art/thunderstorm-frontend/index';
2
+ export declare const ATSGroup_ConflictResolution: AppToolsScreen[];
package/_ats/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { ATS_ConflictResolution } from './ATS_ConflictResolution/ATS_ConflictResolution.js';
2
+ export const ATSGroup_ConflictResolution = [
3
+ ATS_ConflictResolution.screen,
4
+ ];
@@ -0,0 +1 @@
1
+ export * from './show-conflict-resolution.js';
@@ -0,0 +1 @@
1
+ export * from './show-conflict-resolution.js';
@@ -0,0 +1,6 @@
1
+ import { DBEntityDependencies } from '@nu-art/thunderstorm-shared';
2
+ import { ThunderDispatcher } from '@nu-art/thunderstorm-frontend/index';
3
+ export interface OnShowConflictResolution {
4
+ __onShowConflictResolution: (dependencies?: DBEntityDependencies) => void;
5
+ }
6
+ export declare const dispatch_ShowConflictResolution: ThunderDispatcher<OnShowConflictResolution, "__onShowConflictResolution", [dependencies?: DBEntityDependencies | undefined], void>;
@@ -0,0 +1,2 @@
1
+ import { ThunderDispatcher } from '@nu-art/thunderstorm-frontend/index';
2
+ export const dispatch_ShowConflictResolution = new ThunderDispatcher('__onShowConflictResolution');
@@ -0,0 +1,13 @@
1
+ import { DBEntityDependencies } from '@nu-art/thunderstorm-shared';
2
+ import { Module, TypedMap } from '@nu-art/ts-common';
3
+ import { ConflictResolutionItem } from '@nu-art/conflict-resolution-shared';
4
+ declare class ModuleFE_ConflictResolution_Class extends Module {
5
+ private readonly conflictResolutionItems;
6
+ initDefaultHasDependencyResponse: () => void;
7
+ showDependencies: (dependencies: DBEntityDependencies) => void;
8
+ registerConflictResolutionItem: (items: ConflictResolutionItem<any> | ConflictResolutionItem<any>[]) => void;
9
+ getConflictResolutionItem: (dbKey: string) => ConflictResolutionItem<any> | undefined;
10
+ getConflictResolutionItemMap: () => TypedMap<ConflictResolutionItem<any>>;
11
+ }
12
+ export declare const ModuleFE_ConflictResolution: ModuleFE_ConflictResolution_Class;
13
+ export {};
@@ -0,0 +1,36 @@
1
+ import { DBEntityDependencyErrorType } from '@nu-art/thunderstorm-shared';
2
+ import { ModuleFE_XHR } from '@nu-art/thunderstorm-frontend/index';
3
+ import { BadImplementationException, Module, asArray } from '@nu-art/ts-common';
4
+ import { dispatch_ShowConflictResolution } from '../_dispatchers/index.js';
5
+ class ModuleFE_ConflictResolution_Class extends Module {
6
+ conflictResolutionItems = [];
7
+ initDefaultHasDependencyResponse = () => {
8
+ ModuleFE_XHR.setDefaultOnError(async (errorResponse, input, request) => {
9
+ if (errorResponse.errorResponse?.error?.type === DBEntityDependencyErrorType) {
10
+ dispatch_ShowConflictResolution.dispatchUI(errorResponse.errorResponse.error.data);
11
+ }
12
+ });
13
+ };
14
+ showDependencies = (dependencies) => {
15
+ dispatch_ShowConflictResolution.dispatchUI(dependencies);
16
+ };
17
+ registerConflictResolutionItem = (items) => {
18
+ const toAdd = asArray(items);
19
+ toAdd.forEach(item => {
20
+ const existing = this.conflictResolutionItems.find(_item => item.dbKey === _item.dbKey);
21
+ if (existing)
22
+ throw new BadImplementationException(`Conflict resolution item for dbKey ${item.dbKey} already registered!`);
23
+ this.conflictResolutionItems.push(item);
24
+ });
25
+ };
26
+ getConflictResolutionItem = (dbKey) => {
27
+ return this.conflictResolutionItems.find(item => item.dbKey === dbKey);
28
+ };
29
+ getConflictResolutionItemMap = () => {
30
+ return this.conflictResolutionItems.reduce((map, item) => {
31
+ map[item.dbKey] = item;
32
+ return map;
33
+ }, {});
34
+ };
35
+ }
36
+ export const ModuleFE_ConflictResolution = new ModuleFE_ConflictResolution_Class();
@@ -0,0 +1,15 @@
1
+ import { DBEntityDependencies } from '@nu-art/thunderstorm-shared';
2
+ import { Adapter, ComponentSync } from '@nu-art/thunderstorm-frontend/index';
3
+ import './ConflictResolutionTree.scss';
4
+ type Props = {
5
+ dependencies: DBEntityDependencies;
6
+ };
7
+ type State = {
8
+ treeAdapter: Adapter;
9
+ };
10
+ export declare class ConflictResolutionTree extends ComponentSync<Props, State> {
11
+ protected deriveStateFromProps(nextProps: Props, state: State): State;
12
+ private createAdapter;
13
+ render(): import("react/jsx-runtime").JSX.Element;
14
+ }
15
+ export {};
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AdapterBuilder, ComponentSync, TS_Tree } from '@nu-art/thunderstorm-frontend/index';
3
+ import { calculateConflictResolutionTree } from './tree-calculation.js';
4
+ import { ConflictResolutionTreeRenderers } from './tree-rendering.js';
5
+ import { ModuleFE_ConflictResolution } from '../../_modules/ModuleFE_ConflictResolution.js';
6
+ import './ConflictResolutionTree.scss';
7
+ export class ConflictResolutionTree extends ComponentSync {
8
+ deriveStateFromProps(nextProps, state) {
9
+ state.treeAdapter = this.createAdapter(nextProps.dependencies);
10
+ return state;
11
+ }
12
+ createAdapter(dependencies) {
13
+ const tree = calculateConflictResolutionTree(dependencies);
14
+ const conflictResolutionItemMap = ModuleFE_ConflictResolution.getConflictResolutionItemMap();
15
+ return AdapterBuilder()
16
+ .tree()
17
+ .multiRender(ConflictResolutionTreeRenderers(conflictResolutionItemMap))
18
+ .setData(tree)
19
+ .hideRoot()
20
+ .build();
21
+ }
22
+ render() {
23
+ return _jsx(TS_Tree, { adapter: this.state.treeAdapter, className: 'conflict-resolution-tree' });
24
+ }
25
+ }
@@ -0,0 +1,83 @@
1
+ @use '@nu-art/ts-styles' as styles;
2
+
3
+ .conflict-resolution-tree {
4
+ width: 100%;
5
+
6
+ .ts-tree__node {
7
+ padding: 0;
8
+
9
+ .ll_h_c {
10
+ height: 100%;
11
+ width: 100%;
12
+ font: inherit;
13
+ gap: 8px;
14
+ color: inherit;
15
+
16
+ .node-icon {
17
+ height: 20px;
18
+ width: 20px;
19
+ flex-shrink: 0;
20
+ display: flex;
21
+ justify-content: center;
22
+ align-items: center;
23
+ font: {
24
+ size: 18px;
25
+ weight: normal;
26
+ }
27
+ }
28
+
29
+ .ts-label {
30
+ width: 0;
31
+ height: 100%;
32
+ flex-grow: 1;
33
+
34
+ .ts-label__content {
35
+ height: 100%;
36
+ }
37
+
38
+ &.tooltip-active {
39
+ &::after {
40
+ width: 80%;
41
+ white-space: pre-wrap;
42
+ }
43
+ }
44
+ }
45
+ }
46
+
47
+ //Checked Item
48
+ &.depth-0 {
49
+ height: 30px;
50
+ background: styles.dark-blue(3);
51
+ color: #fff;
52
+ font: {
53
+ size: 14px;
54
+ weight: bold;
55
+ }
56
+
57
+ //Add border to the children container when the node is opened
58
+ & + .ts-tree__children-container {
59
+ border-bottom: 2px solid styles.dark-blue(3);
60
+ }
61
+
62
+ .ts-label .ts-label__content {
63
+ line-height: 30px;
64
+ }
65
+ }
66
+
67
+ //Conflicting Collections
68
+ &.depth-1 {
69
+ height: 26px;
70
+ padding-left: 8px;
71
+ }
72
+
73
+ //Conflicting Items
74
+ &.depth-2 {
75
+ height: 22px;
76
+ padding-left: 16px;
77
+
78
+ .ts-label .ts-label__content {
79
+ line-height: 22px;
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,3 @@
1
+ import { DBEntityDependencies } from '@nu-art/thunderstorm-shared';
2
+ import { ConflictResolutionTree } from './types.js';
3
+ export declare const calculateConflictResolutionTree: (dependencies: DBEntityDependencies) => ConflictResolutionTree["nodeType"];
@@ -0,0 +1,47 @@
1
+ import { RuntimeModules, StaticLogger, _keys } from '@nu-art/ts-common';
2
+ const getItem = (dbKey, itemId) => {
3
+ const module = RuntimeModules().filter(module => module.dbDef?.dbKey === dbKey)[0];
4
+ if (!module) {
5
+ StaticLogger.logWarning(`Could not get module for dbKey ${dbKey}`);
6
+ return;
7
+ }
8
+ const item = module.cache.unique(itemId);
9
+ if (!item)
10
+ StaticLogger.logWarning(`Could not get item for dbKey ${dbKey} and id ${itemId}`);
11
+ return item;
12
+ };
13
+ export const calculateConflictResolutionTree = (dependencies) => {
14
+ const checkedItemIds = _keys(dependencies.dependencyMap);
15
+ return {
16
+ type: 'root',
17
+ alwaysExpanded: true,
18
+ item: {},
19
+ _children: checkedItemIds.map(id => calculateConflictResolutionTree_CheckedItem(dependencies.dependencyMap, id, dependencies.dbKey)),
20
+ };
21
+ };
22
+ const calculateConflictResolutionTree_CheckedItem = (dependencyMap, itemId, dbKey) => {
23
+ const conflictingCollectionKeys = _keys(dependencyMap[itemId]);
24
+ const item = getItem(dbKey, itemId);
25
+ return {
26
+ type: 'checkedItem',
27
+ item: { itemId, dbKey, item },
28
+ alwaysExpanded: false,
29
+ _children: conflictingCollectionKeys.map(dbKey => calculateConflictResolutionTree_ConflictingCollection(dbKey, dependencyMap[itemId][dbKey])),
30
+ };
31
+ };
32
+ const calculateConflictResolutionTree_ConflictingCollection = (dbKey, conflictingItemIds) => {
33
+ return {
34
+ type: 'conflictingCollection',
35
+ item: { dbKey },
36
+ alwaysExpanded: false,
37
+ _children: conflictingItemIds.map(id => calculateConflictResolutionTree_ConflictingItem(dbKey, id))
38
+ };
39
+ };
40
+ const calculateConflictResolutionTree_ConflictingItem = (dbKey, itemId) => {
41
+ const item = getItem(dbKey, itemId);
42
+ return {
43
+ type: 'conflictingItem',
44
+ item: { dbKey, itemId, item },
45
+ alwaysExpanded: false,
46
+ };
47
+ };
@@ -0,0 +1,4 @@
1
+ import { ConflictResolutionTree_RendererMap } from './types.js';
2
+ import { ConflictResolutionItem } from '@nu-art/conflict-resolution-shared';
3
+ import { TypedMap } from '@nu-art/ts-common';
4
+ export declare const ConflictResolutionTreeRenderers: (map: TypedMap<ConflictResolutionItem<any>>) => ConflictResolutionTree_RendererMap;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Label, ModuleFE_Thunderstorm } from '@nu-art/thunderstorm-frontend/index';
3
+ const renderTreeNode_CheckedItem = (props, map) => {
4
+ const crItem = map[props.item.dbKey];
5
+ let content;
6
+ if (!crItem || !props.item.item)
7
+ content = props.item.itemId;
8
+ else
9
+ content = crItem.renderer(props.item.item) ?? props.item.itemId;
10
+ return _jsx(Label, { className: 'conflict-resolution-tree__checked-item', tooltip: content, children: content });
11
+ };
12
+ const renderTreeNode_ConflictingCollection = (props, map) => {
13
+ const crItem = map[props.item.dbKey];
14
+ if (!crItem)
15
+ return _jsx(_Fragment, { children: props.item.dbKey });
16
+ return _jsx(_Fragment, { children: crItem.collectionRenderer(props.item.dbKey) });
17
+ };
18
+ const renderTreeNode_ConflictingItem = (props, map) => {
19
+ const crItem = map[props.item.dbKey];
20
+ let content;
21
+ if (!crItem || !props.item.item)
22
+ content = props.item.itemId;
23
+ else
24
+ content = crItem.renderer(props.item.item) ?? props.item.itemId;
25
+ return _jsx(Label, { className: 'conflict-resolution-tree__conflicting-item', tooltip: content, onClick: () => ModuleFE_Thunderstorm.copyToClipboard(props.item.itemId), children: content });
26
+ };
27
+ export const ConflictResolutionTreeRenderers = (map) => ({
28
+ root: () => _jsx(_Fragment, {}),
29
+ checkedItem: (props) => renderTreeNode_CheckedItem(props, map),
30
+ conflictingCollection: (props) => renderTreeNode_ConflictingCollection(props, map),
31
+ conflictingItem: (props) => renderTreeNode_ConflictingItem(props, map),
32
+ });
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { TreeNode, TreeType } from '@nu-art/thunderstorm-frontend/index';
3
+ import { DBProto, UniqueId } from '@nu-art/ts-common';
4
+ type Props_CheckedItem = {
5
+ itemId: UniqueId;
6
+ dbKey: string;
7
+ item?: DBProto<any>['dbType'];
8
+ };
9
+ type Props_ConflictingCollection = {
10
+ dbKey: string;
11
+ };
12
+ type Props_ConflictingItem = {
13
+ itemId: UniqueId;
14
+ dbKey: string;
15
+ item?: DBProto<any>['dbType'];
16
+ };
17
+ type ConflictResolutionTree_Map = {
18
+ root: {};
19
+ checkedItem: Props_CheckedItem;
20
+ conflictingCollection: Props_ConflictingCollection;
21
+ conflictingItem: Props_ConflictingItem;
22
+ };
23
+ export type ConflictResolutionTree = TreeType<ConflictResolutionTree_Map>;
24
+ export type ConflictResolutionTree_RendererProps<K extends keyof ConflictResolutionTree['renderer']> = {
25
+ item: ConflictResolutionTree_Map[K];
26
+ node: TreeNode;
27
+ };
28
+ export type ConflictResolutionTree_RendererMap = {
29
+ [K in keyof ConflictResolutionTree['renderer']]: React.ComponentType<ConflictResolutionTree_RendererProps<K>>;
30
+ };
31
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { DBEntityDependencies } from '@nu-art/thunderstorm-shared';
2
+ import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
3
+ import './Overlay_ConflictResolution.scss';
4
+ import { OnShowConflictResolution } from '../../_dispatchers/index.js';
5
+ type State = {
6
+ dependencies?: DBEntityDependencies;
7
+ };
8
+ export declare class Overlay_ConflictResolution extends ComponentSync<{}, State> implements OnShowConflictResolution {
9
+ __onShowConflictResolution: (dependencies?: DBEntityDependencies) => void;
10
+ render(): import("react/jsx-runtime").JSX.Element;
11
+ }
12
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
3
+ import './Overlay_ConflictResolution.scss';
4
+ import { Panel_ConflictResolution } from '../Panel_ConflictResolution/Panel_ConflictResolution.js';
5
+ export class Overlay_ConflictResolution extends ComponentSync {
6
+ __onShowConflictResolution = (dependencies) => {
7
+ this.setState({ dependencies });
8
+ };
9
+ render() {
10
+ if (!this.state.dependencies)
11
+ return _jsx(_Fragment, {});
12
+ return _jsx(Panel_ConflictResolution, { dependencies: this.state.dependencies });
13
+ }
14
+ }
@@ -0,0 +1,23 @@
1
+ import { DBEntityDependencies } from '@nu-art/thunderstorm-shared';
2
+ import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
3
+ import './Panel_ConflictResolution.scss';
4
+ type Props = {
5
+ dependencies: DBEntityDependencies;
6
+ };
7
+ type State = {
8
+ dependencies: DBEntityDependencies;
9
+ expanded?: boolean;
10
+ };
11
+ export declare class Panel_ConflictResolution extends ComponentSync<Props, State> {
12
+ protected deriveStateFromProps(nextProps: Props, state: State): State;
13
+ private resolveEntityLabel;
14
+ private closePanel;
15
+ private resolveAmounts;
16
+ private expand;
17
+ render(): import("react/jsx-runtime").JSX.Element;
18
+ private render_Header;
19
+ private render_Body;
20
+ private render_Body_Closed;
21
+ private render_Body_Expanded;
22
+ }
23
+ export {};
@@ -0,0 +1,54 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Button, ComponentSync, LL_H_C, LL_V_L } from '@nu-art/thunderstorm-frontend/index';
3
+ import { _keys, _values, filterDuplicates, flatArray, RuntimeModules } from '@nu-art/ts-common';
4
+ import { dispatch_ShowConflictResolution } from '../../_dispatchers/index.js';
5
+ import { TS_Icons } from '@nu-art/ts-styles/icons/index';
6
+ import './Panel_ConflictResolution.scss';
7
+ import { ConflictResolutionTree } from '../ConflictResolutionTree/ConflictResolutionTree.js';
8
+ export class Panel_ConflictResolution extends ComponentSync {
9
+ deriveStateFromProps(nextProps, state) {
10
+ state.expanded ??= false;
11
+ state.dependencies = nextProps.dependencies;
12
+ return state;
13
+ }
14
+ // ##################### Logic #####################
15
+ resolveEntityLabel = () => {
16
+ const module = RuntimeModules().filter(module => module.dbDef?.dbKey === this.props.dependencies.dbKey)[0];
17
+ return module?.dbDef.entityName ?? 'Entity';
18
+ };
19
+ closePanel = () => {
20
+ dispatch_ShowConflictResolution.dispatchUI();
21
+ };
22
+ resolveAmounts = () => {
23
+ const dependencies = this.props.dependencies;
24
+ const dependencyResults = _values(dependencies.dependencyMap);
25
+ const collectionKeys = filterDuplicates(dependencyResults.map(result => _keys(result)).flat());
26
+ const items = filterDuplicates(flatArray(dependencyResults.map(result => _values(result))));
27
+ return {
28
+ collections: collectionKeys.length,
29
+ items: items.length,
30
+ };
31
+ };
32
+ expand = () => {
33
+ this.setState({ expanded: true });
34
+ };
35
+ // ##################### Render #####################
36
+ render() {
37
+ return _jsxs(LL_V_L, { id: 'panel__conflict-resolution', className: this.state.expanded ? 'expanded' : undefined, children: [this.render_Header(), this.render_Body()] });
38
+ }
39
+ render_Header = () => {
40
+ return _jsxs(LL_H_C, { className: 'panel__conflict-resolution__header', children: [this.resolveEntityLabel(), " Dependencies", _jsx(TS_Icons.x.component, { onClick: () => this.closePanel() })] });
41
+ };
42
+ render_Body = () => {
43
+ if (!this.state.expanded)
44
+ return this.render_Body_Closed();
45
+ return this.render_Body_Expanded();
46
+ };
47
+ render_Body_Closed = () => {
48
+ const amounts = this.resolveAmounts();
49
+ return _jsxs(LL_V_L, { className: 'panel__conflict-resolution__body-closed', children: [_jsxs("p", { className: 'toast__conflict-resolution__body', children: [this.resolveEntityLabel(), " has ", amounts.items, " dependencies across ", amounts.collections, " collections"] }), _jsx(Button, { variant: 'primary', onClick: this.expand, children: "Show Dependencies" })] });
50
+ };
51
+ render_Body_Expanded = () => {
52
+ return _jsx("div", { className: 'panel__conflict-resolution__tree-wrapper', children: _jsx(ConflictResolutionTree, { dependencies: this.state.dependencies }) });
53
+ };
54
+ }
@@ -0,0 +1,71 @@
1
+ @use '@nu-art/ts-styles' as styles;
2
+
3
+ #panel__conflict-resolution {
4
+ width: 280px;
5
+ height: 150px;
6
+ position: fixed;
7
+ background: #fff;
8
+ border-radius: 10px;
9
+ border: 2px solid styles.dark-blue(2);
10
+ top: 20px;
11
+ right: 20px;
12
+ transition: height 300ms ease-out,
13
+ width 300ms ease-out;
14
+ animation: slide-in 300ms ease-out forwards;
15
+ overflow: hidden;
16
+
17
+ .panel__conflict-resolution__header {
18
+ width: 100%;
19
+ height: 30px;
20
+ background: styles.dark-blue(2);
21
+ gap: 10px;
22
+ justify-content: space-between;
23
+ padding-left: 8px;
24
+ color: #fff;
25
+ font: {
26
+ size: 15px;
27
+ weight: bold;
28
+ }
29
+
30
+ .icon--wrapper {
31
+ width: 30px;
32
+ height: 30px;
33
+ padding: 8px;
34
+ @include styles.mouse-interactive-icon(#fff);
35
+ }
36
+ }
37
+
38
+ .panel__conflict-resolution__body-closed {
39
+ width: 100%;
40
+ height: calc(100% - 30px);
41
+ padding: 10px;
42
+ gap: 10px;
43
+ justify-content: space-between;
44
+
45
+ p {
46
+ padding: 0;
47
+ margin: 0;
48
+ white-space: pre-wrap;
49
+ }
50
+ }
51
+
52
+ .panel__conflict-resolution__tree-wrapper {
53
+ width: 100%;
54
+ height: calc(100% - 30px);
55
+ overflow-y: auto;
56
+ }
57
+
58
+ &.expanded {
59
+ width: 600px;
60
+ height: calc(100vh - 40px);
61
+ }
62
+ }
63
+
64
+ @keyframes slide-in {
65
+ from {
66
+ transform: translateX(150%);
67
+ }
68
+ to {
69
+ transform: translateX(0);
70
+ }
71
+ }
package/_ui/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Overlay_ConflictResolution/Overlay_ConflictResolution.js';
package/_ui/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './Overlay_ConflictResolution/Overlay_ConflictResolution.js';
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@nu-art/conflict-resolution-frontend",
3
+ "version": "0.400.7",
4
+ "description": "Conflict Resolution Frontend",
5
+ "keywords": [
6
+ "TacB0sS",
7
+ "express",
8
+ "infra",
9
+ "nu-art",
10
+ "thunderstorm",
11
+ "typescript"
12
+ ],
13
+ "homepage": "https://github.com/nu-art-js/thunderstorm",
14
+ "bugs": {
15
+ "url": "https://github.com/nu-art-js/thunderstorm/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@github.com:nu-art-js/thunderstorm.git"
20
+ },
21
+ "license": "Apache-2.0",
22
+ "author": "TacB0sS",
23
+ "scripts": {
24
+ "build": "tsc"
25
+ },
26
+ "contributors": [
27
+ {
28
+ "name": "TacB0sS"
29
+ },
30
+ {
31
+ "name": "Cipher",
32
+ "url": "https://www.linkedin.com/in/itay-leybovich-470b87229/"
33
+ }
34
+ ],
35
+ "publishConfig": {
36
+ "directory": "dist",
37
+ "linkDirectory": true
38
+ },
39
+ "dependencies": {
40
+ "@nu-art/conflict-resolution-shared": "0.400.7",
41
+ "@nu-art/thunderstorm-frontend": "0.400.7",
42
+ "@nu-art/thunderstorm-shared": "0.400.7",
43
+ "@nu-art/ts-common": "0.400.7",
44
+ "@nu-art/ts-styles": "0.400.7",
45
+ "react": "^18.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/react": "^18.0.0"
49
+ },
50
+ "unitConfig": {
51
+ "type": "typescript-lib"
52
+ },
53
+ "type": "module",
54
+ "exports": {
55
+ ".": {
56
+ "types": "./index.d.ts",
57
+ "import": "./index.js"
58
+ },
59
+ "./*": {
60
+ "types": "./*.d.ts",
61
+ "import": "./*.js"
62
+ }
63
+ }
64
+ }