@ytsaurus/ui 1.22.2 → 1.22.3

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 (26) hide show
  1. package/build/cjs/ui/components/Dialog/controls/PoolSuggestControl/PoolSuggestControl.js +48 -34
  2. package/build/cjs/ui/components/Dialog/controls/PoolSuggestControl/PoolSuggestControl.js.map +1 -1
  3. package/build/cjs/ui/hooks/global-pool-trees.d.ts +1 -0
  4. package/build/cjs/ui/hooks/global-pool-trees.js +8 -3
  5. package/build/cjs/ui/hooks/global-pool-trees.js.map +1 -1
  6. package/build/cjs/ui/pages/navigation/modals/RemoteCopyModal.js +11 -10
  7. package/build/cjs/ui/pages/navigation/modals/RemoteCopyModal.js.map +1 -1
  8. package/build/esm/ui/components/Dialog/controls/PoolSuggestControl/PoolSuggestControl.js +48 -34
  9. package/build/esm/ui/components/Dialog/controls/PoolSuggestControl/PoolSuggestControl.js.map +1 -1
  10. package/build/esm/ui/hooks/global-pool-trees.d.ts +1 -0
  11. package/build/esm/ui/hooks/global-pool-trees.js +7 -3
  12. package/build/esm/ui/hooks/global-pool-trees.js.map +1 -1
  13. package/build/esm/ui/pages/navigation/modals/RemoteCopyModal.js +11 -10
  14. package/build/esm/ui/pages/navigation/modals/RemoteCopyModal.js.map +1 -1
  15. package/dist/public/build/assets-manifest.json +9 -9
  16. package/dist/public/build/js/719.b5654185.chunk.js +2 -0
  17. package/dist/public/build/js/{719.5d4d8d0a.chunk.js.map → 719.b5654185.chunk.js.map} +1 -1
  18. package/dist/public/build/js/main.40d53a9b.js +3 -0
  19. package/dist/public/build/js/{main.696bd3aa.js.map → main.40d53a9b.js.map} +1 -1
  20. package/dist/public/build/js/{runtime.d242c08d.js → runtime.d620d412.js} +2 -2
  21. package/dist/public/build/js/{runtime.d242c08d.js.map → runtime.d620d412.js.map} +1 -1
  22. package/dist/public/build/manifest.json +6 -6
  23. package/package.json +2 -2
  24. package/dist/public/build/js/719.5d4d8d0a.chunk.js +0 -2
  25. package/dist/public/build/js/main.696bd3aa.js +0 -3
  26. /package/dist/public/build/js/{main.696bd3aa.js.LICENSE.txt → main.40d53a9b.js.LICENSE.txt} +0 -0
@@ -20,6 +20,7 @@ var _ypath = _interopRequireDefault(require("../../../../common/thor/ypath"));
20
20
  var _Suggest = _interopRequireDefault(require("../../../../components/Suggest/Suggest"));
21
21
  var _rumWrapApi = require("../../../../rum/rum-wrap-api");
22
22
  var _utils = require("../../../../utils/utils");
23
+ var _globalPoolTrees = require("../../../../hooks/global-pool-trees");
23
24
  require("./PoolSuggestControl.css");
24
25
  var _jsxRuntime = require("react/jsx-runtime");
25
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -47,28 +48,32 @@ function PoolSuggestControl(props) {
47
48
  poolNames = _React$useState2[0].items,
48
49
  setPoolNames = _React$useState2[1];
49
50
  var loadedPools = useLoadedPools(cluster, poolTree);
50
- _react.default.useEffect(function () {
51
- loadedPools.then(function (_ref) {
52
- var names = _ref.names,
53
- tree = _ref.tree;
54
- var noRoot = (0, _filter2.default)(names, function (item) {
55
- return '<Root>' !== item;
56
- });
57
- var valueIndex = (0, _indexOf2.default)(noRoot, value);
58
- if (value && -1 === valueIndex) {
59
- onChange('');
60
- }
61
- setPoolNames({
62
- items: (0, _sortBy2.default)(noRoot),
63
- itemsTree: tree
64
- });
65
- if (calculateValueOnPoolsLoaded) {
66
- onChange(calculateValueOnPoolsLoaded({
67
- loadedPoolNames: noRoot
68
- }));
69
- }
51
+ _react.default.useEffect(function onPoolLoaded() {
52
+ var names = loadedPools.names,
53
+ tree = loadedPools.tree;
54
+ if (!tree) {
55
+ return;
56
+ }
57
+ var noRoot = (0, _filter2.default)(names, function (item) {
58
+ return '<Root>' !== item;
59
+ });
60
+ var valueIndex = (0, _indexOf2.default)(noRoot, value);
61
+ if (value && -1 === valueIndex) {
62
+ onChange('');
63
+ }
64
+ setPoolNames({
65
+ items: (0, _sortBy2.default)(noRoot),
66
+ itemsTree: tree
70
67
  });
71
- }, [loadedPools, setPoolNames, onChange]);
68
+ if (calculateValueOnPoolsLoaded) {
69
+ onChange(calculateValueOnPoolsLoaded({
70
+ loadedPoolNames: noRoot
71
+ }));
72
+ }
73
+ },
74
+ // value should not affect the useEffect
75
+ [loadedPools, setPoolNames, onChange, calculateValueOnPoolsLoaded /*, value */]);
76
+
72
77
  var getItems = _react.default.useCallback(function (_items, filter) {
73
78
  if (!filter) {
74
79
  return poolNames;
@@ -81,7 +86,7 @@ function PoolSuggestControl(props) {
81
86
  });
82
87
  var res = (0, _slice2.default)(poolNames, from, to);
83
88
  return res;
84
- }, [poolNames, value]);
89
+ }, [poolNames]);
85
90
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Suggest.default, {
86
91
  popupClassName: block('popup'),
87
92
  text: value,
@@ -107,30 +112,39 @@ PoolSuggestControl.isEmpty = function (value) {
107
112
  };
108
113
  function useLoadedPools(cluster) {
109
114
  var poolTree = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
110
- return _react.default.useMemo(function () {
115
+ var _React$useState3 = _react.default.useState({
116
+ names: []
117
+ }),
118
+ _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
119
+ result = _React$useState4[0],
120
+ setResult = _React$useState4[1];
121
+ var currentClusterTree = (0, _globalPoolTrees.usePoolTreeOrLoadDefault)(poolTree);
122
+ _react.default.useMemo(function () {
111
123
  if (cluster) {
112
- return (0, _utils.wrapApiPromiseByToaster)(_axios.default.get("/api/pool-names/".concat(cluster, "?poolTree=").concat(poolTree)), {
124
+ (0, _utils.wrapApiPromiseByToaster)(_axios.default.get("/api/pool-names/".concat(cluster, "?poolTree=").concat(poolTree)), {
113
125
  skipSuccessToast: true,
114
126
  toasterName: 'load-pool-names',
115
127
  errorTitle: 'Failed to load pools'
116
- }).then(function (_ref2) {
117
- var data = _ref2.data;
118
- return data;
128
+ }).then(function (_ref) {
129
+ var data = _ref.data;
130
+ setResult(data);
119
131
  });
120
- } else {
121
- return (0, _utils.wrapApiPromiseByToaster)(_rumWrapApi.ytApiV3Id.list(_rumWrapApi.YTApiId.listPoolNames, (0, _objectSpread2.default)({
122
- path: "//sys/scheduler/orchid/scheduler/pool_trees/".concat(poolTree, "/pools")
132
+ } else if (poolTree || currentClusterTree) {
133
+ var localPoolTree = poolTree || currentClusterTree;
134
+ (0, _utils.wrapApiPromiseByToaster)(_rumWrapApi.ytApiV3Id.list(_rumWrapApi.YTApiId.listPoolNames, (0, _objectSpread2.default)({
135
+ path: "//sys/scheduler/orchid/scheduler/pool_trees/".concat(localPoolTree, "/pools")
123
136
  }, _ytApi.USE_MAX_SIZE)), {
124
137
  skipSuccessToast: true,
125
138
  toasterName: 'load-pool-names',
126
139
  errorTitle: 'Failed to load pools'
127
140
  }).then(function (names) {
128
- return {
141
+ setResult({
129
142
  names: _ypath.default.getValue(names),
130
- tree: poolTree
131
- };
143
+ tree: localPoolTree
144
+ });
132
145
  });
133
146
  }
134
- }, [cluster, poolTree]);
147
+ }, [cluster, currentClusterTree, poolTree]);
148
+ return result;
135
149
  }
136
150
  // #sourceMappingURL=PoolSuggestControl.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_bemCnLite","_axios","_ytApi","_ypath","_Suggest","_rumWrapApi","_utils","_jsxRuntime","obj","__esModule","default","block","cn","PoolSuggestControl","props","allowEmpty","allowEphemeral","value","onChange","placeholder","poolTree","cluster","calculateValueOnPoolsLoaded","disabled","_React$useState","React","useState","items","itemsTree","_React$useState2","_slicedToArray","poolNames","setPoolNames","loadedPools","useLoadedPools","useEffect","then","_ref","names","tree","noRoot","_filter","item","valueIndex","_indexOf","_sortBy","loadedPoolNames","getItems","useCallback","_items","filter","from","_sortedIndexBy","substring","length","to","_sortedLastIndexBy","res","_slice","_jsx","Suggest","popupClassName","text","apply","v","onItemClick","onTextUpdate","undefined","getDefaultValue","isEmpty","arguments","useMemo","wrapApiPromiseByToaster","axios","get","concat","skipSuccessToast","toasterName","errorTitle","_ref2","data","ytApiV3Id","list","YTApiId","listPoolNames","_objectSpread","path","USE_MAX_SIZE","ypath","getValue"],"sources":["PoolSuggestControl.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport cn from 'bem-cn-lite';\nimport axios from 'axios';\n\nimport {USE_MAX_SIZE} from '../../../../../shared/constants/yt-api';\nimport ypath from '../../../../common/thor/ypath';\n\nimport {DialogControlProps} from '../../../../components/Dialog/Dialog.types';\nimport Suggest from '../../../../components/Suggest/Suggest';\n\nimport {YTApiId, ytApiV3Id} from '../../../../rum/rum-wrap-api';\nimport {wrapApiPromiseByToaster} from '../../../../utils/utils';\n\nimport './PoolSuggestControl.scss';\n\nconst block = cn('pool-suggest-control');\n\ntype Props = DialogControlProps<string> & {\n // If not defined then current cluster should be used\n cluster?: string;\n // If not defined then default pool tree should be used\n poolTree?: string;\n calculateValueOnPoolsLoaded?: (params: {loadedPoolNames: Array<string>}) => string;\n\n allowEmpty?: boolean;\n allowEphemeral?: boolean;\n\n disabled?: boolean;\n};\n\n/**\n * The suggest should be used to select pools of current cluster\n * @param props\n * @returns\n */\nexport function PoolSuggestControl(props: Props) {\n const {\n allowEmpty,\n allowEphemeral,\n value,\n onChange,\n placeholder,\n poolTree,\n cluster,\n calculateValueOnPoolsLoaded,\n disabled,\n } = props;\n\n const [{items: poolNames}, setPoolNames] = React.useState<{\n items: Array<string>;\n itemsTree: string;\n }>({\n items: [],\n itemsTree: '',\n });\n\n const loadedPools = useLoadedPools(cluster, poolTree);\n\n React.useEffect(() => {\n loadedPools.then(({names, tree}) => {\n const noRoot = _.filter(names, (item) => '<Root>' !== item);\n const valueIndex = _.indexOf(noRoot, value);\n if (value && -1 === valueIndex) {\n onChange('');\n }\n setPoolNames({items: _.sortBy(noRoot), itemsTree: tree});\n if (calculateValueOnPoolsLoaded) {\n onChange(calculateValueOnPoolsLoaded({loadedPoolNames: noRoot}));\n }\n });\n }, [loadedPools, setPoolNames, onChange]);\n\n const getItems = React.useCallback(\n (_items: unknown, filter?: string) => {\n if (!filter) {\n return poolNames;\n }\n const from = _.sortedIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n const to = _.sortedLastIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n\n const res = _.slice(poolNames, from, to);\n return res;\n },\n [poolNames, value],\n );\n\n return (\n <Suggest\n popupClassName={block('popup')}\n text={value}\n filter={getItems}\n apply={(v) => allowEphemeral && onChange(typeof v === 'string' ? v : v.value)}\n onItemClick={(v) => onChange(typeof v === 'string' ? v : v.value)}\n onTextUpdate={allowEmpty ? (text) => !text && onChange('') : undefined}\n placeholder={placeholder}\n disabled={disabled}\n />\n );\n}\n\nPoolSuggestControl.getDefaultValue = () => {\n return '';\n};\n\nPoolSuggestControl.isEmpty = (value: Props['value']) => {\n return !value;\n};\n\nfunction useLoadedPools(\n cluster?: string,\n poolTree = '',\n): Promise<{names: Array<string>; tree: string}> {\n return React.useMemo(() => {\n if (cluster) {\n return wrapApiPromiseByToaster(\n axios.get(`/api/pool-names/${cluster}?poolTree=${poolTree}`),\n {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n },\n ).then(({data}) => {\n return data;\n });\n } else {\n return wrapApiPromiseByToaster(\n ytApiV3Id.list(YTApiId.listPoolNames, {\n path: `//sys/scheduler/orchid/scheduler/pool_trees/${poolTree}/pools`,\n ...USE_MAX_SIZE,\n }),\n {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n },\n ).then((names) => {\n return {names: ypath.getValue(names), tree: poolTree};\n });\n }\n }, [cluster, poolTree]);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,MAAA,G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AQ,CAAE,CAAC,EAC5D;QACIwD,gBAAgB,EAAE,IAAI;QACtBC,WAAW,EAAE,iBAAiB;QAC9BC,UAAU,EAAE;MAChB,CACJ,CAAC,CAAC1C,IAAI,CAAC,UAAA2C,KAAA,EAAY;QAAA,IAAVC,IAAI,GAAAD,KAAA,CAAJC,IAAI;QACT,OAAOA,IAAI;MACf,CAAC,CAAC;IACN,CAAC,MAAM;MACH,OAAO,IAAAR,8BAAuB,EAC1BS,qBAAS,CAACC,IAAI,CAACC,mBAAO,CAACC,aAAa,MAAAC,sBAAA;QAChCC,IAAI,iDAAAX,MAAA,CAAiDvD,QAAQ;MAAQ,GAClEmE,mBAAY,CAClB,CAAC,EACF;QACIX,gBAAgB,EAAE,IAAI;QACtBC,WAAW,EAAE,iBAAiB;QAC9BC,UAAU,EAAE;MAChB,CACJ,CAAC,CAAC1C,IAAI,CAAC,UAACE,KAAK,EAAK;QACd,OAAO;UAACA,KAAK,EAAEkD,cAAK,CAACC,QAAQ,CAACnD,KAAK,CAAC;UAAEC,IAAI,EAAEnB;QAAQ,CAAC;MACzD,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAACC,OAAO,EAAED,QAAQ,CAAC,CAAC;AAC3B"}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_bemCnLite","_axios","_ytApi","_ypath","_Suggest","_rumWrapApi","_utils","_globalPoolTrees","_jsxRuntime","obj","__esModule","default","block","cn","PoolSuggestControl","props","allowEmpty","allowEphemeral","value","onChange","placeholder","poolTree","cluster","calculateValueOnPoolsLoaded","disabled","_React$useState","React","useState","items","itemsTree","_React$useState2","_slicedToArray","poolNames","setPoolNames","loadedPools","useLoadedPools","useEffect","onPoolLoaded","names","tree","noRoot","_filter","item","valueIndex","_indexOf","_sortBy","loadedPoolNames","getItems","useCallback","_items","filter","from","_sortedIndexBy","substring","length","to","_sortedLastIndexBy","res","_slice","_jsx","Suggest","popupClassName","text","apply","v","onItemClick","onTextUpdate","undefined","getDefaultValue","isEmpty","arguments","_React$useState3","_React$useState4","result","setResult","currentClusterTree","usePoolTreeOrLoadDefault","useMemo","wrapApiPromiseByToaster","axios","get","concat","skipSuccessToast","toasterName","errorTitle","then","_ref","data","localPoolTree","ytApiV3Id","list","YTApiId","listPoolNames","_objectSpread","path","USE_MAX_SIZE","ypath","getValue"],"sources":["PoolSuggestControl.tsx"],"sourcesContent":["import React from 'react';\n\nimport _ from 'lodash';\nimport cn from 'bem-cn-lite';\nimport axios from 'axios';\n\nimport {USE_MAX_SIZE} from '../../../../../shared/constants/yt-api';\nimport ypath from '../../../../common/thor/ypath';\n\nimport {DialogControlProps} from '../../../../components/Dialog/Dialog.types';\nimport Suggest from '../../../../components/Suggest/Suggest';\n\nimport {YTApiId, ytApiV3Id} from '../../../../rum/rum-wrap-api';\nimport {wrapApiPromiseByToaster} from '../../../../utils/utils';\nimport {usePoolTreeOrLoadDefault} from '../../../../hooks/global-pool-trees';\n\nimport './PoolSuggestControl.scss';\n\nconst block = cn('pool-suggest-control');\n\ntype Props = DialogControlProps<string> & {\n // If not defined then current cluster should be used\n cluster?: string;\n // If not defined then default pool tree should be used\n poolTree?: string;\n calculateValueOnPoolsLoaded?: (params: {loadedPoolNames: Array<string>}) => string;\n\n allowEmpty?: boolean;\n allowEphemeral?: boolean;\n\n disabled?: boolean;\n};\n\n/**\n * The suggest should be used to select pools of current cluster\n * @param props\n * @returns\n */\nexport function PoolSuggestControl(props: Props) {\n const {\n allowEmpty,\n allowEphemeral,\n value,\n onChange,\n placeholder,\n poolTree,\n cluster,\n calculateValueOnPoolsLoaded,\n disabled,\n } = props;\n\n const [{items: poolNames}, setPoolNames] = React.useState<{\n items: Array<string>;\n itemsTree: string;\n }>({\n items: [],\n itemsTree: '',\n });\n\n const loadedPools = useLoadedPools(cluster, poolTree);\n\n React.useEffect(\n function onPoolLoaded() {\n const {names, tree} = loadedPools;\n if (!tree) {\n return;\n }\n const noRoot = _.filter(names, (item) => '<Root>' !== item);\n const valueIndex = _.indexOf(noRoot, value);\n if (value && -1 === valueIndex) {\n onChange('');\n }\n setPoolNames({items: _.sortBy(noRoot), itemsTree: tree});\n if (calculateValueOnPoolsLoaded) {\n onChange(calculateValueOnPoolsLoaded({loadedPoolNames: noRoot}));\n }\n },\n // value should not affect the useEffect\n [loadedPools, setPoolNames, onChange, calculateValueOnPoolsLoaded /*, value */],\n );\n\n const getItems = React.useCallback(\n (_items: unknown, filter?: string) => {\n if (!filter) {\n return poolNames;\n }\n const from = _.sortedIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n const to = _.sortedLastIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n\n const res = _.slice(poolNames, from, to);\n return res;\n },\n [poolNames],\n );\n\n return (\n <Suggest\n popupClassName={block('popup')}\n text={value}\n filter={getItems}\n apply={(v) => allowEphemeral && onChange(typeof v === 'string' ? v : v.value)}\n onItemClick={(v) => onChange(typeof v === 'string' ? v : v.value)}\n onTextUpdate={allowEmpty ? (text) => !text && onChange('') : undefined}\n placeholder={placeholder}\n disabled={disabled}\n />\n );\n}\n\nPoolSuggestControl.getDefaultValue = () => {\n return '';\n};\n\nPoolSuggestControl.isEmpty = (value: Props['value']) => {\n return !value;\n};\n\nfunction useLoadedPools(cluster?: string, poolTree = ''): {names: Array<string>; tree?: string} {\n const [result, setResult] = React.useState<{names: Array<string>; tree?: string}>({names: []});\n\n const currentClusterTree = usePoolTreeOrLoadDefault(poolTree);\n\n React.useMemo(() => {\n if (cluster) {\n wrapApiPromiseByToaster(axios.get(`/api/pool-names/${cluster}?poolTree=${poolTree}`), {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n }).then(({data}) => {\n setResult(data);\n });\n } else if (poolTree || currentClusterTree) {\n const localPoolTree = poolTree || currentClusterTree;\n wrapApiPromiseByToaster(\n ytApiV3Id.list(YTApiId.listPoolNames, {\n path: `//sys/scheduler/orchid/scheduler/pool_trees/${localPoolTree}/pools`,\n ...USE_MAX_SIZE,\n }),\n {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n },\n ).then((names) => {\n setResult({names: ypath.getValue(names), tree: localPoolTree});\n });\n }\n }, [cluster, currentClusterTree, poolTree]);\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AAGA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,gBAAA,GAAAR,OAAA;AAEAA,OAAA;AAAmC,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAD,uBAAAW,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnC,IAAMG,KAAK,GAAG,IAAAC,kBAAE,EAAC,sBAAsB,CAAC;AAexC;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACC,KAAY,EAAE;EAC7C,IACIC,UAAU,GASVD,KAAK,CATLC,UAAU;IACVC,cAAc,GAQdF,KAAK,CARLE,cAAc;IACdC,KAAK,GAOLH,KAAK,CAPLG,KAAK;IACLC,QAAQ,GAMRJ,KAAK,CANLI,QAAQ;IACRC,WAAW,GAKXL,KAAK,CALLK,WAAW;IACXC,QAAQ,GAIRN,KAAK,CAJLM,QAAQ;IACRC,OAAO,GAGPP,KAAK,CAHLO,OAAO;IACPC,2BAA2B,GAE3BR,KAAK,CAFLQ,2BAA2B;IAC3BC,QAAQ,GACRT,KAAK,CADLS,QAAQ;EAGZ,IAAAC,eAAA,GAA2CC,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;MAChB,CACJ,CAAC,CAACC,IAAI,CAAC,UAAC/C,KAAK,EAAK;QACdoC,SAAS,CAAC;UAACpC,KAAK,EAAE0D,cAAK,CAACC,QAAQ,CAAC3D,KAAK,CAAC;UAAEC,IAAI,EAAEiD;QAAa,CAAC,CAAC;MAClE,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAAClE,OAAO,EAAEqD,kBAAkB,EAAEtD,QAAQ,CAAC,CAAC;EAE3C,OAAOoD,MAAM;AACjB"}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export declare function PoolTreesLoader(): null;
3
+ export declare function usePoolTreeOrLoadDefault(poolTree?: string): string | undefined;
3
4
  export declare function WaitForDefaultPoolTree({ children, }: {
4
5
  children: ({ defaultPoolTree }: {
5
6
  defaultPoolTree: string;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.PoolTreesLoader = PoolTreesLoader;
7
7
  exports.WaitForDefaultPoolTree = WaitForDefaultPoolTree;
8
+ exports.usePoolTreeOrLoadDefault = usePoolTreeOrLoadDefault;
8
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
10
  var _react = _interopRequireDefault(require("react"));
10
11
  var _reactRedux = require("react-redux");
@@ -21,9 +22,8 @@ function PoolTreesLoader() {
21
22
  usePoolTreesLoaded();
22
23
  return null;
23
24
  }
24
- function WaitForDefaultPoolTree(_ref) {
25
- var children = _ref.children;
26
- var _React$useState = _react.default.useState(undefined),
25
+ function usePoolTreeOrLoadDefault(poolTree) {
26
+ var _React$useState = _react.default.useState(poolTree),
27
27
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
28
28
  defaultPoolTree = _React$useState2[0],
29
29
  setDefaultPoolTree = _React$useState2[1];
@@ -32,6 +32,11 @@ function WaitForDefaultPoolTree(_ref) {
32
32
  setDefaultPoolTree(value);
33
33
  });
34
34
  }, []);
35
+ return defaultPoolTree;
36
+ }
37
+ function WaitForDefaultPoolTree(_ref) {
38
+ var children = _ref.children;
39
+ var defaultPoolTree = usePoolTreeOrLoadDefault();
35
40
  return defaultPoolTree ? children({
36
41
  defaultPoolTree: defaultPoolTree
37
42
  }) : null;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactRedux","_global","_poolTrees","obj","__esModule","default","usePoolTreesLoaded","dispatch","useDispatch","React","useEffect","loadPoolTreesIfNotLoaded","PoolTreesLoader","WaitForDefaultPoolTree","_ref","children","_React$useState","useState","undefined","_React$useState2","_slicedToArray","defaultPoolTree","setDefaultPoolTree","loadDefaultPoolTree","then","value"],"sources":["global-pool-trees.ts"],"sourcesContent":["import React from 'react';\nimport {useDispatch} from 'react-redux';\n\nimport {loadPoolTreesIfNotLoaded} from '../store/actions/global';\nimport {loadDefaultPoolTree} from '../utils/poolTrees';\n\nfunction usePoolTreesLoaded() {\n const dispatch = useDispatch();\n\n React.useEffect(() => {\n dispatch(loadPoolTreesIfNotLoaded());\n }, [dispatch]);\n}\n\nexport function PoolTreesLoader() {\n usePoolTreesLoaded();\n return null;\n}\n\nexport function WaitForDefaultPoolTree({\n children,\n}: {\n children: ({defaultPoolTree}: {defaultPoolTree: string}) => React.ReactNode;\n}) {\n const [defaultPoolTree, setDefaultPoolTree] = React.useState<string | undefined>(undefined);\n\n React.useEffect(() => {\n loadDefaultPoolTree().then((value) => {\n setDefaultPoolTree(value);\n });\n }, []);\n\n return defaultPoolTree ? children({defaultPoolTree}) : null;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAsD,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEtD,SAASG,kBAAkBA,CAAA,EAAG;EAC1B,IAAMC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9BC,cAAK,CAACC,SAAS,CAAC,YAAM;IAClBH,QAAQ,CAAC,IAAAI,gCAAwB,EAAC,CAAC,CAAC;EACxC,CAAC,EAAE,CAACJ,QAAQ,CAAC,CAAC;AAClB;AAEO,SAASK,eAAeA,CAAA,EAAG;EAC9BN,kBAAkB,CAAC,CAAC;EACpB,OAAO,IAAI;AACf;AAEO,SAASO,sBAAsBA,CAAAC,IAAA,EAInC;EAAA,IAHCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAIR,IAAAC,eAAA,GAA8CP,cAAK,CAACQ,QAAQ,CAAqBC,SAAS,CAAC;IAAAC,gBAAA,OAAAC,uBAAA,EAAAJ,eAAA;IAApFK,eAAe,GAAAF,gBAAA;IAAEG,kBAAkB,GAAAH,gBAAA;EAE1CV,cAAK,CAACC,SAAS,CAAC,YAAM;IAClB,IAAAa,8BAAmB,EAAC,CAAC,CAACC,IAAI,CAAC,UAACC,KAAK,EAAK;MAClCH,kBAAkB,CAACG,KAAK,CAAC;IAC7B,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOJ,eAAe,GAAGN,QAAQ,CAAC;IAACM,eAAe,EAAfA;EAAe,CAAC,CAAC,GAAG,IAAI;AAC/D"}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactRedux","_global","_poolTrees","obj","__esModule","default","usePoolTreesLoaded","dispatch","useDispatch","React","useEffect","loadPoolTreesIfNotLoaded","PoolTreesLoader","usePoolTreeOrLoadDefault","poolTree","_React$useState","useState","_React$useState2","_slicedToArray","defaultPoolTree","setDefaultPoolTree","loadDefaultPoolTree","then","value","WaitForDefaultPoolTree","_ref","children"],"sources":["global-pool-trees.ts"],"sourcesContent":["import React from 'react';\nimport {useDispatch} from 'react-redux';\n\nimport {loadPoolTreesIfNotLoaded} from '../store/actions/global';\nimport {loadDefaultPoolTree} from '../utils/poolTrees';\n\nfunction usePoolTreesLoaded() {\n const dispatch = useDispatch();\n\n React.useEffect(() => {\n dispatch(loadPoolTreesIfNotLoaded());\n }, [dispatch]);\n}\n\nexport function PoolTreesLoader() {\n usePoolTreesLoaded();\n return null;\n}\n\nexport function usePoolTreeOrLoadDefault(poolTree?: string) {\n const [defaultPoolTree, setDefaultPoolTree] = React.useState<string | undefined>(poolTree);\n\n React.useEffect(() => {\n loadDefaultPoolTree().then((value) => {\n setDefaultPoolTree(value);\n });\n }, []);\n\n return defaultPoolTree;\n}\n\nexport function WaitForDefaultPoolTree({\n children,\n}: {\n children: ({defaultPoolTree}: {defaultPoolTree: string}) => React.ReactNode;\n}) {\n const defaultPoolTree = usePoolTreeOrLoadDefault();\n\n return defaultPoolTree ? children({defaultPoolTree}) : null;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAsD,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEtD,SAASG,kBAAkBA,CAAA,EAAG;EAC1B,IAAMC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9BC,cAAK,CAACC,SAAS,CAAC,YAAM;IAClBH,QAAQ,CAAC,IAAAI,gCAAwB,EAAC,CAAC,CAAC;EACxC,CAAC,EAAE,CAACJ,QAAQ,CAAC,CAAC;AAClB;AAEO,SAASK,eAAeA,CAAA,EAAG;EAC9BN,kBAAkB,CAAC,CAAC;EACpB,OAAO,IAAI;AACf;AAEO,SAASO,wBAAwBA,CAACC,QAAiB,EAAE;EACxD,IAAAC,eAAA,GAA8CN,cAAK,CAACO,QAAQ,CAAqBF,QAAQ,CAAC;IAAAG,gBAAA,OAAAC,uBAAA,EAAAH,eAAA;IAAnFI,eAAe,GAAAF,gBAAA;IAAEG,kBAAkB,GAAAH,gBAAA;EAE1CR,cAAK,CAACC,SAAS,CAAC,YAAM;IAClB,IAAAW,8BAAmB,EAAC,CAAC,CAACC,IAAI,CAAC,UAACC,KAAK,EAAK;MAClCH,kBAAkB,CAACG,KAAK,CAAC;IAC7B,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOJ,eAAe;AAC1B;AAEO,SAASK,sBAAsBA,CAAAC,IAAA,EAInC;EAAA,IAHCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAIR,IAAMP,eAAe,GAAGN,wBAAwB,CAAC,CAAC;EAElD,OAAOM,eAAe,GAAGO,QAAQ,CAAC;IAACP,eAAe,EAAfA;EAAe,CAAC,CAAC,GAAG,IAAI;AAC/D"}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _find2 = _interopRequireDefault(require("lodash/find"));
8
7
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
8
+ var _find2 = _interopRequireDefault(require("lodash/find"));
9
9
  var _map2 = _interopRequireDefault(require("lodash/map"));
10
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -77,6 +77,13 @@ function RemoteCopyModal() {
77
77
  };
78
78
  });
79
79
  }, [paths]);
80
+ var calculateValueOnPoolsLoaded = _react.default.useCallback(function (_ref2) {
81
+ var loadedPoolNames = _ref2.loadedPoolNames;
82
+ var transferPool = (0, _find2.default)(loadedPoolNames, function (name) {
83
+ return name === "transfer_".concat(cluster);
84
+ });
85
+ return transferPool || '';
86
+ }, [cluster]);
80
87
  return !visible ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dialog.YTDFDialog, {
81
88
  visible: true,
82
89
  onAdd: handleAdd,
@@ -160,18 +167,12 @@ function RemoteCopyModal() {
160
167
  },
161
168
  required: true,
162
169
  tooltip: (0, _config.docsUrl)((0, _CreateTableModal.makeLink)(_UIFactory.default.docsUrls['operations:operations_options#obshie-opcii-dlya-vseh-tipov-operacij'])),
163
- extras: function extras(_ref2) {
164
- var dstCluster = _ref2.dstCluster;
170
+ extras: function extras(_ref3) {
171
+ var dstCluster = _ref3.dstCluster;
165
172
  return {
166
173
  cluster: dstCluster,
167
174
  placeholder: "(cluster: ".concat(dstCluster, ") pool name"),
168
- calculateValueOnPoolsLoaded: function calculateValueOnPoolsLoaded(_ref3) {
169
- var loadedPoolNames = _ref3.loadedPoolNames;
170
- var transferPool = (0, _find2.default)(loadedPoolNames, function (name) {
171
- return name === "transfer_".concat(cluster);
172
- });
173
- return transferPool || '';
174
- },
175
+ calculateValueOnPoolsLoaded: calculateValueOnPoolsLoaded,
175
176
  allowEphemeral: true
176
177
  };
177
178
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactRedux","_Dialog","_remoteCopyModal","_remoteCopyModal2","_global","_CreateTableModal","_config","_UIFactory","_jsxRuntime","obj","__esModule","default","RemoteCopyModal","_pathsValues$","dispatch","useDispatch","visible","useSelector","getRemoteCopyModalVisible","paths","getRemoteCopyModalPaths","cluster","getCluster","_React$useState","React","useState","_React$useState2","_slicedToArray","error","setError","handleAdd","useCallback","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","form","_form$getState","values","input_table_paths","pool","rest","_response","wrap","_callee$","_context","prev","next","undefined","getState","_objectWithoutProperties","_excluded","remoteCopy","_objectSpread","_map","t0","response","data","stop","_x","apply","arguments","handleClose","hideRemoteCopyModal","pathsValues","useMemo","item","title","_jsx","YTDFDialog","onAdd","onClose","headerProps","initialValues","cluster_name","schema_inference_mode","output_table_path","override","fields","name","type","caption","extras","disabled","width","length","frozen","required","excludeClusters","items","value","text","warning","_jsxs","_Fragment","children","docsUrl","makeLink","UIFactory","docsUrls","visibilityCondition","when","isActive","Boolean","tooltip","_ref2","dstCluster","placeholder","concat","calculateValueOnPoolsLoaded","_ref3","loadedPoolNames","transferPool","_find","allowEphemeral","_toConsumableArray","DialogError","_default","exports","memo"],"sources":["RemoteCopyModal.tsx"],"sourcesContent":["import React from 'react';\nimport {useDispatch, useSelector} from 'react-redux';\nimport _ from 'lodash';\n\nimport {DialogError, FormApi, YTDFDialog} from '../../../components/Dialog/Dialog';\nimport {\n getRemoteCopyModalPaths,\n getRemoteCopyModalVisible,\n} from '../../../store/selectors/navigation/modals/remote-copy-modal';\nimport {\n hideRemoteCopyModal,\n remoteCopy,\n} from '../../../store/actions/navigation/modals/remote-copy-modal';\nimport {getCluster} from '../../../store/selectors/global';\nimport {makeLink} from '../../../navigation/Navigation/PathEditorModal/CreateTableModal/CreateTableModal';\nimport {YTError} from '../../../types';\nimport {RemoteCopyParams} from '../../../../@types/types';\nimport {AxiosError} from 'axios';\nimport {docsUrl} from '../../../config';\nimport UIFactory from '../../../UIFactory';\n\ntype Values = Omit<RemoteCopyParams, 'input_table_paths'> & {\n input_table_paths: Array<{title: string}>;\n};\n\nfunction RemoteCopyModal() {\n const dispatch = useDispatch();\n const visible = useSelector(getRemoteCopyModalVisible);\n const paths = useSelector(getRemoteCopyModalPaths);\n const cluster = useSelector(getCluster);\n\n const [error, setError] = React.useState<YTError | unknown>();\n\n const handleAdd = React.useCallback(\n async (form: FormApi<Values>) => {\n try {\n setError(undefined);\n const {values} = form.getState();\n const {input_table_paths, pool, ...rest} = values;\n await dispatch(\n remoteCopy({\n ...rest,\n input_table_paths: _.map(input_table_paths, 'title'),\n pool: pool,\n }),\n );\n } catch (e: unknown) {\n setError((e as AxiosError<YTError>)?.response?.data || e);\n throw e;\n }\n },\n [setError],\n );\n\n const handleClose = React.useCallback(() => {\n dispatch(hideRemoteCopyModal());\n }, []);\n\n const pathsValues = React.useMemo(\n () =>\n _.map(paths, (item) => {\n return {\n title: item,\n };\n }),\n [paths],\n );\n\n return !visible ? null : (\n <YTDFDialog<Values>\n visible={true}\n onAdd={handleAdd}\n onClose={handleClose}\n headerProps={{\n title: 'Remote copy',\n }}\n initialValues={{\n cluster_name: cluster,\n input_table_paths: pathsValues,\n schema_inference_mode: 'auto',\n output_table_path: pathsValues[0]?.title,\n override: false,\n }}\n fields={[\n {\n name: 'cluster_name',\n type: 'cluster',\n caption: 'Source cluster',\n extras: {\n disabled: true,\n width: 'max',\n },\n },\n {\n name: 'input_table_paths',\n type: 'editable-list',\n caption: paths.length > 1 ? 'Input paths' : 'Input path',\n extras: {\n frozen: true,\n },\n },\n {\n name: 'dstCluster',\n type: 'cluster',\n caption: 'Destination cluster',\n required: true,\n extras: {\n excludeClusters: [cluster],\n width: 'max',\n },\n },\n {\n name: 'output_table_path',\n type: 'text',\n caption: 'Output path',\n required: true,\n },\n {\n name: 'override',\n type: 'tumbler',\n caption: 'Override output',\n },\n {\n name: 'copy_attributes',\n type: 'tumbler',\n caption: 'Copy user attributes',\n },\n {\n name: 'schema_inference_mode',\n type: 'yt-select-single',\n caption: 'Schema inference',\n extras: {\n items: [\n {\n value: 'auto',\n text: 'Auto',\n },\n {\n value: 'from_input',\n text: 'From input',\n },\n {\n value: 'from_output',\n text: 'From output',\n },\n ],\n width: 'max',\n },\n },\n {\n name: 'pool',\n type: 'pool',\n caption: 'Pool',\n warning: (\n <>\n pool must have specified{' '}\n {docsUrl(\n makeLink(\n UIFactory.docsUrls['operations:remote_copy'],\n 'limits',\n true,\n ),\n )}\n </>\n ),\n visibilityCondition: {\n when: 'dstCluster',\n isActive: (value) => Boolean(value),\n },\n required: true,\n tooltip: docsUrl(\n makeLink(\n UIFactory.docsUrls[\n 'operations:operations_options#obshie-opcii-dlya-vseh-tipov-operacij'\n ],\n ),\n ),\n extras: ({dstCluster}: Values) => {\n return {\n cluster: dstCluster,\n placeholder: `(cluster: ${dstCluster}) pool name`,\n calculateValueOnPoolsLoaded({loadedPoolNames}) {\n const transferPool = _.find(\n loadedPoolNames,\n (name) => name === `transfer_${cluster}`,\n );\n return transferPool || '';\n },\n allowEphemeral: true,\n };\n },\n },\n ...(!error\n ? []\n : [\n {\n name: 'error',\n type: 'block' as const,\n extras: {\n children: <DialogError error={error} />,\n },\n },\n ]),\n ]}\n />\n );\n}\n\nexport default React.memo(RemoteCopyModal);\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAIA,IAAAI,iBAAA,GAAAJ,OAAA;AAIA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAIA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAT,sBAAA,CAAAC,OAAA;AAA2C,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAD,uBAAAW,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;;AAM3C,SAASG,eAAeA,CAAA,EAAG;EAAA,IAAAC,aAAA;EACvB,IAAMC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAC9B,IAAMC,OAAO,GAAG,IAAAC,uBAAW,EAACC,0CAAyB,CAAC;EACtD,IAAMC,KAAK,GAAG,IAAAF,uBAAW,EAACG,wCAAuB,CAAC;EAClD,IAAMC,OAAO,GAAG,IAAAJ,uBAAW,EAACK,kBAAU,CAAC;EAEvC,IAAAC,eAAA,GAA0BC,cAAK,CAACC,QAAQ,CAAoB,CAAC;IAAAC,gBAAA,OAAAC,uBAAA,EAAAJ,eAAA;IAAtDK,KAAK,GAAAF,gBAAA;IAAEG,QAAQ,GAAAH,gBAAA;EAEtB,IAAMI,SAAS,GAAGN,cAAK,CAACO,WAAW;IAAA,IAAAC,IAAA,OAAAC,0BAAA,gBAAAC,oBAAA,C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AO,CAACb,KAAK,CAAC;QAAA;MACvC,CAAC;MACDH,QAAQ,EAAE,IAAI;MACdiB,OAAO,EAAE,IAAAR,eAAO,EACZ,IAAAC,0BAAQ,EACJC,kBAAS,CAACC,QAAQ,CACd,qEAAqE,CAE7E,CACJ,CAAC;MACDjB,MAAM,EAAE,SAAAA,OAAAuB,KAAA,EAA0B;QAAA,IAAxBC,UAAU,GAAAD,KAAA,CAAVC,UAAU;QAChB,OAAO;UACHtF,OAAO,EAAEsF,UAAU;UACnBC,WAAW,eAAAC,MAAA,CAAeF,UAAU,gBAAa;UACjDG,2BAA2B,WAAAA,4BAAAC,KAAA,EAAoB;YAAA,IAAlBC,eAAe,GAAAD,KAAA,CAAfC,eAAe;YACxC,IAAMC,YAAY,GAAG,IAAAC,cAAA,EACjBF,eAAe,EACf,UAAChC,IAAI;cAAA,OAAKA,IAAI,iBAAA6B,MAAA,CAAiBxF,OAAO,CAAE;YAAA,CAC5C,CAAC;YACD,OAAO4F,YAAY,IAAI,EAAE;UAC7B,CAAC;UACDE,cAAc,EAAE;QACpB,CAAC;MACL;IACJ,CAAC,EAAAN,MAAA,KAAAO,2BAAA,EACG,CAACxF,KAAK,GACJ,EAAE,GACF,CACI;MACIoD,IAAI,EAAE,OAAO;MACbC,IAAI,EAAE,OAAgB;MACtBE,MAAM,EAAE;QACJa,QAAQ,eAAE,IAAA3B,eAAA,EAACgD,mBAAW;UAACzF,KAAK,EAAEA;QAAM,CAAE;MAC1C;IACJ,CAAC,CACJ;EACT,CACL,CACJ;AACL;AAAA,IAAA0F,QAAA,GAAAC,OAAA,CAAA5G,OAAA,GAEA,aAAea,cAAK,CAACgG,IAAI,CAAC5G,eAAe,CAAC"}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactRedux","_Dialog","_remoteCopyModal","_remoteCopyModal2","_global","_CreateTableModal","_config","_UIFactory","_jsxRuntime","obj","__esModule","default","RemoteCopyModal","_pathsValues$","dispatch","useDispatch","visible","useSelector","getRemoteCopyModalVisible","paths","getRemoteCopyModalPaths","cluster","getCluster","_React$useState","React","useState","_React$useState2","_slicedToArray","error","setError","handleAdd","useCallback","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","form","_form$getState","values","input_table_paths","pool","rest","_response","wrap","_callee$","_context","prev","next","undefined","getState","_objectWithoutProperties","_excluded","remoteCopy","_objectSpread","_map","t0","response","data","stop","_x","apply","arguments","handleClose","hideRemoteCopyModal","pathsValues","useMemo","item","title","calculateValueOnPoolsLoaded","_ref2","loadedPoolNames","transferPool","_find","name","concat","_jsx","YTDFDialog","onAdd","onClose","headerProps","initialValues","cluster_name","schema_inference_mode","output_table_path","override","fields","type","caption","extras","disabled","width","length","frozen","required","excludeClusters","items","value","text","warning","_jsxs","_Fragment","children","docsUrl","makeLink","UIFactory","docsUrls","visibilityCondition","when","isActive","Boolean","tooltip","_ref3","dstCluster","placeholder","allowEphemeral","_toConsumableArray","DialogError","_default","exports","memo"],"sources":["RemoteCopyModal.tsx"],"sourcesContent":["import React from 'react';\nimport {useDispatch, useSelector} from 'react-redux';\nimport _ from 'lodash';\n\nimport {DialogError, FormApi, YTDFDialog} from '../../../components/Dialog/Dialog';\nimport {\n getRemoteCopyModalPaths,\n getRemoteCopyModalVisible,\n} from '../../../store/selectors/navigation/modals/remote-copy-modal';\nimport {\n hideRemoteCopyModal,\n remoteCopy,\n} from '../../../store/actions/navigation/modals/remote-copy-modal';\nimport {getCluster} from '../../../store/selectors/global';\nimport {makeLink} from '../../../navigation/Navigation/PathEditorModal/CreateTableModal/CreateTableModal';\nimport {YTError} from '../../../types';\nimport {RemoteCopyParams} from '../../../../@types/types';\nimport {AxiosError} from 'axios';\nimport {docsUrl} from '../../../config';\nimport UIFactory from '../../../UIFactory';\n\ntype Values = Omit<RemoteCopyParams, 'input_table_paths'> & {\n input_table_paths: Array<{title: string}>;\n};\n\nfunction RemoteCopyModal() {\n const dispatch = useDispatch();\n const visible = useSelector(getRemoteCopyModalVisible);\n const paths = useSelector(getRemoteCopyModalPaths);\n const cluster = useSelector(getCluster);\n\n const [error, setError] = React.useState<YTError | unknown>();\n\n const handleAdd = React.useCallback(\n async (form: FormApi<Values>) => {\n try {\n setError(undefined);\n const {values} = form.getState();\n const {input_table_paths, pool, ...rest} = values;\n await dispatch(\n remoteCopy({\n ...rest,\n input_table_paths: _.map(input_table_paths, 'title'),\n pool: pool,\n }),\n );\n } catch (e: unknown) {\n setError((e as AxiosError<YTError>)?.response?.data || e);\n throw e;\n }\n },\n [setError],\n );\n\n const handleClose = React.useCallback(() => {\n dispatch(hideRemoteCopyModal());\n }, []);\n\n const pathsValues = React.useMemo(\n () =>\n _.map(paths, (item) => {\n return {\n title: item,\n };\n }),\n [paths],\n );\n\n const calculateValueOnPoolsLoaded = React.useCallback(\n ({loadedPoolNames}: {loadedPoolNames: Array<string>}) => {\n const transferPool = _.find(loadedPoolNames, (name) => name === `transfer_${cluster}`);\n return transferPool || '';\n },\n [cluster],\n );\n\n return !visible ? null : (\n <YTDFDialog<Values>\n visible={true}\n onAdd={handleAdd}\n onClose={handleClose}\n headerProps={{\n title: 'Remote copy',\n }}\n initialValues={{\n cluster_name: cluster,\n input_table_paths: pathsValues,\n schema_inference_mode: 'auto',\n output_table_path: pathsValues[0]?.title,\n override: false,\n }}\n fields={[\n {\n name: 'cluster_name',\n type: 'cluster',\n caption: 'Source cluster',\n extras: {\n disabled: true,\n width: 'max',\n },\n },\n {\n name: 'input_table_paths',\n type: 'editable-list',\n caption: paths.length > 1 ? 'Input paths' : 'Input path',\n extras: {\n frozen: true,\n },\n },\n {\n name: 'dstCluster',\n type: 'cluster',\n caption: 'Destination cluster',\n required: true,\n extras: {\n excludeClusters: [cluster],\n width: 'max',\n },\n },\n {\n name: 'output_table_path',\n type: 'text',\n caption: 'Output path',\n required: true,\n },\n {\n name: 'override',\n type: 'tumbler',\n caption: 'Override output',\n },\n {\n name: 'copy_attributes',\n type: 'tumbler',\n caption: 'Copy user attributes',\n },\n {\n name: 'schema_inference_mode',\n type: 'yt-select-single',\n caption: 'Schema inference',\n extras: {\n items: [\n {\n value: 'auto',\n text: 'Auto',\n },\n {\n value: 'from_input',\n text: 'From input',\n },\n {\n value: 'from_output',\n text: 'From output',\n },\n ],\n width: 'max',\n },\n },\n {\n name: 'pool',\n type: 'pool',\n caption: 'Pool',\n warning: (\n <>\n pool must have specified{' '}\n {docsUrl(\n makeLink(\n UIFactory.docsUrls['operations:remote_copy'],\n 'limits',\n true,\n ),\n )}\n </>\n ),\n visibilityCondition: {\n when: 'dstCluster',\n isActive: (value) => Boolean(value),\n },\n required: true,\n tooltip: docsUrl(\n makeLink(\n UIFactory.docsUrls[\n 'operations:operations_options#obshie-opcii-dlya-vseh-tipov-operacij'\n ],\n ),\n ),\n extras: ({dstCluster}: Values) => {\n return {\n cluster: dstCluster,\n placeholder: `(cluster: ${dstCluster}) pool name`,\n calculateValueOnPoolsLoaded,\n allowEphemeral: true,\n };\n },\n },\n ...(!error\n ? []\n : [\n {\n name: 'error',\n type: 'block' as const,\n extras: {\n children: <DialogError error={error} />,\n },\n },\n ]),\n ]}\n />\n );\n}\n\nexport default React.memo(RemoteCopyModal);\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAIA,IAAAI,iBAAA,GAAAJ,OAAA;AAIA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAIA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAT,sBAAA,CAAAC,OAAA;AAA2C,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAD,uBAAAW,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;;AAM3C,SAASG,eAAeA,CAAA,EAA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2BAA2B,EAA3BA,2BAA2B;UAC3B8C,cAAc,EAAE;QACpB,CAAC;MACL;IACJ,CAAC,EAAAxC,MAAA,KAAAyC,2BAAA,EACG,CAACxF,KAAK,GACJ,EAAE,GACF,CACI;MACI8C,IAAI,EAAE,OAAO;MACba,IAAI,EAAE,OAAgB;MACtBE,MAAM,EAAE;QACJa,QAAQ,eAAE,IAAA1B,eAAA,EAACyC,mBAAW;UAACzF,KAAK,EAAEA;QAAM,CAAE;MAC1C;IACJ,CAAC,CACJ;EACT,CACL,CACJ;AACL;AAAA,IAAA0F,QAAA,GAAAC,OAAA,CAAA5G,OAAA,GAEA,aAAea,cAAK,CAACgG,IAAI,CAAC5G,eAAe,CAAC"}
@@ -14,6 +14,7 @@ import ypath from '../../../../common/thor/ypath';
14
14
  import Suggest from '../../../../components/Suggest/Suggest';
15
15
  import { YTApiId, ytApiV3Id } from '../../../../rum/rum-wrap-api';
16
16
  import { wrapApiPromiseByToaster } from '../../../../utils/utils';
17
+ import { usePoolTreeOrLoadDefault } from '../../../../hooks/global-pool-trees';
17
18
  import "./PoolSuggestControl.css";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
19
20
  var block = cn('pool-suggest-control');
@@ -40,28 +41,32 @@ export function PoolSuggestControl(props) {
40
41
  poolNames = _React$useState2[0].items,
41
42
  setPoolNames = _React$useState2[1];
42
43
  var loadedPools = useLoadedPools(cluster, poolTree);
43
- React.useEffect(function () {
44
- loadedPools.then(function (_ref) {
45
- var names = _ref.names,
46
- tree = _ref.tree;
47
- var noRoot = _filter(names, function (item) {
48
- return '<Root>' !== item;
49
- });
50
- var valueIndex = _indexOf(noRoot, value);
51
- if (value && -1 === valueIndex) {
52
- onChange('');
53
- }
54
- setPoolNames({
55
- items: _sortBy(noRoot),
56
- itemsTree: tree
57
- });
58
- if (calculateValueOnPoolsLoaded) {
59
- onChange(calculateValueOnPoolsLoaded({
60
- loadedPoolNames: noRoot
61
- }));
62
- }
44
+ React.useEffect(function onPoolLoaded() {
45
+ var names = loadedPools.names,
46
+ tree = loadedPools.tree;
47
+ if (!tree) {
48
+ return;
49
+ }
50
+ var noRoot = _filter(names, function (item) {
51
+ return '<Root>' !== item;
63
52
  });
64
- }, [loadedPools, setPoolNames, onChange]);
53
+ var valueIndex = _indexOf(noRoot, value);
54
+ if (value && -1 === valueIndex) {
55
+ onChange('');
56
+ }
57
+ setPoolNames({
58
+ items: _sortBy(noRoot),
59
+ itemsTree: tree
60
+ });
61
+ if (calculateValueOnPoolsLoaded) {
62
+ onChange(calculateValueOnPoolsLoaded({
63
+ loadedPoolNames: noRoot
64
+ }));
65
+ }
66
+ },
67
+ // value should not affect the useEffect
68
+ [loadedPools, setPoolNames, onChange, calculateValueOnPoolsLoaded /*, value */]);
69
+
65
70
  var getItems = React.useCallback(function (_items, filter) {
66
71
  if (!filter) {
67
72
  return poolNames;
@@ -74,7 +79,7 @@ export function PoolSuggestControl(props) {
74
79
  });
75
80
  var res = _slice(poolNames, from, to);
76
81
  return res;
77
- }, [poolNames, value]);
82
+ }, [poolNames]);
78
83
  return /*#__PURE__*/_jsx(Suggest, {
79
84
  popupClassName: block('popup'),
80
85
  text: value,
@@ -100,30 +105,39 @@ PoolSuggestControl.isEmpty = function (value) {
100
105
  };
101
106
  function useLoadedPools(cluster) {
102
107
  var poolTree = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
103
- return React.useMemo(function () {
108
+ var _React$useState3 = React.useState({
109
+ names: []
110
+ }),
111
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
112
+ result = _React$useState4[0],
113
+ setResult = _React$useState4[1];
114
+ var currentClusterTree = usePoolTreeOrLoadDefault(poolTree);
115
+ React.useMemo(function () {
104
116
  if (cluster) {
105
- return wrapApiPromiseByToaster(axios.get("/api/pool-names/".concat(cluster, "?poolTree=").concat(poolTree)), {
117
+ wrapApiPromiseByToaster(axios.get("/api/pool-names/".concat(cluster, "?poolTree=").concat(poolTree)), {
106
118
  skipSuccessToast: true,
107
119
  toasterName: 'load-pool-names',
108
120
  errorTitle: 'Failed to load pools'
109
- }).then(function (_ref2) {
110
- var data = _ref2.data;
111
- return data;
121
+ }).then(function (_ref) {
122
+ var data = _ref.data;
123
+ setResult(data);
112
124
  });
113
- } else {
114
- return wrapApiPromiseByToaster(ytApiV3Id.list(YTApiId.listPoolNames, _objectSpread({
115
- path: "//sys/scheduler/orchid/scheduler/pool_trees/".concat(poolTree, "/pools")
125
+ } else if (poolTree || currentClusterTree) {
126
+ var localPoolTree = poolTree || currentClusterTree;
127
+ wrapApiPromiseByToaster(ytApiV3Id.list(YTApiId.listPoolNames, _objectSpread({
128
+ path: "//sys/scheduler/orchid/scheduler/pool_trees/".concat(localPoolTree, "/pools")
116
129
  }, USE_MAX_SIZE)), {
117
130
  skipSuccessToast: true,
118
131
  toasterName: 'load-pool-names',
119
132
  errorTitle: 'Failed to load pools'
120
133
  }).then(function (names) {
121
- return {
134
+ setResult({
122
135
  names: ypath.getValue(names),
123
- tree: poolTree
124
- };
136
+ tree: localPoolTree
137
+ });
125
138
  });
126
139
  }
127
- }, [cluster, poolTree]);
140
+ }, [cluster, currentClusterTree, poolTree]);
141
+ return result;
128
142
  }
129
143
  // #sourceMappingURL=PoolSuggestControl.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","cn","axios","USE_MAX_SIZE","ypath","Suggest","YTApiId","ytApiV3Id","wrapApiPromiseByToaster","jsx","_jsx","block","PoolSuggestControl","props","allowEmpty","allowEphemeral","value","onChange","placeholder","poolTree","cluster","calculateValueOnPoolsLoaded","disabled","_React$useState","useState","items","itemsTree","_React$useState2","_slicedToArray","poolNames","setPoolNames","loadedPools","useLoadedPools","useEffect","then","_ref","names","tree","noRoot","_filter","item","valueIndex","_indexOf","_sortBy","loadedPoolNames","getItems","useCallback","_items","filter","from","_sortedIndexBy","substring","length","to","_sortedLastIndexBy","res","_slice","popupClassName","text","apply","v","onItemClick","onTextUpdate","undefined","getDefaultValue","isEmpty","arguments","useMemo","get","concat","skipSuccessToast","toasterName","errorTitle","_ref2","data","list","listPoolNames","_objectSpread","path","getValue"],"sources":["PoolSuggestControl.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport cn from 'bem-cn-lite';\nimport axios from 'axios';\n\nimport {USE_MAX_SIZE} from '../../../../../shared/constants/yt-api';\nimport ypath from '../../../../common/thor/ypath';\n\nimport {DialogControlProps} from '../../../../components/Dialog/Dialog.types';\nimport Suggest from '../../../../components/Suggest/Suggest';\n\nimport {YTApiId, ytApiV3Id} from '../../../../rum/rum-wrap-api';\nimport {wrapApiPromiseByToaster} from '../../../../utils/utils';\n\nimport './PoolSuggestControl.scss';\n\nconst block = cn('pool-suggest-control');\n\ntype Props = DialogControlProps<string> & {\n // If not defined then current cluster should be used\n cluster?: string;\n // If not defined then default pool tree should be used\n poolTree?: string;\n calculateValueOnPoolsLoaded?: (params: {loadedPoolNames: Array<string>}) => string;\n\n allowEmpty?: boolean;\n allowEphemeral?: boolean;\n\n disabled?: boolean;\n};\n\n/**\n * The suggest should be used to select pools of current cluster\n * @param props\n * @returns\n */\nexport function PoolSuggestControl(props: Props) {\n const {\n allowEmpty,\n allowEphemeral,\n value,\n onChange,\n placeholder,\n poolTree,\n cluster,\n calculateValueOnPoolsLoaded,\n disabled,\n } = props;\n\n const [{items: poolNames}, setPoolNames] = React.useState<{\n items: Array<string>;\n itemsTree: string;\n }>({\n items: [],\n itemsTree: '',\n });\n\n const loadedPools = useLoadedPools(cluster, poolTree);\n\n React.useEffect(() => {\n loadedPools.then(({names, tree}) => {\n const noRoot = _.filter(names, (item) => '<Root>' !== item);\n const valueIndex = _.indexOf(noRoot, value);\n if (value && -1 === valueIndex) {\n onChange('');\n }\n setPoolNames({items: _.sortBy(noRoot), itemsTree: tree});\n if (calculateValueOnPoolsLoaded) {\n onChange(calculateValueOnPoolsLoaded({loadedPoolNames: noRoot}));\n }\n });\n }, [loadedPools, setPoolNames, onChange]);\n\n const getItems = React.useCallback(\n (_items: unknown, filter?: string) => {\n if (!filter) {\n return poolNames;\n }\n const from = _.sortedIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n const to = _.sortedLastIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n\n const res = _.slice(poolNames, from, to);\n return res;\n },\n [poolNames, value],\n );\n\n return (\n <Suggest\n popupClassName={block('popup')}\n text={value}\n filter={getItems}\n apply={(v) => allowEphemeral && onChange(typeof v === 'string' ? v : v.value)}\n onItemClick={(v) => onChange(typeof v === 'string' ? v : v.value)}\n onTextUpdate={allowEmpty ? (text) => !text && onChange('') : undefined}\n placeholder={placeholder}\n disabled={disabled}\n />\n );\n}\n\nPoolSuggestControl.getDefaultValue = () => {\n return '';\n};\n\nPoolSuggestControl.isEmpty = (value: Props['value']) => {\n return !value;\n};\n\nfunction useLoadedPools(\n cluster?: string,\n poolTree = '',\n): Promise<{names: Array<string>; tree: string}> {\n return React.useMemo(() => {\n if (cluster) {\n return wrapApiPromiseByToaster(\n axios.get(`/api/pool-names/${cluster}?poolTree=${poolTree}`),\n {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n },\n ).then(({data}) => {\n return data;\n });\n } else {\n return wrapApiPromiseByToaster(\n ytApiV3Id.list(YTApiId.listPoolNames, {\n path: `//sys/scheduler/orchid/scheduler/pool_trees/${poolTree}/pools`,\n ...USE_MAX_SIZE,\n }),\n {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n },\n ).then((names) => {\n return {names: ypath.getValue(names), tree: poolTree};\n });\n }\n }, [cluster, poolTree]);\n}\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,EAAE,MAAM,aAAa;AAC5B,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAAQC,YAAY,QAAO,wCAAwC;AACnE,OAAOC,KAAK,MAAM,+BAA+B;AAGjD,OAAOC,OAAO,MAAM,wCAAwC;AAE5D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,CAAC,MAAM;MACH,OAAOlE,uBAAuB,CAC1BD,SAAS,CAACoE,IAAI,CAACrE,OAAO,CAACsE,aAAa,EAAAC,aAAA;QAChCC,IAAI,iDAAAT,MAAA,CAAiDlD,QAAQ;MAAQ,GAClEhB,YAAY,CAClB,CAAC,EACF;QACImE,gBAAgB,EAAE,IAAI;QACtBC,WAAW,EAAE,iBAAiB;QAC9BC,UAAU,EAAE;MAChB,CACJ,CAAC,CAACtC,IAAI,CAAC,UAACE,KAAK,EAAK;QACd,OAAO;UAACA,KAAK,EAAEhC,KAAK,CAAC2E,QAAQ,CAAC3C,KAAK,CAAC;UAAEC,IAAI,EAAElB;QAAQ,CAAC;MACzD,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAACC,OAAO,EAAED,QAAQ,CAAC,CAAC;AAC3B"}
1
+ {"version":3,"names":["React","cn","axios","USE_MAX_SIZE","ypath","Suggest","YTApiId","ytApiV3Id","wrapApiPromiseByToaster","usePoolTreeOrLoadDefault","jsx","_jsx","block","PoolSuggestControl","props","allowEmpty","allowEphemeral","value","onChange","placeholder","poolTree","cluster","calculateValueOnPoolsLoaded","disabled","_React$useState","useState","items","itemsTree","_React$useState2","_slicedToArray","poolNames","setPoolNames","loadedPools","useLoadedPools","useEffect","onPoolLoaded","names","tree","noRoot","_filter","item","valueIndex","_indexOf","_sortBy","loadedPoolNames","getItems","useCallback","_items","filter","from","_sortedIndexBy","substring","length","to","_sortedLastIndexBy","res","_slice","popupClassName","text","apply","v","onItemClick","onTextUpdate","undefined","getDefaultValue","isEmpty","arguments","_React$useState3","_React$useState4","result","setResult","currentClusterTree","useMemo","get","concat","skipSuccessToast","toasterName","errorTitle","then","_ref","data","localPoolTree","list","listPoolNames","_objectSpread","path","getValue"],"sources":["PoolSuggestControl.tsx"],"sourcesContent":["import React from 'react';\n\nimport _ from 'lodash';\nimport cn from 'bem-cn-lite';\nimport axios from 'axios';\n\nimport {USE_MAX_SIZE} from '../../../../../shared/constants/yt-api';\nimport ypath from '../../../../common/thor/ypath';\n\nimport {DialogControlProps} from '../../../../components/Dialog/Dialog.types';\nimport Suggest from '../../../../components/Suggest/Suggest';\n\nimport {YTApiId, ytApiV3Id} from '../../../../rum/rum-wrap-api';\nimport {wrapApiPromiseByToaster} from '../../../../utils/utils';\nimport {usePoolTreeOrLoadDefault} from '../../../../hooks/global-pool-trees';\n\nimport './PoolSuggestControl.scss';\n\nconst block = cn('pool-suggest-control');\n\ntype Props = DialogControlProps<string> & {\n // If not defined then current cluster should be used\n cluster?: string;\n // If not defined then default pool tree should be used\n poolTree?: string;\n calculateValueOnPoolsLoaded?: (params: {loadedPoolNames: Array<string>}) => string;\n\n allowEmpty?: boolean;\n allowEphemeral?: boolean;\n\n disabled?: boolean;\n};\n\n/**\n * The suggest should be used to select pools of current cluster\n * @param props\n * @returns\n */\nexport function PoolSuggestControl(props: Props) {\n const {\n allowEmpty,\n allowEphemeral,\n value,\n onChange,\n placeholder,\n poolTree,\n cluster,\n calculateValueOnPoolsLoaded,\n disabled,\n } = props;\n\n const [{items: poolNames}, setPoolNames] = React.useState<{\n items: Array<string>;\n itemsTree: string;\n }>({\n items: [],\n itemsTree: '',\n });\n\n const loadedPools = useLoadedPools(cluster, poolTree);\n\n React.useEffect(\n function onPoolLoaded() {\n const {names, tree} = loadedPools;\n if (!tree) {\n return;\n }\n const noRoot = _.filter(names, (item) => '<Root>' !== item);\n const valueIndex = _.indexOf(noRoot, value);\n if (value && -1 === valueIndex) {\n onChange('');\n }\n setPoolNames({items: _.sortBy(noRoot), itemsTree: tree});\n if (calculateValueOnPoolsLoaded) {\n onChange(calculateValueOnPoolsLoaded({loadedPoolNames: noRoot}));\n }\n },\n // value should not affect the useEffect\n [loadedPools, setPoolNames, onChange, calculateValueOnPoolsLoaded /*, value */],\n );\n\n const getItems = React.useCallback(\n (_items: unknown, filter?: string) => {\n if (!filter) {\n return poolNames;\n }\n const from = _.sortedIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n const to = _.sortedLastIndexBy(poolNames, filter, (item) =>\n item.substring(0, filter.length),\n );\n\n const res = _.slice(poolNames, from, to);\n return res;\n },\n [poolNames],\n );\n\n return (\n <Suggest\n popupClassName={block('popup')}\n text={value}\n filter={getItems}\n apply={(v) => allowEphemeral && onChange(typeof v === 'string' ? v : v.value)}\n onItemClick={(v) => onChange(typeof v === 'string' ? v : v.value)}\n onTextUpdate={allowEmpty ? (text) => !text && onChange('') : undefined}\n placeholder={placeholder}\n disabled={disabled}\n />\n );\n}\n\nPoolSuggestControl.getDefaultValue = () => {\n return '';\n};\n\nPoolSuggestControl.isEmpty = (value: Props['value']) => {\n return !value;\n};\n\nfunction useLoadedPools(cluster?: string, poolTree = ''): {names: Array<string>; tree?: string} {\n const [result, setResult] = React.useState<{names: Array<string>; tree?: string}>({names: []});\n\n const currentClusterTree = usePoolTreeOrLoadDefault(poolTree);\n\n React.useMemo(() => {\n if (cluster) {\n wrapApiPromiseByToaster(axios.get(`/api/pool-names/${cluster}?poolTree=${poolTree}`), {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n }).then(({data}) => {\n setResult(data);\n });\n } else if (poolTree || currentClusterTree) {\n const localPoolTree = poolTree || currentClusterTree;\n wrapApiPromiseByToaster(\n ytApiV3Id.list(YTApiId.listPoolNames, {\n path: `//sys/scheduler/orchid/scheduler/pool_trees/${localPoolTree}/pools`,\n ...USE_MAX_SIZE,\n }),\n {\n skipSuccessToast: true,\n toasterName: 'load-pool-names',\n errorTitle: 'Failed to load pools',\n },\n ).then((names) => {\n setResult({names: ypath.getValue(names), tree: localPoolTree});\n });\n }\n }, [cluster, currentClusterTree, poolTree]);\n\n return result;\n}\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,EAAE,MAAM,aAAa;AAC5B,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAAQC,YAAY,QAAO,wCAAwC;AACnE,OAAOC,KAAK,MAAM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,CAACN,KAAK,CAACuE,GAAG,oBAAAC,MAAA,CAAoBrD,OAAO,gBAAAqD,MAAA,CAAatD,QAAQ,CAAE,CAAC,EAAE;QAClFuD,gBAAgB,EAAE,IAAI;QACtBC,WAAW,EAAE,iBAAiB;QAC9BC,UAAU,EAAE;MAChB,CAAC,CAAC,CAACC,IAAI,CAAC,UAAAC,IAAA,EAAY;QAAA,IAAVC,IAAI,GAAAD,IAAA,CAAJC,IAAI;QACVV,SAAS,CAACU,IAAI,CAAC;MACnB,CAAC,CAAC;IACN,CAAC,MAAM,IAAI5D,QAAQ,IAAImD,kBAAkB,EAAE;MACvC,IAAMU,aAAa,GAAG7D,QAAQ,IAAImD,kBAAkB;MACpD/D,uBAAuB,CACnBD,SAAS,CAAC2E,IAAI,CAAC5E,OAAO,CAAC6E,aAAa,EAAAC,aAAA;QAChCC,IAAI,iDAAAX,MAAA,CAAiDO,aAAa;MAAQ,GACvE9E,YAAY,CAClB,CAAC,EACF;QACIwE,gBAAgB,EAAE,IAAI;QACtBC,WAAW,EAAE,iBAAiB;QAC9BC,UAAU,EAAE;MAChB,CACJ,CAAC,CAACC,IAAI,CAAC,UAAC1C,KAAK,EAAK;QACdkC,SAAS,CAAC;UAAClC,KAAK,EAAEhC,KAAK,CAACkF,QAAQ,CAAClD,KAAK,CAAC;UAAEC,IAAI,EAAE4C;QAAa,CAAC,CAAC;MAClE,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAAC5D,OAAO,EAAEkD,kBAAkB,EAAEnD,QAAQ,CAAC,CAAC;EAE3C,OAAOiD,MAAM;AACjB"}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export declare function PoolTreesLoader(): null;
3
+ export declare function usePoolTreeOrLoadDefault(poolTree?: string): string | undefined;
3
4
  export declare function WaitForDefaultPoolTree({ children, }: {
4
5
  children: ({ defaultPoolTree }: {
5
6
  defaultPoolTree: string;
@@ -13,9 +13,8 @@ export function PoolTreesLoader() {
13
13
  usePoolTreesLoaded();
14
14
  return null;
15
15
  }
16
- export function WaitForDefaultPoolTree(_ref) {
17
- var children = _ref.children;
18
- var _React$useState = React.useState(undefined),
16
+ export function usePoolTreeOrLoadDefault(poolTree) {
17
+ var _React$useState = React.useState(poolTree),
19
18
  _React$useState2 = _slicedToArray(_React$useState, 2),
20
19
  defaultPoolTree = _React$useState2[0],
21
20
  setDefaultPoolTree = _React$useState2[1];
@@ -24,6 +23,11 @@ export function WaitForDefaultPoolTree(_ref) {
24
23
  setDefaultPoolTree(value);
25
24
  });
26
25
  }, []);
26
+ return defaultPoolTree;
27
+ }
28
+ export function WaitForDefaultPoolTree(_ref) {
29
+ var children = _ref.children;
30
+ var defaultPoolTree = usePoolTreeOrLoadDefault();
27
31
  return defaultPoolTree ? children({
28
32
  defaultPoolTree: defaultPoolTree
29
33
  }) : null;
@@ -1 +1 @@
1
- {"version":3,"names":["React","useDispatch","loadPoolTreesIfNotLoaded","loadDefaultPoolTree","usePoolTreesLoaded","dispatch","useEffect","PoolTreesLoader","WaitForDefaultPoolTree","_ref","children","_React$useState","useState","undefined","_React$useState2","_slicedToArray","defaultPoolTree","setDefaultPoolTree","then","value"],"sources":["global-pool-trees.ts"],"sourcesContent":["import React from 'react';\nimport {useDispatch} from 'react-redux';\n\nimport {loadPoolTreesIfNotLoaded} from '../store/actions/global';\nimport {loadDefaultPoolTree} from '../utils/poolTrees';\n\nfunction usePoolTreesLoaded() {\n const dispatch = useDispatch();\n\n React.useEffect(() => {\n dispatch(loadPoolTreesIfNotLoaded());\n }, [dispatch]);\n}\n\nexport function PoolTreesLoader() {\n usePoolTreesLoaded();\n return null;\n}\n\nexport function WaitForDefaultPoolTree({\n children,\n}: {\n children: ({defaultPoolTree}: {defaultPoolTree: string}) => React.ReactNode;\n}) {\n const [defaultPoolTree, setDefaultPoolTree] = React.useState<string | undefined>(undefined);\n\n React.useEffect(() => {\n loadDefaultPoolTree().then((value) => {\n setDefaultPoolTree(value);\n });\n }, []);\n\n return defaultPoolTree ? children({defaultPoolTree}) : null;\n}\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,WAAW,QAAO,aAAa;AAEvC,SAAQC,wBAAwB,QAAO,yBAAyB;AAChE,SAAQC,mBAAmB,QAAO,oBAAoB;AAEtD,SAASC,kBAAkBA,CAAA,EAAG;EAC1B,IAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAE9BD,KAAK,CAACM,SAAS,CAAC,YAAM;IAClBD,QAAQ,CAACH,wBAAwB,CAAC,CAAC,CAAC;EACxC,CAAC,EAAE,CAACG,QAAQ,CAAC,CAAC;AAClB;AAEA,OAAO,SAASE,eAAeA,CAAA,EAAG;EAC9BH,kBAAkB,CAAC,CAAC;EACpB,OAAO,IAAI;AACf;AAEA,OAAO,SAASI,sBAAsBA,CAAAC,IAAA,EAInC;EAAA,IAHCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAIR,IAAAC,eAAA,GAA8CX,KAAK,CAACY,QAAQ,CAAqBC,SAAS,CAAC;IAAAC,gBAAA,GAAAC,cAAA,CAAAJ,eAAA;IAApFK,eAAe,GAAAF,gBAAA;IAAEG,kBAAkB,GAAAH,gBAAA;EAE1Cd,KAAK,CAACM,SAAS,CAAC,YAAM;IAClBH,mBAAmB,CAAC,CAAC,CAACe,IAAI,CAAC,UAACC,KAAK,EAAK;MAClCF,kBAAkB,CAACE,KAAK,CAAC;IAC7B,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,eAAe,GAAGN,QAAQ,CAAC;IAACM,eAAe,EAAfA;EAAe,CAAC,CAAC,GAAG,IAAI;AAC/D"}
1
+ {"version":3,"names":["React","useDispatch","loadPoolTreesIfNotLoaded","loadDefaultPoolTree","usePoolTreesLoaded","dispatch","useEffect","PoolTreesLoader","usePoolTreeOrLoadDefault","poolTree","_React$useState","useState","_React$useState2","_slicedToArray","defaultPoolTree","setDefaultPoolTree","then","value","WaitForDefaultPoolTree","_ref","children"],"sources":["global-pool-trees.ts"],"sourcesContent":["import React from 'react';\nimport {useDispatch} from 'react-redux';\n\nimport {loadPoolTreesIfNotLoaded} from '../store/actions/global';\nimport {loadDefaultPoolTree} from '../utils/poolTrees';\n\nfunction usePoolTreesLoaded() {\n const dispatch = useDispatch();\n\n React.useEffect(() => {\n dispatch(loadPoolTreesIfNotLoaded());\n }, [dispatch]);\n}\n\nexport function PoolTreesLoader() {\n usePoolTreesLoaded();\n return null;\n}\n\nexport function usePoolTreeOrLoadDefault(poolTree?: string) {\n const [defaultPoolTree, setDefaultPoolTree] = React.useState<string | undefined>(poolTree);\n\n React.useEffect(() => {\n loadDefaultPoolTree().then((value) => {\n setDefaultPoolTree(value);\n });\n }, []);\n\n return defaultPoolTree;\n}\n\nexport function WaitForDefaultPoolTree({\n children,\n}: {\n children: ({defaultPoolTree}: {defaultPoolTree: string}) => React.ReactNode;\n}) {\n const defaultPoolTree = usePoolTreeOrLoadDefault();\n\n return defaultPoolTree ? children({defaultPoolTree}) : null;\n}\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,WAAW,QAAO,aAAa;AAEvC,SAAQC,wBAAwB,QAAO,yBAAyB;AAChE,SAAQC,mBAAmB,QAAO,oBAAoB;AAEtD,SAASC,kBAAkBA,CAAA,EAAG;EAC1B,IAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAE9BD,KAAK,CAACM,SAAS,CAAC,YAAM;IAClBD,QAAQ,CAACH,wBAAwB,CAAC,CAAC,CAAC;EACxC,CAAC,EAAE,CAACG,QAAQ,CAAC,CAAC;AAClB;AAEA,OAAO,SAASE,eAAeA,CAAA,EAAG;EAC9BH,kBAAkB,CAAC,CAAC;EACpB,OAAO,IAAI;AACf;AAEA,OAAO,SAASI,wBAAwBA,CAACC,QAAiB,EAAE;EACxD,IAAAC,eAAA,GAA8CV,KAAK,CAACW,QAAQ,CAAqBF,QAAQ,CAAC;IAAAG,gBAAA,GAAAC,cAAA,CAAAH,eAAA;IAAnFI,eAAe,GAAAF,gBAAA;IAAEG,kBAAkB,GAAAH,gBAAA;EAE1CZ,KAAK,CAACM,SAAS,CAAC,YAAM;IAClBH,mBAAmB,CAAC,CAAC,CAACa,IAAI,CAAC,UAACC,KAAK,EAAK;MAClCF,kBAAkB,CAACE,KAAK,CAAC;IAC7B,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,eAAe;AAC1B;AAEA,OAAO,SAASI,sBAAsBA,CAAAC,IAAA,EAInC;EAAA,IAHCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAIR,IAAMN,eAAe,GAAGN,wBAAwB,CAAC,CAAC;EAElD,OAAOM,eAAe,GAAGM,QAAQ,CAAC;IAACN,eAAe,EAAfA;EAAe,CAAC,CAAC,GAAG,IAAI;AAC/D"}