@boarteam/boar-pack-common-frontend 3.4.0 → 4.1.0
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/components/ChangesModal/ChangesModal.d.ts +37 -0
- package/dist/components/ChangesModal/ChangesModal.js +143 -0
- package/dist/components/ChangesModal/ChangesModal.js.map +1 -0
- package/dist/components/ChangesModal/ChangesTab.d.ts +7 -0
- package/dist/components/ChangesModal/ChangesTab.js +29 -0
- package/dist/components/ChangesModal/ChangesTab.js.map +1 -0
- package/dist/components/ChangesModal/ConflictsTab.d.ts +10 -0
- package/dist/components/ChangesModal/ConflictsTab.js +105 -0
- package/dist/components/ChangesModal/ConflictsTab.js.map +1 -0
- package/dist/components/ChangesModal/ErrorsTab.d.ts +5 -0
- package/dist/components/ChangesModal/ErrorsTab.js +27 -0
- package/dist/components/ChangesModal/ErrorsTab.js.map +1 -0
- package/dist/components/ChangesModal/NewRecordsTab.d.ts +12 -0
- package/dist/components/ChangesModal/NewRecordsTab.js +24 -0
- package/dist/components/ChangesModal/NewRecordsTab.js.map +1 -0
- package/dist/components/ChangesModal/ResultsTab.d.ts +8 -0
- package/dist/components/ChangesModal/ResultsTab.js +12 -0
- package/dist/components/ChangesModal/ResultsTab.js.map +1 -0
- package/dist/components/ChangesModal/index.d.ts +1 -0
- package/dist/components/ChangesModal/index.js +5 -0
- package/dist/components/ChangesModal/index.js.map +1 -0
- package/dist/components/Comment/Comment.d.ts +12 -0
- package/dist/components/Comment/Comment.js +25 -0
- package/dist/components/Comment/Comment.js.map +1 -0
- package/dist/components/Comment/CommentAvatar.d.ts +7 -0
- package/dist/components/Comment/CommentAvatar.js +22 -0
- package/dist/components/Comment/CommentAvatar.js.map +1 -0
- package/dist/components/Comment/CommentForm.d.ts +6 -0
- package/dist/components/Comment/CommentForm.js +17 -0
- package/dist/components/Comment/CommentForm.js.map +1 -0
- package/dist/components/Comment/CommentFormModal.d.ts +10 -0
- package/dist/components/Comment/CommentFormModal.js +13 -0
- package/dist/components/Comment/CommentFormModal.js.map +1 -0
- package/dist/components/Comment/index.js +11 -0
- package/dist/components/Comment/index.js.map +1 -0
- package/dist/components/Descriptions/Descriptions.d.ts +4 -0
- package/dist/components/Descriptions/Descriptions.js +218 -0
- package/dist/components/Descriptions/Descriptions.js.map +1 -0
- package/dist/components/Descriptions/DescriptionsCreateModal.d.ts +3 -0
- package/dist/components/Descriptions/DescriptionsCreateModal.js +30 -0
- package/dist/components/Descriptions/DescriptionsCreateModal.js.map +1 -0
- package/dist/components/Descriptions/descriptionTypes.d.ts +68 -0
- package/dist/components/Descriptions/descriptionTypes.js +9 -0
- package/dist/components/Descriptions/descriptionTypes.js.map +1 -0
- package/dist/components/Descriptions/index.js +11 -0
- package/dist/components/Descriptions/index.js.map +1 -0
- package/dist/components/Descriptions/useContentViewMode.d.ts +10 -0
- package/dist/components/Descriptions/useContentViewMode.js +19 -0
- package/dist/components/Descriptions/useContentViewMode.js.map +1 -0
- package/dist/components/Descriptions/useDescriptionColumns.d.ts +8 -0
- package/dist/components/Descriptions/useDescriptionColumns.js +27 -0
- package/dist/components/Descriptions/useDescriptionColumns.js.map +1 -0
- package/dist/components/Inputs/DateRange.d.ts +8 -0
- package/dist/components/Inputs/DateRange.js +61 -0
- package/dist/components/Inputs/DateRange.js.map +1 -0
- package/dist/components/Inputs/MultiStringSelect.d.ts +5 -0
- package/dist/components/Inputs/MultiStringSelect.js +10 -0
- package/dist/components/Inputs/MultiStringSelect.js.map +1 -0
- package/dist/components/Inputs/NumberInputHandlingNewRecord.d.ts +3 -0
- package/dist/components/Inputs/NumberInputHandlingNewRecord.js +11 -0
- package/dist/components/Inputs/NumberInputHandlingNewRecord.js.map +1 -0
- package/dist/components/Inputs/NumberSwitcher.d.ts +8 -0
- package/dist/components/Inputs/NumberSwitcher.js +13 -0
- package/dist/components/Inputs/NumberSwitcher.js.map +1 -0
- package/dist/components/Inputs/Password.d.ts +3 -0
- package/dist/components/Inputs/Password.js +18 -0
- package/dist/components/Inputs/Password.js.map +1 -0
- package/dist/components/Inputs/RelationSelect.d.ts +21 -0
- package/dist/components/Inputs/RelationSelect.js +58 -0
- package/dist/components/Inputs/RelationSelect.js.map +1 -0
- package/dist/components/Inputs/SearchSelect.d.ts +12 -0
- package/dist/components/Inputs/SearchSelect.js +40 -0
- package/dist/components/Inputs/SearchSelect.js.map +1 -0
- package/dist/components/Inputs/filterDropdowns.d.ts +11 -0
- package/dist/components/Inputs/filterDropdowns.js +56 -0
- package/dist/components/Inputs/filterDropdowns.js.map +1 -0
- package/dist/components/Inputs/index.js +13 -0
- package/dist/components/Inputs/index.js.map +1 -0
- package/dist/components/Inputs/useCheckConnection.d.ts +13 -0
- package/dist/components/Inputs/useCheckConnection.js +53 -0
- package/dist/components/Inputs/useCheckConnection.js.map +1 -0
- package/dist/components/List/List.d.ts +3 -0
- package/dist/components/List/List.js +144 -0
- package/dist/components/List/List.js.map +1 -0
- package/dist/components/List/index.js +9 -0
- package/dist/components/List/index.js.map +1 -0
- package/dist/components/List/listTypes.d.ts +30 -0
- package/dist/components/List/listTypes.js +3 -0
- package/dist/components/List/listTypes.js.map +1 -0
- package/dist/components/QuestionMarkHint/QuestionMarkHint.d.ts +7 -0
- package/dist/components/QuestionMarkHint/QuestionMarkHint.js +16 -0
- package/dist/components/QuestionMarkHint/QuestionMarkHint.js.map +1 -0
- package/dist/components/QuestionMarkHint/index.js +5 -0
- package/dist/components/QuestionMarkHint/index.js.map +1 -0
- package/dist/components/Table/BulkDeleteButton.d.ts +8 -0
- package/dist/components/Table/BulkDeleteButton.js +27 -0
- package/dist/components/Table/BulkDeleteButton.js.map +1 -0
- package/dist/components/Table/BulkEditButton.d.ts +11 -0
- package/dist/components/Table/BulkEditButton.js +66 -0
- package/dist/components/Table/BulkEditButton.js.map +1 -0
- package/dist/components/Table/CreateEntityModal.d.ts +25 -0
- package/dist/components/Table/CreateEntityModal.js +23 -0
- package/dist/components/Table/CreateEntityModal.js.map +1 -0
- package/dist/components/Table/DeleteButton.d.ts +4 -0
- package/dist/components/Table/DeleteButton.js +28 -0
- package/dist/components/Table/DeleteButton.js.map +1 -0
- package/dist/components/Table/Table.d.ts +6 -0
- package/dist/components/Table/Table.js +154 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Table/getTableDataQueryParams.d.ts +15 -0
- package/dist/components/Table/getTableDataQueryParams.js +37 -0
- package/dist/components/Table/getTableDataQueryParams.js.map +1 -0
- package/{src/components/Table/index.ts → dist/components/Table/index.d.ts} +1 -1
- package/dist/components/Table/index.js +14 -0
- package/dist/components/Table/index.js.map +1 -0
- package/dist/components/Table/tableTools.d.ts +38 -0
- package/dist/components/Table/tableTools.js +185 -0
- package/dist/components/Table/tableTools.js.map +1 -0
- package/dist/components/Table/tableTypes.d.ts +145 -0
- package/dist/components/Table/tableTypes.js +3 -0
- package/dist/components/Table/tableTypes.js.map +1 -0
- package/dist/components/Table/useBulkEditing.d.ts +30 -0
- package/dist/components/Table/useBulkEditing.js +79 -0
- package/dist/components/Table/useBulkEditing.js.map +1 -0
- package/dist/components/Table/useColumnsSets.d.ts +22 -0
- package/dist/components/Table/useColumnsSets.js +82 -0
- package/dist/components/Table/useColumnsSets.js.map +1 -0
- package/dist/components/Table/useCreation.d.ts +21 -0
- package/dist/components/Table/useCreation.js +75 -0
- package/dist/components/Table/useCreation.js.map +1 -0
- package/dist/components/Table/useEditableTable.d.ts +7 -0
- package/dist/components/Table/useEditableTable.js +63 -0
- package/dist/components/Table/useEditableTable.js.map +1 -0
- package/dist/components/Table/useImportExport.d.ts +35 -0
- package/dist/components/Table/useImportExport.js +207 -0
- package/dist/components/Table/useImportExport.js.map +1 -0
- package/dist/components/index.js +10 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/ApiError.d.ts +16 -0
- package/dist/tools/ApiError.js +13 -0
- package/dist/tools/ApiError.js.map +1 -0
- package/dist/tools/WebsocketClient.d.ts +38 -0
- package/dist/tools/WebsocketClient.js +114 -0
- package/dist/tools/WebsocketClient.js.map +1 -0
- package/{src/tools/index.ts → dist/tools/index.d.ts} +1 -1
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/numberTools.d.ts +1 -0
- package/dist/tools/numberTools.js +10 -0
- package/dist/tools/numberTools.js.map +1 -0
- package/dist/tools/safetyRun.d.ts +2 -0
- package/dist/tools/safetyRun.js +10 -0
- package/dist/tools/safetyRun.js.map +1 -0
- package/dist/tools/useFullscreen.d.ts +6 -0
- package/dist/tools/useFullscreen.js +56 -0
- package/dist/tools/useFullscreen.js.map +1 -0
- package/dist/tools/useTabs.d.ts +2 -0
- package/dist/tools/useTabs.js +18 -0
- package/dist/tools/useTabs.js.map +1 -0
- package/package.json +6 -4
- package/src/components/ChangesModal/ChangesModal.tsx +0 -262
- package/src/components/ChangesModal/ChangesTab.tsx +0 -51
- package/src/components/ChangesModal/ConflictsTab.tsx +0 -176
- package/src/components/ChangesModal/ErrorsTab.tsx +0 -49
- package/src/components/ChangesModal/NewRecordsTab.tsx +0 -48
- package/src/components/ChangesModal/ResultsTab.tsx +0 -28
- package/src/components/ChangesModal/index.ts +0 -1
- package/src/components/Comment/Comment.tsx +0 -53
- package/src/components/Comment/CommentAvatar.tsx +0 -34
- package/src/components/Comment/CommentForm.tsx +0 -36
- package/src/components/Comment/CommentFormModal.tsx +0 -31
- package/src/components/Descriptions/Descriptions.tsx +0 -351
- package/src/components/Descriptions/DescriptionsCreateModal.tsx +0 -65
- package/src/components/Descriptions/descriptionTypes.ts +0 -74
- package/src/components/Descriptions/useContentViewMode.tsx +0 -28
- package/src/components/Descriptions/useDescriptionColumns.ts +0 -42
- package/src/components/Inputs/DateRange.tsx +0 -75
- package/src/components/Inputs/MultiStringSelect.tsx +0 -20
- package/src/components/Inputs/NumberInputHandlingNewRecord.tsx +0 -11
- package/src/components/Inputs/NumberSwitcher.tsx +0 -27
- package/src/components/Inputs/Password.tsx +0 -33
- package/src/components/Inputs/RelationSelect.tsx +0 -108
- package/src/components/Inputs/SearchSelect.tsx +0 -93
- package/src/components/Inputs/filterDropdowns.tsx +0 -141
- package/src/components/Inputs/useCheckConnection.tsx +0 -79
- package/src/components/List/List.tsx +0 -266
- package/src/components/List/listTypes.ts +0 -31
- package/src/components/QuestionMarkHint/QuestionMarkHint.tsx +0 -33
- package/src/components/Table/BulkDeleteButton.tsx +0 -55
- package/src/components/Table/BulkEditButton.tsx +0 -160
- package/src/components/Table/CreateEntityModal.tsx +0 -85
- package/src/components/Table/DeleteButton.tsx +0 -44
- package/src/components/Table/Table.tsx +0 -316
- package/src/components/Table/getTableDataQueryParams.ts +0 -79
- package/src/components/Table/tableTools.ts +0 -244
- package/src/components/Table/tableTypes.ts +0 -152
- package/src/components/Table/useBulkEditing.tsx +0 -128
- package/src/components/Table/useColumnsSets.tsx +0 -142
- package/src/components/Table/useCreation.tsx +0 -114
- package/src/components/Table/useEditableTable.tsx +0 -86
- package/src/components/Table/useImportExport.tsx +0 -312
- package/src/tools/ApiError.ts +0 -18
- package/src/tools/WebsocketClient.ts +0 -138
- package/src/tools/numberTools.ts +0 -6
- package/src/tools/safetyRun.ts +0 -5
- package/src/tools/useFullscreen.tsx +0 -62
- package/src/tools/useTabs.ts +0 -17
- /package/{src/components/Comment/index.ts → dist/components/Comment/index.d.ts} +0 -0
- /package/{src/components/Descriptions/index.ts → dist/components/Descriptions/index.d.ts} +0 -0
- /package/{src/components/Inputs/index.ts → dist/components/Inputs/index.d.ts} +0 -0
- /package/{src/components/List/index.ts → dist/components/List/index.d.ts} +0 -0
- /package/{src/components/QuestionMarkHint/index.ts → dist/components/QuestionMarkHint/index.d.ts} +0 -0
- /package/{src/components/index.ts → dist/components/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./safetyRun"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./useFullscreen"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./numberTools"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./useTabs"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./WebsocketClient"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./ApiError"), exports);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,0DAAgC;AAChC,wDAA8B;AAC9B,oDAA0B;AAC1B,4DAAkC;AAClC,qDAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dropTrailZeroes(str: string | undefined): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dropTrailZeroes = dropTrailZeroes;
|
|
4
|
+
function dropTrailZeroes(str) {
|
|
5
|
+
if (typeof str === 'string' && str.includes(".")) {
|
|
6
|
+
return str.replace(/\.?0*$/, "");
|
|
7
|
+
}
|
|
8
|
+
return str;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=numberTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberTools.js","sourceRoot":"","sources":["../../src/tools/numberTools.ts"],"names":[],"mappings":";;AAAA,0CAKC;AALD,SAAgB,eAAe,CAAC,GAAuB;IACrD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safetyRun = safetyRun;
|
|
4
|
+
function safetyRun(promise) {
|
|
5
|
+
promise?.catch((e) => {
|
|
6
|
+
console.error(e);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
exports.default = safetyRun;
|
|
10
|
+
//# sourceMappingURL=safetyRun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safetyRun.js","sourceRoot":"","sources":["../../src/tools/safetyRun.ts"],"names":[],"mappings":";;AAAA,8BAIC;AAJD,SAAgB,SAAS,CAAI,OAAoB;IAC/C,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFullscreen = useFullscreen;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const icons_1 = require("@ant-design/icons");
|
|
7
|
+
const antd_1 = require("antd");
|
|
8
|
+
const antd_style_1 = require("antd-style");
|
|
9
|
+
function changeFullScreen(fullscreen) {
|
|
10
|
+
if (fullscreen) {
|
|
11
|
+
document.documentElement.requestFullscreen().catch((e) => {
|
|
12
|
+
console.log(e);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else if (document.fullscreenElement) {
|
|
16
|
+
document.exitFullscreen().catch((e) => {
|
|
17
|
+
console.log(e);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const useStyles = (0, antd_style_1.createStyles)(({ token }) => {
|
|
22
|
+
return {
|
|
23
|
+
fullscreen: {
|
|
24
|
+
backgroundColor: token.colorBgLayout,
|
|
25
|
+
position: 'fixed',
|
|
26
|
+
top: 0,
|
|
27
|
+
left: 0,
|
|
28
|
+
zIndex: 100,
|
|
29
|
+
width: '100%',
|
|
30
|
+
height: '100%',
|
|
31
|
+
overflow: 'auto',
|
|
32
|
+
},
|
|
33
|
+
notFullscreen: {},
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
function useFullscreen() {
|
|
37
|
+
const [isFullscreen, setIsFullscreen] = (0, react_1.useState)(false);
|
|
38
|
+
const { styles } = useStyles();
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
|
+
const listener = () => {
|
|
41
|
+
setIsFullscreen(!!document.fullscreenElement);
|
|
42
|
+
};
|
|
43
|
+
document.addEventListener('fullscreenchange', listener);
|
|
44
|
+
return () => {
|
|
45
|
+
document.removeEventListener('fullscreenchange', listener);
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
const button = (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "text", onClick: () => changeFullScreen(!isFullscreen), children: isFullscreen ? (0, jsx_runtime_1.jsx)(icons_1.FullscreenExitOutlined, {}) : (0, jsx_runtime_1.jsx)(icons_1.FullscreenOutlined, {}) }, "fullscreen");
|
|
49
|
+
return {
|
|
50
|
+
isFullscreen,
|
|
51
|
+
setIsFullscreen,
|
|
52
|
+
fullscreenClassName: isFullscreen ? styles.fullscreen : styles.notFullscreen,
|
|
53
|
+
fullscreenButton: button,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=useFullscreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFullscreen.js","sourceRoot":"","sources":["../../src/tools/useFullscreen.tsx"],"names":[],"mappings":";;AAiCA,sCA4BC;;AA7DD,iCAA4C;AAC5C,6CAA+E;AAC/E,+BAA8B;AAC9B,2CAA0C;AAE1C,SAAS,gBAAgB,CAAC,UAAmB;IAC3C,IAAI,UAAU,EAAE,CAAC;QACf,QAAQ,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACvD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QACtC,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACpC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,yBAAY,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3C,OAAO;QACL,UAAU,EAAE;YACV,eAAe,EAAE,KAAK,CAAC,aAAa;YACpC,QAAQ,EAAE,OAAO;YACjB,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,MAAM;SACjB;QACD,aAAa,EAAE,EAAE;KAClB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAgB,aAAa;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACxD,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAE/B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAChD,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QACxD,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,MAAM,GAAG,uBAAC,aAAM,IAEpB,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,YAE7C,YAAY,CAAC,CAAC,CAAC,uBAAC,8BAAsB,KAAG,CAAC,CAAC,CAAC,uBAAC,0BAAkB,KAAG,IAJ/D,YAAY,CAKT,CAAC;IAEV,OAAO;QACL,YAAY;QACZ,eAAe;QACf,mBAAmB,EAAE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa;QAC5E,gBAAgB,EAAE,MAAM;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTabs = useTabs;
|
|
4
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useTabs(defaultTab) {
|
|
7
|
+
const [searchParams, setSearchParams] = (0, react_router_dom_1.useSearchParams)();
|
|
8
|
+
const [tab, setTab] = (0, react_1.useState)(() => {
|
|
9
|
+
return searchParams.get('tab') ?? defaultTab;
|
|
10
|
+
});
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
const newSearchParams = new URLSearchParams(searchParams);
|
|
13
|
+
newSearchParams.set('tab', tab);
|
|
14
|
+
setSearchParams(newSearchParams, { replace: true });
|
|
15
|
+
}, [tab]);
|
|
16
|
+
return [tab, setTab];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=useTabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTabs.js","sourceRoot":"","sources":["../../src/tools/useTabs.ts"],"names":[],"mappings":";;AAGA,0BAaC;AAhBD,uDAAmD;AACnD,iCAAmD;AAEnD,SAAgB,OAAO,CAAmB,UAAa;IACrD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,kCAAe,GAAE,CAAC;IAC1D,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAAI,GAAG,EAAE;QACrC,OAAO,YAAY,CAAC,GAAG,CAAC,KAAK,CAAM,IAAI,UAAU,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC;QAC1D,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,eAAe,CAAC,eAAe,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boarteam/boar-pack-common-frontend",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Common frontend package for Boar Pack",
|
|
5
5
|
"repository": "git@github.com:boarteam/boar-pack.git",
|
|
6
6
|
"author": "Andrew Balakirev <balakirev.andrey@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"main": "
|
|
8
|
+
"main": "dist/index",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
9
10
|
"files": [
|
|
10
|
-
"
|
|
11
|
+
"dist"
|
|
11
12
|
],
|
|
12
13
|
"publishConfig": {
|
|
13
14
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -48,7 +49,8 @@
|
|
|
48
49
|
"umi": "^4.1.5"
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
52
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json",
|
|
51
53
|
"yalc:push": "yalc push"
|
|
52
54
|
},
|
|
53
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "db759a35be3528d9970b7d2408d3b90d19bd7741"
|
|
54
56
|
}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { Badge, Button, message, Modal, Tabs } from "antd";
|
|
2
|
-
import { ProColumns } from "@ant-design/pro-components";
|
|
3
|
-
import { createStyles } from "antd-style";
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import ConflictsTab from "./ConflictsTab";
|
|
6
|
-
import ErrorsTab from "./ErrorsTab";
|
|
7
|
-
import ResultsTab from "./ResultsTab";
|
|
8
|
-
import NewRecordsTab, { TCreatedRecordsColumnsConfig } from "./NewRecordsTab";
|
|
9
|
-
import ChangesTab from "./ChangesTab";
|
|
10
|
-
import { TDiffResult } from "../Table/useImportExport";
|
|
11
|
-
import { CancelablePromise } from "@boarteam/boar-pack-users-frontend/dist/src/tools/api-client";
|
|
12
|
-
|
|
13
|
-
enum ModalTabs {
|
|
14
|
-
changes = "changes",
|
|
15
|
-
newRecords = "newRecords",
|
|
16
|
-
errors = "errors",
|
|
17
|
-
results = "results",
|
|
18
|
-
conflicts = "conflicts",
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type TServerErrorItem = { field: string; message: string };
|
|
22
|
-
|
|
23
|
-
export type TRelationalFields = Map<string, {
|
|
24
|
-
key: string,
|
|
25
|
-
data: {
|
|
26
|
-
[key: string]: any,
|
|
27
|
-
}
|
|
28
|
-
}>
|
|
29
|
-
|
|
30
|
-
export type TImportConflict = {
|
|
31
|
-
id: number;
|
|
32
|
-
version: number;
|
|
33
|
-
fields: Array<{
|
|
34
|
-
field: string;
|
|
35
|
-
current_value: any;
|
|
36
|
-
imported_value: any;
|
|
37
|
-
}>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type TImportResponse = {
|
|
41
|
-
errors?: Array<TServerErrorItem>,
|
|
42
|
-
conflicts?: Array<TImportConflict>,
|
|
43
|
-
created_count: number,
|
|
44
|
-
updated_count: number
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const useStyles = createStyles(() => {
|
|
48
|
-
return {
|
|
49
|
-
changesModal: {
|
|
50
|
-
".ant-modal-content": {
|
|
51
|
-
width: 800,
|
|
52
|
-
},
|
|
53
|
-
".ant-table-content": {
|
|
54
|
-
overflowX: "auto",
|
|
55
|
-
},
|
|
56
|
-
"ul": {
|
|
57
|
-
maxHeight: 500,
|
|
58
|
-
overflowY: "auto",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export function ChangesModal<
|
|
65
|
-
Entity,
|
|
66
|
-
ImportRequestParams,
|
|
67
|
-
>({
|
|
68
|
-
onClose,
|
|
69
|
-
onCommit,
|
|
70
|
-
changes,
|
|
71
|
-
relationalFields,
|
|
72
|
-
originRecordsColumnsConfig,
|
|
73
|
-
changedRecordsColumnsConfig,
|
|
74
|
-
createdRecordsColumnsConfig,
|
|
75
|
-
}: {
|
|
76
|
-
onCommit: (params: ImportRequestParams) => CancelablePromise<TImportResponse>,
|
|
77
|
-
onClose: () => void;
|
|
78
|
-
changes?: TDiffResult<Entity>,
|
|
79
|
-
relationalFields?: TRelationalFields,
|
|
80
|
-
originRecordsColumnsConfig: ProColumns<Entity>[],
|
|
81
|
-
changedRecordsColumnsConfig: ProColumns<Entity>[];
|
|
82
|
-
createdRecordsColumnsConfig: TCreatedRecordsColumnsConfig<Entity>;
|
|
83
|
-
}) {
|
|
84
|
-
const { styles } = useStyles();
|
|
85
|
-
const [activeTab, setActiveTab] = useState<string>(ModalTabs.changes);
|
|
86
|
-
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
87
|
-
const [importResponse, setImportResponse] = useState<TImportResponse>();
|
|
88
|
-
const [serverErrors, setServerErrors] = useState<TServerErrorItem[]>([]);
|
|
89
|
-
const [resolvedData, setResolvedData] = useState<Entity[]>();
|
|
90
|
-
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
if (serverErrors.length > 0) {
|
|
93
|
-
setActiveTab(ModalTabs.errors);
|
|
94
|
-
}
|
|
95
|
-
}, [serverErrors.length]);
|
|
96
|
-
|
|
97
|
-
if (!changes) return null;
|
|
98
|
-
|
|
99
|
-
const { created, updated, tableData } = changes;
|
|
100
|
-
|
|
101
|
-
const onCancel = () => {
|
|
102
|
-
setActiveTab(ModalTabs.changes);
|
|
103
|
-
setImportResponse(undefined);
|
|
104
|
-
setServerErrors([]);
|
|
105
|
-
setResolvedData([])
|
|
106
|
-
onClose();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const handleCommitClick = async () => {
|
|
110
|
-
// TODO: Client validation
|
|
111
|
-
// ...
|
|
112
|
-
setServerErrors([]);
|
|
113
|
-
setIsLoading(true);
|
|
114
|
-
|
|
115
|
-
const modifiedSource = (resolvedData && resolvedData.length > 0)
|
|
116
|
-
? resolvedData
|
|
117
|
-
: updated;
|
|
118
|
-
|
|
119
|
-
const payload: any = {
|
|
120
|
-
new: created,
|
|
121
|
-
modified: modifiedSource,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
onCommit(payload).then((res) => {
|
|
125
|
-
setImportResponse(res);
|
|
126
|
-
|
|
127
|
-
// Check conflicts
|
|
128
|
-
if (res.conflicts?.length) {
|
|
129
|
-
setActiveTab(ModalTabs.conflicts);
|
|
130
|
-
message.error("There are conflicts in the import. Please resolve them.");
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
setActiveTab(ModalTabs.results);
|
|
135
|
-
}).catch((err) => {
|
|
136
|
-
// TODO: Simplify
|
|
137
|
-
const status = err?.status || err?.statusCode || err?.response?.status;
|
|
138
|
-
const payload = err?.body || err?.response?.data || err?.data || err;
|
|
139
|
-
|
|
140
|
-
if ((status === 400 || payload?.statusCode === 400) && Array.isArray(payload?.errors)) {
|
|
141
|
-
setServerErrors(payload.errors);
|
|
142
|
-
message.error(payload.message || "Validation error");
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
console.error("Commit failed:", err);
|
|
147
|
-
message.error("Unexpected error while committing changes");
|
|
148
|
-
}).finally(() => {
|
|
149
|
-
setIsLoading(false);
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const tabList = [
|
|
154
|
-
{
|
|
155
|
-
key: ModalTabs.changes,
|
|
156
|
-
tab: "Changed values",
|
|
157
|
-
disabled: tableData.length === 0,
|
|
158
|
-
label: tableData.length ? (
|
|
159
|
-
<Badge
|
|
160
|
-
size="small"
|
|
161
|
-
color="blue"
|
|
162
|
-
count={tableData.length}
|
|
163
|
-
>
|
|
164
|
-
Changed Values
|
|
165
|
-
</Badge>
|
|
166
|
-
) : "Changed Values",
|
|
167
|
-
children: <ChangesTab
|
|
168
|
-
changedRecordsColumnsConfig={changedRecordsColumnsConfig}
|
|
169
|
-
updated={tableData}
|
|
170
|
-
/>,
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
key: ModalTabs.newRecords,
|
|
174
|
-
tab: "New records",
|
|
175
|
-
disabled: created.length === 0,
|
|
176
|
-
label: created.length ? (
|
|
177
|
-
<Badge
|
|
178
|
-
size="small"
|
|
179
|
-
color="blue"
|
|
180
|
-
count={created.length}
|
|
181
|
-
>
|
|
182
|
-
New Records
|
|
183
|
-
</Badge>
|
|
184
|
-
) : "New Records",
|
|
185
|
-
children: <NewRecordsTab
|
|
186
|
-
createdRecordsColumnsConfig={createdRecordsColumnsConfig}
|
|
187
|
-
created={created}
|
|
188
|
-
/>,
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
key: ModalTabs.errors,
|
|
192
|
-
tab: "Import errors",
|
|
193
|
-
disabled: serverErrors.length === 0,
|
|
194
|
-
label: serverErrors.length ? (
|
|
195
|
-
<Badge size="small" count={serverErrors.length}>
|
|
196
|
-
Errors
|
|
197
|
-
</Badge>
|
|
198
|
-
) : "Errors",
|
|
199
|
-
children: <ErrorsTab serverErrors={serverErrors} />,
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
key: ModalTabs.conflicts,
|
|
203
|
-
tab: "Import conflicts",
|
|
204
|
-
disabled: !importResponse || importResponse.conflicts?.length === 0,
|
|
205
|
-
label: importResponse?.conflicts?.length ? (
|
|
206
|
-
<Badge size="small" count={importResponse.conflicts.length}>
|
|
207
|
-
Conflicts
|
|
208
|
-
</Badge>
|
|
209
|
-
) : "Conflicts",
|
|
210
|
-
children: <ConflictsTab<Entity>
|
|
211
|
-
conflicts={importResponse?.conflicts}
|
|
212
|
-
setResolvedData={setResolvedData}
|
|
213
|
-
relationalFields={relationalFields}
|
|
214
|
-
originColumns={originRecordsColumnsConfig}
|
|
215
|
-
/>,
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
key: ModalTabs.results,
|
|
219
|
-
tab: "Import results",
|
|
220
|
-
disabled: !importResponse || !!importResponse.conflicts?.length,
|
|
221
|
-
label: "Results",
|
|
222
|
-
children: <ResultsTab importStatistic={
|
|
223
|
-
{
|
|
224
|
-
created: importResponse?.created_count || 0,
|
|
225
|
-
updated: importResponse?.updated_count || 0,
|
|
226
|
-
}
|
|
227
|
-
} />,
|
|
228
|
-
},
|
|
229
|
-
];
|
|
230
|
-
|
|
231
|
-
return (
|
|
232
|
-
<Modal
|
|
233
|
-
title="Preview changes"
|
|
234
|
-
open={true}
|
|
235
|
-
onCancel={onCancel}
|
|
236
|
-
footer={[
|
|
237
|
-
<Button key="close" onClick={onCancel}>Close</Button>,
|
|
238
|
-
<Button
|
|
239
|
-
loading={isLoading}
|
|
240
|
-
type="primary"
|
|
241
|
-
key="approve"
|
|
242
|
-
onClick={handleCommitClick}
|
|
243
|
-
disabled={
|
|
244
|
-
importResponse?.conflicts?.length === 0
|
|
245
|
-
|| serverErrors.length > 0
|
|
246
|
-
|| updated.length === 0 && created.length === 0
|
|
247
|
-
}
|
|
248
|
-
>
|
|
249
|
-
Commit
|
|
250
|
-
</Button>,
|
|
251
|
-
]}
|
|
252
|
-
className={styles.changesModal}
|
|
253
|
-
>
|
|
254
|
-
<Tabs
|
|
255
|
-
activeKey={activeTab}
|
|
256
|
-
onChange={setActiveTab}
|
|
257
|
-
defaultActiveKey="1"
|
|
258
|
-
items={tabList}
|
|
259
|
-
/>
|
|
260
|
-
</Modal>
|
|
261
|
-
)
|
|
262
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import diff from "deep-diff";
|
|
2
|
-
import { Tag } from "antd";
|
|
3
|
-
import { ProColumns } from "@ant-design/pro-components";
|
|
4
|
-
import { TDiffResult, TUpdatedDiffResult } from "../Table/useImportExport";
|
|
5
|
-
import ProTable from "@ant-design/pro-table";
|
|
6
|
-
|
|
7
|
-
function ChangesTab<Entity> ({ updated, changedRecordsColumnsConfig }: {
|
|
8
|
-
updated: TDiffResult<Entity>['tableData'],
|
|
9
|
-
changedRecordsColumnsConfig: ProColumns<Entity>[]
|
|
10
|
-
}) {
|
|
11
|
-
if (!updated.length) {
|
|
12
|
-
return <>
|
|
13
|
-
No changes found.
|
|
14
|
-
</>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const updateColumns = [
|
|
18
|
-
...changedRecordsColumnsConfig,
|
|
19
|
-
{
|
|
20
|
-
title: "Changes",
|
|
21
|
-
dataIndex: "diff",
|
|
22
|
-
key: "diff",
|
|
23
|
-
render: (diff: diff.Diff<any, any>[]) => (
|
|
24
|
-
<div style={{ display: "flex", flexDirection: "column", gap: "8px" }}>
|
|
25
|
-
{diff.map((change, index) => {
|
|
26
|
-
return (
|
|
27
|
-
<div key={index} style={{ display: "flex", alignItems: "center" }}>
|
|
28
|
-
<Tag color="blue">{change.path.join(".")}</Tag>
|
|
29
|
-
{change.lhs ? `${change.lhs.toString()} →` : "- →"} {change.rhs ? change.rhs : change.rhs === false ? 'false' : '-'}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
})}
|
|
33
|
-
</div>
|
|
34
|
-
),
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
return [
|
|
39
|
-
<h3 key='changes-header'>Changed Values (Local Comparing)</h3>,
|
|
40
|
-
<ProTable<TUpdatedDiffResult>
|
|
41
|
-
key='changes-data'
|
|
42
|
-
dataSource={updated}
|
|
43
|
-
columns={updateColumns}
|
|
44
|
-
rowKey='id'
|
|
45
|
-
search={false}
|
|
46
|
-
toolBarRender={false}
|
|
47
|
-
/>
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default ChangesTab;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { Descriptions, TImportConflict } from "@boarteam/boar-pack-common-frontend";
|
|
2
|
-
import { Tag, Tooltip, Button } from "antd";
|
|
3
|
-
import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|
4
|
-
import { TImportResponse, TRelationalFields } from "./ChangesModal";
|
|
5
|
-
import { keyBy } from "lodash";
|
|
6
|
-
import { createStyles } from "antd-style";
|
|
7
|
-
import { SwapOutlined } from "@ant-design/icons";
|
|
8
|
-
import { ProColumns } from "@ant-design/pro-components";
|
|
9
|
-
|
|
10
|
-
const useStyles = createStyles(() => {
|
|
11
|
-
return {
|
|
12
|
-
conflictsStyle: {
|
|
13
|
-
".ant-descriptions-row > *:nth-child(1), .ant-descriptions-row > *:nth-child(2)": {
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
".ant-descriptions-row > *:nth-child(3)": {
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
".ant-descriptions-row > *:nth-child(4)": {
|
|
20
|
-
backgroundColor: "#f0fff0 !important",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const getCurrentKey = (field: string) => {
|
|
27
|
-
return `${field}-current`;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const getNormalizedKey = (field: string) => {
|
|
31
|
-
return field.replace('_id', '');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function ConflictsTab<Entity>({
|
|
35
|
-
conflicts,
|
|
36
|
-
relationalFields,
|
|
37
|
-
setResolvedData,
|
|
38
|
-
originColumns,
|
|
39
|
-
}: {
|
|
40
|
-
conflicts?: TImportResponse['conflicts'],
|
|
41
|
-
relationalFields?: TRelationalFields;
|
|
42
|
-
setResolvedData?: Dispatch<SetStateAction<Entity[]>>;
|
|
43
|
-
originColumns: ProColumns<Entity>[];
|
|
44
|
-
}) {
|
|
45
|
-
|
|
46
|
-
if (!conflicts || conflicts.length === 0) {
|
|
47
|
-
return <p>No conflicts found.</p>;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const getRelationalData = (key: string, value: string) => {
|
|
51
|
-
if (relationalFields?.has(key)) {
|
|
52
|
-
const relation = relationalFields.get(key);
|
|
53
|
-
return relation?.data[value] ?? null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return value;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/*Initial value based on received conflicts
|
|
60
|
-
{
|
|
61
|
-
field: 'importing field value',
|
|
62
|
-
field-current: 'current field name from server',
|
|
63
|
-
...
|
|
64
|
-
}*/
|
|
65
|
-
const [resolvedData, setLocalResolvedData] = useState<Record<string, any>[]>(conflicts.map(conflict => (
|
|
66
|
-
conflict.fields.reduce((acc: Record<string, any>, currentValue) => {
|
|
67
|
-
const key = getNormalizedKey(currentValue.field);
|
|
68
|
-
acc[key] = getRelationalData(key, currentValue.imported_value);
|
|
69
|
-
acc[getCurrentKey(key)] = getRelationalData(key, currentValue.current_value);
|
|
70
|
-
|
|
71
|
-
return acc;
|
|
72
|
-
}, {})
|
|
73
|
-
)));
|
|
74
|
-
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
if (!setResolvedData) return;
|
|
77
|
-
|
|
78
|
-
const payload = resolvedData.map((obj, i) => {
|
|
79
|
-
const data = { ...obj };
|
|
80
|
-
// Remove the "current" postfix key from the resolved data
|
|
81
|
-
Object.keys(obj).forEach(key => {
|
|
82
|
-
if (key.endsWith('-current')) {
|
|
83
|
-
delete data[key];
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
id: conflicts[i].id,
|
|
89
|
-
...data,
|
|
90
|
-
version: conflicts[i].version,
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
setResolvedData(payload);
|
|
95
|
-
}, [resolvedData, conflicts, setResolvedData]);
|
|
96
|
-
|
|
97
|
-
const { styles } = useStyles();
|
|
98
|
-
|
|
99
|
-
const useCurrentValue = (conflict: TImportConflict, field: string) => {
|
|
100
|
-
const key = getNormalizedKey(field);
|
|
101
|
-
|
|
102
|
-
// Update the resolved data for this conflict
|
|
103
|
-
setLocalResolvedData(prev => {
|
|
104
|
-
const newData = [...prev];
|
|
105
|
-
const index = conflicts.indexOf(conflict);
|
|
106
|
-
newData[index] = {
|
|
107
|
-
...newData[index],
|
|
108
|
-
[key]: newData[index][getCurrentKey(key)],
|
|
109
|
-
};
|
|
110
|
-
return newData;
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const keyedOriginColumns = keyBy(originColumns, "dataIndex");
|
|
115
|
-
|
|
116
|
-
return conflicts.map((conflict, idx) => {
|
|
117
|
-
const conflictColumns: ProColumns[] = [];
|
|
118
|
-
|
|
119
|
-
conflict.fields.forEach(field => {
|
|
120
|
-
const key = getNormalizedKey(field.field);
|
|
121
|
-
const originColumn = keyedOriginColumns[key];
|
|
122
|
-
conflictColumns.push({
|
|
123
|
-
...originColumn,
|
|
124
|
-
dataIndex: getCurrentKey(key),
|
|
125
|
-
editable: false,
|
|
126
|
-
// Should override render to keep -current value
|
|
127
|
-
render: (node) => node
|
|
128
|
-
});
|
|
129
|
-
conflictColumns.push({
|
|
130
|
-
...originColumn,
|
|
131
|
-
title: (
|
|
132
|
-
<div style={{ textAlign: 'center' }}>
|
|
133
|
-
<Tooltip title="Use value from server">
|
|
134
|
-
<Button
|
|
135
|
-
size="small"
|
|
136
|
-
type="link"
|
|
137
|
-
icon={<SwapOutlined />}
|
|
138
|
-
onClick={() => useCurrentValue(conflict, field.field)}
|
|
139
|
-
/>
|
|
140
|
-
</Tooltip>
|
|
141
|
-
</div>
|
|
142
|
-
),
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<div key={idx} style={{ display: "flex", flexDirection: "column", gap: 15, width: "100%" }}>
|
|
148
|
-
<div>
|
|
149
|
-
<Tag color="error">ID {conflict.id}</Tag>
|
|
150
|
-
<Tag color="blue">Server version: v{conflict.version}</Tag>
|
|
151
|
-
</div>
|
|
152
|
-
<table>
|
|
153
|
-
<thead>
|
|
154
|
-
<tr>
|
|
155
|
-
<th style={{ width: '50%' }}>Current (From Server)</th>
|
|
156
|
-
<th style={{ width: '50%' }}>New (Importing)</th>
|
|
157
|
-
</tr>
|
|
158
|
-
</thead>
|
|
159
|
-
</table>
|
|
160
|
-
<Descriptions
|
|
161
|
-
size="small"
|
|
162
|
-
bordered
|
|
163
|
-
entity={resolvedData[idx]}
|
|
164
|
-
columns={conflictColumns}
|
|
165
|
-
column={2}
|
|
166
|
-
canEdit={true}
|
|
167
|
-
mainTitle={null}
|
|
168
|
-
className={styles.conflictsStyle}
|
|
169
|
-
>
|
|
170
|
-
</Descriptions>
|
|
171
|
-
</div>
|
|
172
|
-
);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export default ConflictsTab;
|