pollination-react-io 1.26.2 → 1.27.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.
@@ -0,0 +1,2 @@
1
+ import type { EffectCallback, DependencyList } from "react";
2
+ export declare const useDebounce: (delay: number) => (effect: EffectCallback, deps?: DependencyList) => void;
@@ -40596,23 +40596,44 @@ var getFileIcon$1 = function (type, disabled) {
40596
40596
  }
40597
40597
  };
40598
40598
 
40599
+ // https://dev.to/rajeshroyal/how-to-make-a-custom-debounce-hook-in-react-js-4gcc
40600
+ var useDebounce = function (delay) { return function (effect, deps) {
40601
+ return useEffect(function () {
40602
+ var handler = setTimeout(effect, delay);
40603
+ return function () { return clearTimeout(handler); };
40604
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40605
+ }, __spreadArray(__spreadArray([], deps, true), [delay], false));
40606
+ }; };
40607
+
40608
+ var longDebounce$3 = useDebounce(500);
40609
+ var shortDebounce$3 = useDebounce(200);
40599
40610
  var SelectCloudArtifacts = function (_a) {
40600
40611
  var _b, _c;
40601
40612
  var projectOwner = _a.projectOwner, projectName = _a.projectName, jobId = _a.jobId, value = _a.value, hidden = _a.hidden, _d = _a.fileNameMatch, fileNameMatch = _d === void 0 ? '.*' : _d, onChange = _a.onChange, client = _a.client;
40602
40613
  var comboBoxRef = useRef(null);
40603
- var listArtifacts = useArtifacts(projectOwner, projectName, client).listArtifacts;
40604
40614
  var valueRef = useRef();
40615
+ var listArtifacts = useArtifacts(projectOwner, projectName, client).listArtifacts;
40605
40616
  var _e = useState(), selArtifact = _e[0], setSelArtifact = _e[1];
40606
40617
  var _f = useState(false), loading = _f[0], setLoading = _f[1];
40607
40618
  var _g = useState({ folders: [], files: [] }), artifacts = _g[0], setArtifacts = _g[1];
40608
- var _h = useState(value ?
40619
+ var _h = useState((value === null || value === void 0 ? void 0 : value.key) ?
40609
40620
  [value.key.split('/').slice(0, -1).join('/')]
40610
40621
  :
40611
40622
  []), path = _h[0], setPath = _h[1];
40612
40623
  var handleClear = useCallback(function () {
40613
40624
  setPath([]);
40614
40625
  }, []);
40626
+ // resetting query
40615
40627
  useEffect(function () {
40628
+ // deselect item
40629
+ if (comboBoxRef.current) {
40630
+ comboBoxRef.current.selectItem(null);
40631
+ }
40632
+ setArtifacts({ folders: [], files: [] });
40633
+ }, [projectOwner, projectName]);
40634
+ longDebounce$3(function () {
40635
+ if (!client || !client.projects)
40636
+ return;
40616
40637
  setLoading(true);
40617
40638
  listArtifacts(path, jobId)
40618
40639
  .then(function (facts) {
@@ -40630,8 +40651,7 @@ var SelectCloudArtifacts = function (_a) {
40630
40651
  return newPath;
40631
40652
  });
40632
40653
  }, [selArtifact]);
40633
- useEffect(function () {
40634
- // nonmemoized value from react-hook-form or other parent causes infinite rerendering
40654
+ shortDebounce$3(function () {
40635
40655
  if (lodash_isequal(valueRef.current, selArtifact) ||
40636
40656
  (!valueRef.current && !selArtifact)) {
40637
40657
  return;
@@ -40642,11 +40662,8 @@ var SelectCloudArtifacts = function (_a) {
40642
40662
  comboBoxRef.current.selectItem(selArtifact);
40643
40663
  valueRef.current = selArtifact;
40644
40664
  // don't call onChange for undefined values
40645
- onChange && selArtifact && onChange(selArtifact);
40665
+ onChange && onChange(selArtifact);
40646
40666
  }, [onChange, selArtifact]);
40647
- useEffect(function () {
40648
- setSelArtifact(value);
40649
- }, [value]);
40650
40667
  var stateReducer = useCallback(function (state, actionAndChanges) {
40651
40668
  var type = actionAndChanges.type, changes = actionAndChanges.changes;
40652
40669
  switch (type) {
@@ -40790,9 +40807,8 @@ var ComboFileSelector = function (_a) {
40790
40807
  var projectOwner = _a.projectOwner, projectName = _a.projectName, value = _a.value, _b = _a.hidden, hidden = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, defaultOption = _a.defaultOption, optionsConfig = _a.optionsConfig, _d = _a.mode, mode = _d === void 0 ? 'cloud' : _d, onChange = _a.onChange, client = _a.client, inputProps = _a.inputProps;
40791
40808
  var host = getHost();
40792
40809
  var _e = useState(function () {
40793
- if (typeof defaultOption !== 'undefined') {
40794
- return defaultOption;
40795
- }
40810
+ if (defaultOption == null)
40811
+ return;
40796
40812
  if (host !== 'web') {
40797
40813
  if (mode !== 'cloud') {
40798
40814
  // plugin, local
@@ -40814,6 +40830,10 @@ var ComboFileSelector = function (_a) {
40814
40830
  var handleLocalArtifactSelect = useCallback(function (path) {
40815
40831
  onChange({ pollination_local_path: path });
40816
40832
  }, [onChange]);
40833
+ // reset onChange if option
40834
+ useEffect(function () {
40835
+ onChange();
40836
+ }, [option]);
40817
40837
  return (React__default.createElement("div", { "data-testid": "ComboFileSelector", style: {
40818
40838
  display: 'flex',
40819
40839
  flexDirection: 'column',
@@ -40821,7 +40841,7 @@ var ComboFileSelector = function (_a) {
40821
40841
  } },
40822
40842
  !hidden &&
40823
40843
  React__default.createElement(ButtonGroup, null,
40824
- (typeof optionsConfig['get_file'] === 'undefined' || optionsConfig['get_file']) &&
40844
+ mode === 'cloud' && (typeof optionsConfig['get_file'] === 'undefined' || optionsConfig['get_file']) &&
40825
40845
  React__default.createElement("button", { type: 'button', disabled: disabled, onClick: function () { return setOption('get_file'); }, style: {
40826
40846
  display: 'flex',
40827
40847
  boxShadow: !disabled && option === 'get_file' ?
@@ -41717,6 +41737,8 @@ TabPanel.tabsRole = 'TabPanel';
41717
41737
  TabPanel.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
41718
41738
  TabPanel.defaultProps = defaultProps;
41719
41739
 
41740
+ var longDebounce$2 = useDebounce(500);
41741
+ var shortDebounce$2 = useDebounce(200);
41720
41742
  var SelectProject = function (_a) {
41721
41743
  var _b, _c;
41722
41744
  var authUser = _a.authUser, client = _a.client, projectOwner = _a.projectOwner, value = _a.value, onChange = _a.onChange;
@@ -41725,16 +41747,17 @@ var SelectProject = function (_a) {
41725
41747
  var _d = useState(), selProject = _d[0], setSelProject = _d[1];
41726
41748
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
41727
41749
  var _f = useState([]), projects = _f[0], setProjects = _f[1];
41750
+ var _g = useState(1), pageNumber = _g[0], setPageNumber = _g[1];
41728
41751
  var totalProjectsRef = useRef({
41729
41752
  loaded: 0,
41730
41753
  total: undefined
41731
41754
  });
41732
- var _g = useState(0), total = _g[0], setTotal = _g[1];
41733
- var _h = useState({
41755
+ var _h = useState(0), total = _h[0], setTotal = _h[1];
41756
+ var projectApiRef = useRef({
41734
41757
  owner: (_b = [projectOwner]) !== null && _b !== void 0 ? _b : (authUser && [authUser.username]),
41735
- page: 1,
41758
+ page: pageNumber,
41736
41759
  perPage: 10,
41737
- }), queryConfig = _h[0], setQueryConfig = _h[1];
41760
+ });
41738
41761
  // resetting query
41739
41762
  useEffect(function () {
41740
41763
  // reset total loaded
@@ -41742,72 +41765,88 @@ var SelectProject = function (_a) {
41742
41765
  loaded: 0,
41743
41766
  total: undefined
41744
41767
  };
41745
- // deselect items
41768
+ // deselect item
41746
41769
  if (comboBoxRef.current) {
41747
- comboBoxRef.current.selectItem(value);
41770
+ comboBoxRef.current.selectItem(null);
41748
41771
  }
41749
41772
  setProjects([]);
41750
- setQueryConfig(function (q) { return (__assign(__assign({}, q), { owner: [projectOwner], page: 1 })); });
41751
- }, [projectOwner, value]);
41752
- var fetchProjects = useCallback(function (queryConfig) {
41773
+ setPageNumber(1);
41774
+ }, [projectOwner]);
41775
+ useEffect(function () {
41776
+ // select item
41777
+ if (comboBoxRef.current) {
41778
+ comboBoxRef.current.selectItem(value);
41779
+ }
41780
+ }, [value]);
41781
+ longDebounce$2(function () {
41782
+ var _a;
41783
+ projectApiRef.current = {
41784
+ owner: (_a = [projectOwner]) !== null && _a !== void 0 ? _a : (authUser && [authUser.username]),
41785
+ page: pageNumber,
41786
+ perPage: 10,
41787
+ };
41788
+ var queryConfig = projectApiRef.current;
41753
41789
  if (!authUser || !client || !client.projects)
41754
41790
  return;
41755
41791
  if (!queryConfig.owner)
41756
41792
  return;
41757
- var _a = totalProjectsRef.current, total = _a.total, loaded = _a.loaded;
41793
+ var _b = totalProjectsRef.current, total = _b.total, loaded = _b.loaded;
41758
41794
  if (total && loaded >= total)
41759
41795
  return;
41796
+ var fetchData = function () { return __awaiter$1(void 0, void 0, void 0, function () {
41797
+ var data;
41798
+ return __generator$1(this, function (_a) {
41799
+ switch (_a.label) {
41800
+ case 0: return [4 /*yield*/, client.projects.listProjects(queryConfig)];
41801
+ case 1:
41802
+ data = (_a.sent()).data;
41803
+ setProjects(function (state) { return state
41804
+ ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
41805
+ setTotal(data.total_count);
41806
+ totalProjectsRef.current.loaded += data.resources.length;
41807
+ totalProjectsRef.current.total = data.total_count;
41808
+ return [2 /*return*/];
41809
+ }
41810
+ });
41811
+ }); };
41812
+ // call the function
41760
41813
  setLoading(true);
41761
- client.projects.listProjects(queryConfig)
41762
- .then(function (_a) {
41763
- var data = _a.data;
41764
- setProjects(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
41765
- setTotal(data.total_count);
41766
- totalProjectsRef.current.loaded += data.resources.length;
41767
- totalProjectsRef.current.total = data.total_count;
41768
- })
41769
- .finally(function () {
41770
- setLoading(false);
41771
- });
41772
- }, [authUser, client]);
41773
- useEffect(function () {
41774
- fetchProjects(queryConfig);
41775
- }, [fetchProjects, queryConfig]);
41776
- useEffect(function () {
41814
+ fetchData()
41815
+ .catch(console.error)
41816
+ .finally(function () { return setLoading(false); });
41817
+ }, [authUser, client, projectOwner, pageNumber]);
41818
+ shortDebounce$2(function () {
41777
41819
  // nonmemoized value from react-hook-form or other parent causes infinite rerendering
41778
41820
  if (lodash_isequal(valueRef.current, selProject)) {
41779
41821
  return;
41780
41822
  }
41781
- if (selProject == null)
41782
- return;
41783
41823
  if (selProject && selProject.name) {
41784
41824
  comboBoxRef.current.setInputValue(selProject.name);
41785
41825
  }
41786
41826
  comboBoxRef.current.selectItem(selProject);
41787
41827
  valueRef.current = selProject;
41788
41828
  // don't call onChange for undefined values
41789
- onChange && selProject && onChange(selProject);
41829
+ onChange && onChange(selProject);
41790
41830
  }, [selProject, onChange]);
41791
- useEffect(function () {
41792
- setSelProject(value);
41793
- }, [value]);
41794
41831
  var onScrollReachEnd = useCallback(function () {
41795
41832
  // already loaded all runs
41796
41833
  var _a = totalProjectsRef.current, total = _a.total, loaded = _a.loaded;
41797
41834
  if (total && loaded >= total)
41798
41835
  return;
41799
- setQueryConfig(function (q) { return (__assign(__assign({}, q), { page: q.page ? q.page + 1 : 1 })); });
41836
+ setPageNumber(projectApiRef.current.page + 1);
41800
41837
  }, []);
41801
- return (React__default.createElement(ComboBox, { ref: comboBoxRef, items: projects !== null && projects !== void 0 ? projects : [], setSelected: setSelProject, onClear: function () { return setSelProject(undefined); }, inputProps: {
41838
+ return (React__default.createElement(ComboBox, { ref: comboBoxRef, items: projects !== null && projects !== void 0 ? projects : [], setSelected: setSelProject, inputProps: {
41802
41839
  placeholder: 'Select a project...',
41803
- }, loading: loading, disabled: !authUser || !queryConfig.owner, footer: (React__default.createElement("div", { key: "footer", style: {
41840
+ }, loading: loading, disabled: !authUser || !projectOwner, footer: (React__default.createElement("div", { key: "footer", style: {
41804
41841
  width: '100%',
41805
41842
  display: 'flex',
41806
41843
  justifyContent: 'center',
41807
41844
  color: 'var(--grey4)',
41808
- } }, "Showing ".concat((_c = projects === null || projects === void 0 ? void 0 : projects.length) !== null && _c !== void 0 ? _c : 0, " of ").concat(total, " projects"))), onScrollReachEnd: onScrollReachEnd }));
41845
+ } }, "Showing ".concat((_c = projects.length) !== null && _c !== void 0 ? _c : 0, " of ").concat(total, " projects"))), onScrollReachEnd: onScrollReachEnd }));
41809
41846
  };
41810
41847
 
41848
+ var longDebounce$1 = useDebounce(500);
41849
+ var shortDebounce$1 = useDebounce(200);
41811
41850
  var SelectAccount = function (_a) {
41812
41851
  var _b;
41813
41852
  var authUser = _a.authUser, client = _a.client, value = _a.value, onChange = _a.onChange;
@@ -41816,28 +41855,42 @@ var SelectAccount = function (_a) {
41816
41855
  var _c = useState(value), selAccount = _c[0], setSelAccount = _c[1];
41817
41856
  var _d = useState(function () { return authUser ? [authUser] : []; }), accounts = _d[0], setAccounts = _d[1];
41818
41857
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
41858
+ var _f = useState(1), pageNumber = _f[0], setPageNumber = _f[1];
41819
41859
  var totalAccountsRef = useRef({
41820
41860
  loaded: 0,
41821
41861
  total: undefined
41822
41862
  });
41823
- var _f = useState(0), total = _f[0], setTotal = _f[1];
41824
- var _g = useState({
41825
- page: 1,
41863
+ var _g = useState(0), total = _g[0], setTotal = _g[1];
41864
+ var accountsApiRef = useRef({
41865
+ page: pageNumber,
41826
41866
  perPage: 25,
41827
- }), queryConfig = _g[0], setQueryConfig = _g[1];
41828
- // resetting query
41867
+ });
41829
41868
  useEffect(function () {
41830
- if (authUser == null)
41831
- return;
41832
41869
  // reset total loaded
41833
41870
  totalAccountsRef.current = {
41834
41871
  loaded: 0,
41835
41872
  total: undefined
41836
41873
  };
41837
- setAccounts([authUser]);
41838
- setQueryConfig(function (q) { return (__assign(__assign({}, q), { member: [authUser === null || authUser === void 0 ? void 0 : authUser.username], page: 1 })); });
41839
- }, [authUser, onChange, value]);
41840
- var fetchOrganizations = useCallback(function (queryConfig) {
41874
+ // deselect items
41875
+ if (comboBoxRef.current) {
41876
+ comboBoxRef.current.selectItem(null);
41877
+ }
41878
+ setAccounts([]);
41879
+ setPageNumber(1);
41880
+ }, [authUser]);
41881
+ useEffect(function () {
41882
+ // select item
41883
+ if (comboBoxRef.current) {
41884
+ comboBoxRef.current.selectItem(value);
41885
+ }
41886
+ }, [value]);
41887
+ longDebounce$1(function () {
41888
+ accountsApiRef.current = {
41889
+ member: [authUser === null || authUser === void 0 ? void 0 : authUser.username],
41890
+ page: pageNumber,
41891
+ perPage: 25
41892
+ };
41893
+ var queryConfig = accountsApiRef.current;
41841
41894
  if (!authUser || !client || !client.orgs)
41842
41895
  return;
41843
41896
  if (!queryConfig.member)
@@ -41846,42 +41899,44 @@ var SelectAccount = function (_a) {
41846
41899
  // we've already loaded all accounts
41847
41900
  if (total && loaded >= total)
41848
41901
  return;
41902
+ var fetchData = function () { return __awaiter$1(void 0, void 0, void 0, function () {
41903
+ var data;
41904
+ return __generator$1(this, function (_a) {
41905
+ switch (_a.label) {
41906
+ case 0: return [4 /*yield*/, client.orgs.listOrgs(queryConfig)];
41907
+ case 1:
41908
+ data = (_a.sent()).data;
41909
+ setAccounts(function (state) { return state
41910
+ ? __spreadArray(__spreadArray([authUser], state, true), data.resources, true) : __spreadArray([authUser], data.resources, true); });
41911
+ setTotal(data.total_count);
41912
+ totalAccountsRef.current.loaded += data.resources.length;
41913
+ totalAccountsRef.current.total = data.total_count;
41914
+ return [2 /*return*/];
41915
+ }
41916
+ });
41917
+ }); };
41918
+ // call the function
41849
41919
  setLoading(true);
41850
- client.orgs.listOrgs(__assign(__assign({}, queryConfig), { member: [authUser.username] }))
41851
- .then(function (_a) {
41852
- var data = _a.data;
41853
- setAccounts(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
41854
- setTotal(data.total_count);
41855
- totalAccountsRef.current.loaded += data.resources.length;
41856
- totalAccountsRef.current.total = data.total_count;
41857
- })
41858
- .finally(function () {
41859
- setLoading(false);
41860
- });
41861
- }, [authUser, client]);
41862
- useEffect(function () {
41863
- fetchOrganizations(queryConfig);
41864
- }, [fetchOrganizations, queryConfig]);
41865
- useEffect(function () {
41920
+ fetchData()
41921
+ .catch(console.error)
41922
+ .finally(function () { return setLoading(false); });
41923
+ }, [authUser, client, pageNumber, selAccount]);
41924
+ shortDebounce$1(function () {
41925
+ // nonmemoized value from react-hook-form or other parent causes infinite rerendering
41866
41926
  if (lodash_isequal(valueRef.current, selAccount)) {
41867
41927
  return;
41868
41928
  }
41869
- if (selAccount == null)
41870
- return;
41871
41929
  comboBoxRef.current.selectItem(selAccount);
41872
41930
  valueRef.current = selAccount;
41873
- // comboBoxRef.current.setInputValue( selAccount.name )
41931
+ // don't call onChange for undefined values
41874
41932
  onChange && onChange(selAccount);
41875
- }, [onChange, selAccount]);
41876
- useEffect(function () {
41877
- setSelAccount(value);
41878
- }, [value]);
41933
+ }, [selAccount, onChange]);
41879
41934
  var onScrollReachEnd = useCallback(function () {
41880
41935
  // already loaded all runs
41881
41936
  var _a = totalAccountsRef.current, total = _a.total, loaded = _a.loaded;
41882
41937
  if (total && loaded >= total)
41883
41938
  return;
41884
- setQueryConfig(function (q) { return (__assign(__assign({}, q), { page: q.page ? q.page + 1 : 1 })); });
41939
+ setPageNumber(accountsApiRef.current.page + 1);
41885
41940
  }, []);
41886
41941
  return (React__default.createElement(ComboBox, { ref: comboBoxRef,
41887
41942
  // @ts-ignore
@@ -41912,6 +41967,8 @@ var SelectAccount = function (_a) {
41912
41967
  } }, "Showing ".concat((_b = accounts === null || accounts === void 0 ? void 0 : accounts.length) !== null && _b !== void 0 ? _b : 0, " of ").concat(total + 1, " accounts."))), onScrollReachEnd: onScrollReachEnd }));
41913
41968
  };
41914
41969
 
41970
+ var longDebounce = useDebounce(500);
41971
+ var shortDebounce = useDebounce(200);
41915
41972
  var SelectRecipe = function (_a) {
41916
41973
  var _b, _c;
41917
41974
  var authUser = _a.authUser, client = _a.client, projectName = _a.projectName, projectOwner = _a.projectOwner, value = _a.value, onChange = _a.onChange;
@@ -41920,17 +41977,18 @@ var SelectRecipe = function (_a) {
41920
41977
  var _d = useState(), selRecipe = _d[0], setSelRecipe = _d[1];
41921
41978
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
41922
41979
  var _f = useState(), recipes = _f[0], setRecipes = _f[1];
41980
+ var _g = useState(1), pageNumber = _g[0], setPageNumber = _g[1];
41923
41981
  var totalRecipesRef = useRef({
41924
41982
  loaded: 0,
41925
41983
  total: undefined
41926
41984
  });
41927
- var _g = useState(0), total = _g[0], setTotal = _g[1];
41928
- var _h = useState({
41985
+ var _h = useState(0), total = _h[0], setTotal = _h[1];
41986
+ var projectApiRef = useRef({
41929
41987
  owner: projectOwner !== null && projectOwner !== void 0 ? projectOwner : (authUser && authUser.username),
41930
41988
  name: projectName,
41931
- page: 1,
41989
+ page: pageNumber,
41932
41990
  perPage: 10,
41933
- }), queryConfig = _h[0], setQueryConfig = _h[1];
41991
+ });
41934
41992
  // resetting query
41935
41993
  useEffect(function () {
41936
41994
  // reset total loaded
@@ -41940,58 +41998,71 @@ var SelectRecipe = function (_a) {
41940
41998
  };
41941
41999
  // deselect items
41942
42000
  if (comboBoxRef.current) {
41943
- comboBoxRef.current.selectItem(value);
42001
+ comboBoxRef.current.selectItem(null);
41944
42002
  }
41945
42003
  setRecipes([]);
41946
- setQueryConfig(function (q) { return (__assign(__assign({}, q), { owner: projectOwner, name: projectName, page: 1 })); });
41947
- }, [projectOwner, projectName, value]);
41948
- var fetchRecipes = useCallback(function (queryConfig) {
42004
+ setPageNumber(1);
42005
+ }, [projectOwner, projectName]);
42006
+ useEffect(function () {
42007
+ // select item
42008
+ if (comboBoxRef.current) {
42009
+ comboBoxRef.current.selectItem(value);
42010
+ }
42011
+ }, [value]);
42012
+ longDebounce(function () {
42013
+ projectApiRef.current = {
42014
+ owner: projectOwner !== null && projectOwner !== void 0 ? projectOwner : (authUser && authUser.username),
42015
+ name: projectName,
42016
+ page: pageNumber,
42017
+ perPage: 10,
42018
+ };
42019
+ var queryConfig = projectApiRef.current;
41949
42020
  if (!authUser || !client || !client.projects)
41950
42021
  return;
41951
42022
  if (!queryConfig.owner || !queryConfig.name)
41952
42023
  return;
41953
- // we've already loaded all recipes
41954
42024
  var _a = totalRecipesRef.current, total = _a.total, loaded = _a.loaded;
41955
42025
  if (total && loaded >= total)
41956
42026
  return;
42027
+ var fetchData = function () { return __awaiter$1(void 0, void 0, void 0, function () {
42028
+ var data;
42029
+ return __generator$1(this, function (_a) {
42030
+ switch (_a.label) {
42031
+ case 0: return [4 /*yield*/, client.projects.getProjectRecipes(queryConfig)];
42032
+ case 1:
42033
+ data = (_a.sent()).data;
42034
+ setRecipes(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
42035
+ setTotal(data.total_count);
42036
+ totalRecipesRef.current.loaded += data.resources.length;
42037
+ totalRecipesRef.current.total = data.total_count;
42038
+ return [2 /*return*/];
42039
+ }
42040
+ });
42041
+ }); };
42042
+ // call the function
41957
42043
  setLoading(true);
41958
- client.projects.getProjectRecipes(queryConfig)
41959
- .then(function (_a) {
41960
- var data = _a.data;
41961
- setRecipes(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
41962
- setTotal(data.total_count);
41963
- totalRecipesRef.current.loaded += data.resources.length;
41964
- totalRecipesRef.current.total = data.total_count;
41965
- })
41966
- .finally(function () {
41967
- setLoading(false);
41968
- });
41969
- }, [authUser, client]);
41970
- useEffect(function () {
41971
- fetchRecipes(queryConfig);
41972
- }, [fetchRecipes, queryConfig]);
41973
- useEffect(function () {
42044
+ fetchData()
42045
+ .catch(console.error)
42046
+ .finally(function () { return setLoading(false); });
42047
+ }, [authUser, client, projectOwner, projectName, pageNumber]);
42048
+ shortDebounce(function () {
41974
42049
  // nonmemoized value from react-hook-form or other parent causes infinite rerendering
41975
42050
  if (lodash_isequal(valueRef.current, selRecipe)) {
41976
42051
  return;
41977
42052
  }
41978
- if (selRecipe == null)
41979
- return;
42053
+ // if (selRecipe == null) return
41980
42054
  if (selRecipe && selRecipe.metadata && selRecipe.metadata.name) {
41981
42055
  comboBoxRef.current.setInputValue(selRecipe.metadata.name);
41982
42056
  }
41983
42057
  comboBoxRef.current.selectItem(selRecipe);
41984
42058
  valueRef.current = selRecipe;
41985
- onChange && selRecipe && onChange(selRecipe);
42059
+ onChange && onChange(selRecipe);
41986
42060
  }, [selRecipe, onChange]);
41987
- useEffect(function () {
41988
- setSelRecipe(value);
41989
- }, [value]);
41990
42061
  var onScrollReachEnd = useCallback(function () {
41991
42062
  var _a = totalRecipesRef.current, total = _a.total, loaded = _a.loaded;
41992
42063
  if (total && loaded >= total)
41993
42064
  return;
41994
- setQueryConfig(function (q) { return (__assign(__assign({}, q), { page: q.page ? q.page + 1 : 1 })); });
42065
+ setPageNumber(projectApiRef.current.page + 1);
41995
42066
  }, []);
41996
42067
  return (React__default.createElement(ComboBox, { ref: comboBoxRef, items: (_b = recipes === null || recipes === void 0 ? void 0 : recipes.map(function (r, i) { return (__assign(__assign({}, r), { name: "".concat(r.metadata.name, "-").concat(r.metadata.tag), id: "".concat(r.metadata.name, "-").concat(r.metadata.tag) })); })) !== null && _b !== void 0 ? _b : [], renderItem: function (item) { return (React__default.createElement("div", { style: {
41997
42068
  display: 'flex',
@@ -42000,7 +42071,7 @@ var SelectRecipe = function (_a) {
42000
42071
  }, id: "".concat(item.metadata.name, "-").concat(item.metadata.tag) },
42001
42072
  React__default.createElement(Avatar, { src: item.metadata.icon, alt: item.metadata.name, fallback: item.metadata.name, size: 24 }), "".concat(item.metadata.name, "-").concat(item.metadata.tag))); }, setSelected: setSelRecipe, inputProps: {
42002
42073
  placeholder: 'Select a recipe...',
42003
- }, loading: loading, disabled: !authUser || !queryConfig.name || !queryConfig.owner, footer: (React__default.createElement("div", { key: "footer", style: {
42074
+ }, loading: loading, disabled: !authUser || !projectName, footer: (React__default.createElement("div", { key: "footer", style: {
42004
42075
  width: '100%',
42005
42076
  display: 'flex',
42006
42077
  justifyContent: 'center',
@@ -44033,7 +44104,7 @@ var RecipeInputsForm = function (_a) {
44033
44104
  var _f = useForm({
44034
44105
  resolver: Oe(schema),
44035
44106
  mode: 'all',
44036
- }), control = _f.control, register = _f.register, handleSubmit = _f.handleSubmit, reset = _f.reset, resetField = _f.resetField, _g = _f.formState, errors = _g.errors, isValid = _g.isValid, isSubmitSuccessful = _g.isSubmitSuccessful;
44107
+ }), control = _f.control, register = _f.register, handleSubmit = _f.handleSubmit, reset = _f.reset, resetField = _f.resetField, formState = _f.formState, _g = _f.formState, errors = _g.errors, isValid = _g.isValid, isSubmitSuccessful = _g.isSubmitSuccessful;
44037
44108
  var _onSubmit = function (_data) {
44038
44109
  var data = __assign({}, _data);
44039
44110
  // strip study name
@@ -44055,19 +44126,22 @@ var RecipeInputsForm = function (_a) {
44055
44126
  setLoading(true);
44056
44127
  onSubmit(studyName, data, 'description', localConfig)
44057
44128
  .finally(function () {
44058
- // @ts-ignore
44059
- var defaults = recipe.inputs.map(function (input) {
44060
- var _a;
44061
- var _b;
44062
- return (_a = {}, _a[input.name] = (_b = input.default) !== null && _b !== void 0 ? _b : '', _a);
44063
- });
44064
- defaults.push({ 'study-name': '' });
44065
- // console.log(defaults)
44066
- reset();
44067
44129
  setLoading(false);
44068
44130
  });
44069
44131
  }
44070
44132
  };
44133
+ useEffect(function () {
44134
+ reset({
44135
+ 'study-name': ''
44136
+ }, { keepValues: false });
44137
+ }, [recipe]);
44138
+ useEffect(function () {
44139
+ if (formState.isSubmitSuccessful) {
44140
+ reset({
44141
+ 'study-name': ''
44142
+ }, { keepValues: false });
44143
+ }
44144
+ }, [formState, reset]);
44071
44145
  var groups = recipe.inputs.reduce(function (p, c) {
44072
44146
  if (c.required) {
44073
44147
  p[0].push(c);