@next-libs/cmdb-instances 7.2.4 → 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.
@@ -415,43 +415,6 @@ function LegacyInstanceList(props) {
415
415
  const [selectedRowKeys, setSelectedRowKeys] = (0, _react.useState)((_props$selectedRowKey = props.selectedRowKeys) !== null && _props$selectedRowKey !== void 0 ? _props$selectedRowKey : []);
416
416
  const cache = (0, _react.useRef)(new Map());
417
417
  const isFirstRunRef = (0, _react.useRef)(true);
418
-
419
- // istanbul ignore next
420
- const onSelectionChange = (0, _react.useCallback)(async selected => {
421
- var _props$onSelectionCha;
422
- let {
423
- selectedItems,
424
- selectedKeys
425
- } = selected;
426
- setSelectedRowKeys(selectedKeys);
427
- if (selectedKeys.length > (0, _lodash.compact)(selectedItems).length) {
428
- const ids = selectedKeys.filter(id => !cache.current.has(id));
429
- if (ids.length) {
430
- let resp;
431
- const params = {
432
- fields: ["instanceId"],
433
- query: {
434
- instanceId: {
435
- $in: ids
436
- }
437
- },
438
- page_size: ids.length
439
- };
440
- // useAutoDiscoveryProvider=true, 使用useProvider的接口,虽然这里列表用不到选择功能,但还是加上保持统一
441
- if (props.useAutoDiscoveryProvider) {
442
- resp = await listProvider.query([props.objectId, Object.assign(params, props.extraParams)]);
443
- } else {
444
- resp = await (0, _cmdbSdk.InstanceApi_postSearchV3)(props.objectId, params);
445
- }
446
- resp.list.forEach(i => cache.current.set(i.instanceId, i));
447
- }
448
- selectedItems = selectedKeys.map(id => cache.current.get(id));
449
- }
450
- (_props$onSelectionCha = props.onSelectionChange) === null || _props$onSelectionCha === void 0 ? void 0 : _props$onSelectionCha.call(props, {
451
- selectedItems,
452
- selectedKeys
453
- });
454
- }, []);
455
418
  const getInstanceListData = async (sort, asc, page) => {
456
419
  var _modelData$attrList, _modelData$attrList$f2, _modelData$attrList$f3, _props$onSearchExecut;
457
420
  const data = {};
@@ -612,14 +575,6 @@ function LegacyInstanceList(props) {
612
575
  setSelectedRowKeys((_props$selectedRowKey2 = props.selectedRowKeys) !== null && _props$selectedRowKey2 !== void 0 ? _props$selectedRowKey2 : []);
613
576
  }, [props.objectId, props.selectedRowKeys]);
614
577
 
615
- // istanbul ignore next
616
- (0, _react.useEffect)(() => {
617
- onSelectionChange({
618
- selectedKeys: [],
619
- selectedItems: []
620
- });
621
- }, [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]);
622
-
623
578
  // on filter condition change
624
579
  (0, _react.useEffect)(() => {
625
580
  if (isFirstRunRef.current) {
@@ -660,6 +615,43 @@ function LegacyInstanceList(props) {
660
615
  const onChange = e => {
661
616
  setQ(e.target.value);
662
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
+ }, []);
663
655
  const onSearch = value => {
664
656
  var _props$onSearch;
665
657
  const q = value.trim();
@@ -667,10 +659,6 @@ function LegacyInstanceList(props) {
667
659
  q
668
660
  });
669
661
  (_props$onSearch = props.onSearch) === null || _props$onSearch === void 0 ? void 0 : _props$onSearch.call(props, q);
670
- onSelectionChange({
671
- selectedKeys: [],
672
- selectedItems: []
673
- });
674
662
  };
675
663
  const onAdvancedSearch = (queries, queriesToShow, fieldToShow) => {
676
664
  var _props$onAdvancedSear;
@@ -680,10 +668,6 @@ function LegacyInstanceList(props) {
680
668
  aqToShow: queriesToShow
681
669
  });
682
670
  (_props$onAdvancedSear = props.onAdvancedSearch) === null || _props$onAdvancedSear === void 0 ? void 0 : _props$onAdvancedSear.call(props, queries);
683
- onSelectionChange({
684
- selectedKeys: [],
685
- selectedItems: []
686
- });
687
671
  };
688
672
  const onSortingChange = (0, _react.useCallback)(info => {
689
673
  var _props$onSortingChang;