@next-libs/cmdb-instances 7.2.3 → 7.2.5
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.
|
@@ -161,10 +161,11 @@ function translateConditions(aq, idObjectMap, modelData, t) {
|
|
|
161
161
|
queries = query[Object.keys(query)[0]];
|
|
162
162
|
}
|
|
163
163
|
queries.forEach(query => {
|
|
164
|
+
var _attr;
|
|
164
165
|
const key = Object.keys(query)[0];
|
|
165
166
|
const value = Object.values(query)[0];
|
|
166
167
|
let attr = attrAndRelationList.find(attr => attr.id === key || attr.relationSideId === key);
|
|
167
|
-
if (Object.keys(value)[0] === _cmdbUtils.ElementOperators.Exists && attr.relationSideId) {
|
|
168
|
+
if (Object.keys(value)[0] === _cmdbUtils.ElementOperators.Exists && (_attr = attr) !== null && _attr !== void 0 && _attr.relationSideId) {
|
|
168
169
|
const relationSideId = attr.relationSideId;
|
|
169
170
|
attr = attrAndRelationList.find(attr => attr.id === `${relationSideId}.`) || attr;
|
|
170
171
|
}
|
|
@@ -414,43 +415,6 @@ function LegacyInstanceList(props) {
|
|
|
414
415
|
const [selectedRowKeys, setSelectedRowKeys] = (0, _react.useState)((_props$selectedRowKey = props.selectedRowKeys) !== null && _props$selectedRowKey !== void 0 ? _props$selectedRowKey : []);
|
|
415
416
|
const cache = (0, _react.useRef)(new Map());
|
|
416
417
|
const isFirstRunRef = (0, _react.useRef)(true);
|
|
417
|
-
|
|
418
|
-
// istanbul ignore next
|
|
419
|
-
const onSelectionChange = (0, _react.useCallback)(async selected => {
|
|
420
|
-
var _props$onSelectionCha;
|
|
421
|
-
let {
|
|
422
|
-
selectedItems,
|
|
423
|
-
selectedKeys
|
|
424
|
-
} = selected;
|
|
425
|
-
setSelectedRowKeys(selectedKeys);
|
|
426
|
-
if (selectedKeys.length > (0, _lodash.compact)(selectedItems).length) {
|
|
427
|
-
const ids = selectedKeys.filter(id => !cache.current.has(id));
|
|
428
|
-
if (ids.length) {
|
|
429
|
-
let resp;
|
|
430
|
-
const params = {
|
|
431
|
-
fields: ["instanceId"],
|
|
432
|
-
query: {
|
|
433
|
-
instanceId: {
|
|
434
|
-
$in: ids
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
page_size: ids.length
|
|
438
|
-
};
|
|
439
|
-
// useAutoDiscoveryProvider=true, 使用useProvider的接口,虽然这里列表用不到选择功能,但还是加上保持统一
|
|
440
|
-
if (props.useAutoDiscoveryProvider) {
|
|
441
|
-
resp = await listProvider.query([props.objectId, Object.assign(params, props.extraParams)]);
|
|
442
|
-
} else {
|
|
443
|
-
resp = await (0, _cmdbSdk.InstanceApi_postSearchV3)(props.objectId, params);
|
|
444
|
-
}
|
|
445
|
-
resp.list.forEach(i => cache.current.set(i.instanceId, i));
|
|
446
|
-
}
|
|
447
|
-
selectedItems = selectedKeys.map(id => cache.current.get(id));
|
|
448
|
-
}
|
|
449
|
-
(_props$onSelectionCha = props.onSelectionChange) === null || _props$onSelectionCha === void 0 ? void 0 : _props$onSelectionCha.call(props, {
|
|
450
|
-
selectedItems,
|
|
451
|
-
selectedKeys
|
|
452
|
-
});
|
|
453
|
-
}, []);
|
|
454
418
|
const getInstanceListData = async (sort, asc, page) => {
|
|
455
419
|
var _modelData$attrList, _modelData$attrList$f2, _modelData$attrList$f3, _props$onSearchExecut;
|
|
456
420
|
const data = {};
|
|
@@ -611,14 +575,6 @@ function LegacyInstanceList(props) {
|
|
|
611
575
|
setSelectedRowKeys((_props$selectedRowKey2 = props.selectedRowKeys) !== null && _props$selectedRowKey2 !== void 0 ? _props$selectedRowKey2 : []);
|
|
612
576
|
}, [props.objectId, props.selectedRowKeys]);
|
|
613
577
|
|
|
614
|
-
// istanbul ignore next
|
|
615
|
-
(0, _react.useEffect)(() => {
|
|
616
|
-
onSelectionChange({
|
|
617
|
-
selectedKeys: [],
|
|
618
|
-
selectedItems: []
|
|
619
|
-
});
|
|
620
|
-
}, [state.sort, state.asc, state.fieldIds, state.appSearchInstanceId, state.currentChangeSelect, state.searchByApp, props.dataSource, state.presetConfigsQuery, state.q, state.aq, state.instanceSourceQuery, state.aliveHosts, state.relatedToMe, props.objectId, props.permission, props.defaultQuery]);
|
|
621
|
-
|
|
622
578
|
// on filter condition change
|
|
623
579
|
(0, _react.useEffect)(() => {
|
|
624
580
|
if (isFirstRunRef.current) {
|
|
@@ -659,6 +615,43 @@ function LegacyInstanceList(props) {
|
|
|
659
615
|
const onChange = e => {
|
|
660
616
|
setQ(e.target.value);
|
|
661
617
|
};
|
|
618
|
+
|
|
619
|
+
// istanbul ignore next
|
|
620
|
+
const onSelectionChange = (0, _react.useCallback)(async selected => {
|
|
621
|
+
var _props$onSelectionCha;
|
|
622
|
+
let {
|
|
623
|
+
selectedItems,
|
|
624
|
+
selectedKeys
|
|
625
|
+
} = selected;
|
|
626
|
+
setSelectedRowKeys(selectedKeys);
|
|
627
|
+
if (selectedKeys.length > (0, _lodash.compact)(selectedItems).length) {
|
|
628
|
+
const ids = selectedKeys.filter(id => !cache.current.has(id));
|
|
629
|
+
if (ids.length) {
|
|
630
|
+
let resp;
|
|
631
|
+
const params = {
|
|
632
|
+
fields: ["instanceId"],
|
|
633
|
+
query: {
|
|
634
|
+
instanceId: {
|
|
635
|
+
$in: ids
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
page_size: ids.length
|
|
639
|
+
};
|
|
640
|
+
// useAutoDiscoveryProvider=true, 使用useProvider的接口,虽然这里列表用不到选择功能,但还是加上保持统一
|
|
641
|
+
if (props.useAutoDiscoveryProvider) {
|
|
642
|
+
resp = await listProvider.query([props.objectId, Object.assign(params, props.extraParams)]);
|
|
643
|
+
} else {
|
|
644
|
+
resp = await (0, _cmdbSdk.InstanceApi_postSearchV3)(props.objectId, params);
|
|
645
|
+
}
|
|
646
|
+
resp.list.forEach(i => cache.current.set(i.instanceId, i));
|
|
647
|
+
}
|
|
648
|
+
selectedItems = selectedKeys.map(id => cache.current.get(id));
|
|
649
|
+
}
|
|
650
|
+
(_props$onSelectionCha = props.onSelectionChange) === null || _props$onSelectionCha === void 0 ? void 0 : _props$onSelectionCha.call(props, {
|
|
651
|
+
selectedItems,
|
|
652
|
+
selectedKeys
|
|
653
|
+
});
|
|
654
|
+
}, []);
|
|
662
655
|
const onSearch = value => {
|
|
663
656
|
var _props$onSearch;
|
|
664
657
|
const q = value.trim();
|
|
@@ -666,10 +659,6 @@ function LegacyInstanceList(props) {
|
|
|
666
659
|
q
|
|
667
660
|
});
|
|
668
661
|
(_props$onSearch = props.onSearch) === null || _props$onSearch === void 0 ? void 0 : _props$onSearch.call(props, q);
|
|
669
|
-
onSelectionChange({
|
|
670
|
-
selectedKeys: [],
|
|
671
|
-
selectedItems: []
|
|
672
|
-
});
|
|
673
662
|
};
|
|
674
663
|
const onAdvancedSearch = (queries, queriesToShow, fieldToShow) => {
|
|
675
664
|
var _props$onAdvancedSear;
|
|
@@ -679,10 +668,6 @@ function LegacyInstanceList(props) {
|
|
|
679
668
|
aqToShow: queriesToShow
|
|
680
669
|
});
|
|
681
670
|
(_props$onAdvancedSear = props.onAdvancedSearch) === null || _props$onAdvancedSear === void 0 ? void 0 : _props$onAdvancedSear.call(props, queries);
|
|
682
|
-
onSelectionChange({
|
|
683
|
-
selectedKeys: [],
|
|
684
|
-
selectedItems: []
|
|
685
|
-
});
|
|
686
671
|
};
|
|
687
672
|
const onSortingChange = (0, _react.useCallback)(info => {
|
|
688
673
|
var _props$onSortingChang;
|