pollination-react-io 0.0.45-beta.3 → 0.0.45

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.
@@ -1,11 +1,9 @@
1
1
  import { Organization, UserPrivate } from '@pollination-solutions/pollination-sdk';
2
- import { CSSProperties } from 'react';
3
2
  import { APIClient } from '../hooks';
4
3
  export declare type Account = Organization | UserPrivate;
5
4
  export interface SelectAccountProps {
6
5
  authUser?: UserPrivate;
7
6
  client?: APIClient;
8
- style?: CSSProperties;
9
7
  setSelAccount?: (account: Account) => void;
10
8
  environment: Window;
11
9
  }
@@ -1,9 +1,9 @@
1
- import { Project, ProjectsApiListProjectsRequest, UserPrivate } from '@pollination-solutions/pollination-sdk';
1
+ import { Project, UserPrivate } from '@pollination-solutions/pollination-sdk';
2
2
  import { APIClient } from '../hooks';
3
3
  export interface SelectProjectProps {
4
4
  authUser?: UserPrivate;
5
5
  client?: APIClient;
6
+ projectOwner: string[];
6
7
  setSelProject?: (project: Project) => void;
7
- queryConfig?: Partial<ProjectsApiListProjectsRequest>;
8
8
  environment?: Window;
9
9
  }
@@ -1,9 +1,10 @@
1
1
  import { RecipeInterface, UserPrivate } from '@pollination-solutions/pollination-sdk';
2
2
  import { APIClient } from '../hooks';
3
3
  export interface SelectRecipeProps {
4
- projectName?: string;
5
4
  authUser?: UserPrivate;
6
5
  client?: APIClient;
6
+ projectName?: string;
7
+ projectOwner?: string;
7
8
  setSelRecipe?: (recipe: RecipeInterface) => void;
8
9
  environment?: Window;
9
10
  }
@@ -1,11 +1,11 @@
1
1
  import { Run, UserPrivate } from '@pollination-solutions/pollination-sdk';
2
2
  import { APIClient } from '../hooks';
3
3
  export interface SelectRunProps {
4
+ authUser?: UserPrivate;
5
+ client?: APIClient;
4
6
  projectOwner?: string;
5
7
  projectName?: string;
6
8
  jobId?: string[];
7
- authUser?: UserPrivate;
8
- client?: APIClient;
9
9
  setSelRun?: (recipe: Run) => void;
10
10
  environment?: Window;
11
11
  }
@@ -31062,7 +31062,7 @@ var ComboBox = React__default.forwardRef(function ComboBox(_a, ref) {
31062
31062
  React__default.createElement("ul", __assign$3({}, getMenuProps(), { style: __assign$3(__assign$3({}, menuStyle), { display: 'flex', width: '100%', boxSizing: 'border-box', zIndex: 100, padding: 0, flexDirection: 'column' }) }), inputItems.map(function (item, i, arr) { return (React__default.createElement("li", __assign$3({ className: "poll-combobox-item", style: highlightedIndex === i ? { backgroundColor: '#bde4ff' } : {}, key: "".concat(item.name, "-").concat(i) }, getItemProps({
31063
31063
  item: item,
31064
31064
  index: i,
31065
- isSelected: selectedItem && selectedItem.id === item.id,
31065
+ // isSelected: selectedItem && selectedItem.id === item.id,
31066
31066
  })), renderItem ? renderItem(item, i, arr) : item.name)); }))),
31067
31067
  React__default.createElement("div", { className: 'poll-combo-footer-container', style: {
31068
31068
  opacity: isOpen ? 1 : 0
@@ -34120,42 +34120,72 @@ var css_248z = ":root {\n --slate1: hsl(206, 30.0%, 98.8%);\n --slate2: hsl(21
34120
34120
  styleInject(css_248z);
34121
34121
 
34122
34122
  var SelectAccount = function (_a) {
34123
+ var _b;
34123
34124
  var authUser = _a.authUser, client = _a.client, setSelAccount = _a.setSelAccount, environment = _a.environment;
34124
- var _b = useState(), accounts = _b[0], setAccounts = _b[1];
34125
34125
  var comboBoxRef = useRef();
34126
- var _c = useState(false), loading = _c[0], setLoading = _c[1];
34127
- var fetchOrganizations = useCallback(function (member) {
34126
+ var _c = useState(function () { return authUser ? [authUser] : []; }), accounts = _c[0], setAccounts = _c[1];
34127
+ var _d = useState(false), loading = _d[0], setLoading = _d[1];
34128
+ var totalRunsRef = useRef({
34129
+ loaded: 0,
34130
+ total: undefined
34131
+ });
34132
+ var _e = useState(0), total = _e[0], setTotal = _e[1];
34133
+ var _f = useState({
34134
+ page: 1,
34135
+ perPage: 25,
34136
+ }), queryConfig = _f[0], setQueryConfig = _f[1];
34137
+ // resetting query
34138
+ useEffect(function () {
34139
+ // reset total loaded
34140
+ totalRunsRef.current = {
34141
+ loaded: 0,
34142
+ total: undefined
34143
+ };
34144
+ // deselect items
34145
+ if (comboBoxRef.current) {
34146
+ comboBoxRef.current.selectItem(null);
34147
+ }
34148
+ setAccounts(authUser ? [authUser] : []);
34149
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { member: authUser ? [authUser === null || authUser === void 0 ? void 0 : authUser.username] : undefined, page: 1 })); });
34150
+ }, [authUser]);
34151
+ var fetchOrganizations = useCallback(function (queryConfig) {
34128
34152
  if (!authUser)
34129
34153
  return;
34154
+ if (!queryConfig.member)
34155
+ return;
34156
+ // we've already loaded all Runs
34157
+ var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34158
+ if (total && loaded >= total)
34159
+ return;
34130
34160
  setLoading(true);
34131
- client.orgs.listOrgs({
34132
- member: member,
34133
- page: 1,
34134
- perPage: 25,
34135
- })
34161
+ client.orgs.listOrgs(__assign$3(__assign$3({}, queryConfig), { member: [authUser.username] }))
34136
34162
  .then(function (_a) {
34137
34163
  var data = _a.data;
34138
- setAccounts(data);
34164
+ setAccounts(function (state) { return state ? __spreadArray$2(__spreadArray$2([], state, true), data.resources, true) : __spreadArray$2([], data.resources, true); });
34165
+ setTotal(data.total_count);
34166
+ totalRunsRef.current.loaded += data.resources.length;
34167
+ totalRunsRef.current.total = data.total_count;
34139
34168
  })
34140
34169
  .finally(function () {
34141
34170
  setLoading(false);
34142
34171
  });
34143
34172
  }, [authUser, client.orgs]);
34144
- // initial fetch
34145
34173
  useEffect(function () {
34146
- if (!authUser)
34147
- return;
34148
- fetchOrganizations([authUser.username]);
34149
- }, [authUser, fetchOrganizations]);
34150
- useEffect(function () {
34151
- if (!authUser || !comboBoxRef.current)
34174
+ fetchOrganizations(queryConfig);
34175
+ }, [fetchOrganizations, queryConfig]);
34176
+ var onScrollReachEnd = useCallback(function () {
34177
+ // already loaded all runs
34178
+ var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34179
+ if (total && loaded >= total)
34152
34180
  return;
34153
- comboBoxRef.current.selectItem(authUser);
34154
- }, [authUser]);
34181
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { page: q.page ? q.page + 1 : 1 })); });
34182
+ }, []);
34155
34183
  return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment,
34156
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34157
34184
  // @ts-ignore
34158
- items: (accounts === null || accounts === void 0 ? void 0 : accounts.resources) ? __spreadArray$2([authUser], accounts.resources, true) : [], renderItem: function (item) {
34185
+ items: accounts ? accounts.map(function (a) {
34186
+ // @ts-ignore
34187
+ return a.name ? a : (__assign$3(__assign$3({}, a), { name: a.account_name }));
34188
+ }) : [], renderItem: function (item) {
34159
34189
  var _a;
34160
34190
  return (React__default.createElement("div", { style: {
34161
34191
  display: 'flex',
@@ -34164,134 +34194,207 @@ var SelectAccount = function (_a) {
34164
34194
  padding: '2px 0px'
34165
34195
  } },
34166
34196
  React__default.createElement(Avatar
34167
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34168
34197
  // @ts-ignore
34169
34198
  , {
34170
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34171
34199
  // @ts-ignore
34172
34200
  src: (_a = item.picture) !== null && _a !== void 0 ? _a : item.picture_url, alt: item.name, fallback: item.name, size: 24 }),
34173
34201
  item.name));
34174
34202
  }, setSelected: setSelAccount, inputProps: {
34175
34203
  placeholder: 'Select an account...',
34176
- }, loading: !client || loading, footer: (React__default.createElement("div", { key: "footer", style: {
34204
+ }, loading: loading, disabled: !authUser, footer: (React__default.createElement("div", { key: "footer", style: {
34177
34205
  width: '100%',
34178
34206
  display: 'flex',
34179
34207
  justifyContent: 'center',
34180
34208
  color: 'var(--slate10)',
34181
- } }, "".concat(accounts === null || accounts === void 0 ? void 0 : accounts.total_count, " accounts"))) }));
34209
+ } }, "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 }));
34182
34210
  };
34183
34211
 
34184
34212
  var SelectStudy = function (_a) {
34185
- var _b;
34186
- var projectName = _a.projectName, projectOwner = _a.projectOwner, authUser = _a.authUser, client = _a.client, setSelStudy = _a.setSelStudy, queryConfig = _a.queryConfig, environment = _a.environment;
34187
- var _c = useState(), studies = _c[0], setStudies = _c[1];
34213
+ var _b, _c;
34214
+ var authUser = _a.authUser, client = _a.client, projectName = _a.projectName, projectOwner = _a.projectOwner, setSelStudy = _a.setSelStudy, environment = _a.environment;
34188
34215
  var comboBoxRef = useRef();
34189
- var _d = useState(false), loading = _d[0], setLoading = _d[1];
34190
- var fetchStudies = useCallback(function (name, owner) {
34216
+ var _d = useState(), studies = _d[0], setStudies = _d[1];
34217
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
34218
+ var totalRunsRef = useRef({
34219
+ loaded: 0,
34220
+ total: undefined
34221
+ });
34222
+ var _f = useState(0), total = _f[0], setTotal = _f[1];
34223
+ var _g = useState({
34224
+ owner: projectOwner !== null && projectOwner !== void 0 ? projectOwner : (authUser && authUser.username),
34225
+ name: projectName,
34226
+ page: 1,
34227
+ perPage: 10,
34228
+ }), queryConfig = _g[0], setQueryConfig = _g[1];
34229
+ // resetting query
34230
+ useEffect(function () {
34231
+ // reset total loaded
34232
+ totalRunsRef.current = {
34233
+ loaded: 0,
34234
+ total: undefined
34235
+ };
34236
+ // deselect items
34237
+ if (comboBoxRef.current) {
34238
+ comboBoxRef.current.selectItem(null);
34239
+ }
34240
+ setStudies([]);
34241
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { owner: projectOwner, name: projectName, page: 1 })); });
34242
+ }, [projectOwner, projectName]);
34243
+ var fetchStudies = useCallback(function (queryConfig) {
34191
34244
  if (!authUser)
34192
34245
  return;
34246
+ if (!queryConfig.name || !queryConfig.owner)
34247
+ return;
34248
+ // we've already loaded all Runs
34249
+ var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34250
+ if (total && loaded >= total)
34251
+ return;
34193
34252
  setLoading(true);
34194
- client.jobs.listJobs(__assign$3({ name: name,
34195
- // @ts-ignore
34196
- owner: owner, page: 1, perPage: 25 }, queryConfig))
34253
+ client.jobs.listJobs(queryConfig)
34197
34254
  .then(function (_a) {
34198
34255
  var data = _a.data;
34199
- setStudies(data);
34256
+ setStudies(function (state) { return state ? __spreadArray$2(__spreadArray$2([], state, true), data.resources, true) : __spreadArray$2([], data.resources, true); });
34257
+ setTotal(data.total_count);
34258
+ totalRunsRef.current.loaded += data.resources.length;
34259
+ totalRunsRef.current.total = data.total_count;
34200
34260
  })
34201
34261
  .finally(function () {
34202
34262
  setLoading(false);
34203
34263
  });
34204
- }, [authUser, client.jobs, queryConfig]);
34264
+ }, [authUser, client.jobs]);
34205
34265
  useEffect(function () {
34206
- // recent selection on refetch
34207
- if (comboBoxRef.current) {
34208
- comboBoxRef.current.selectItem(null);
34209
- }
34210
- }, [queryConfig]);
34211
- // initial fetch
34212
- useEffect(function () {
34213
- if (!authUser || !projectName)
34266
+ fetchStudies(queryConfig);
34267
+ }, [fetchStudies, queryConfig]);
34268
+ var onScrollReachEnd = useCallback(function () {
34269
+ // already loaded all runs
34270
+ var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34271
+ if (total && loaded >= total)
34214
34272
  return;
34215
- var owner = projectOwner !== null && projectOwner !== void 0 ? projectOwner : authUser.username;
34216
- fetchStudies(projectName, owner);
34217
- }, [authUser, fetchStudies, projectName, projectOwner]);
34218
- return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment, items: (_b = studies === null || studies === void 0 ? void 0 : studies.resources.map(function (r) { var _a; return (__assign$3(__assign$3({}, r), { name: (_a = r.spec.name) !== null && _a !== void 0 ? _a : "".concat(r.recipe.metadata.name, " : ").concat(r.status.id.slice(0, 5), "...") })); })) !== null && _b !== void 0 ? _b : [], setSelected: setSelStudy, inputProps: {
34273
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { page: q.page ? q.page + 1 : 1 })); });
34274
+ }, []);
34275
+ return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment, items: (_b = studies === null || studies === void 0 ? void 0 : studies.map(function (r) { var _a; return (__assign$3(__assign$3({}, r), { name: (_a = r.spec.name) !== null && _a !== void 0 ? _a : "".concat(r.recipe.metadata.name, " : ").concat(r.status.id.slice(0, 5), "...") })); })) !== null && _b !== void 0 ? _b : [], setSelected: setSelStudy, inputProps: {
34219
34276
  placeholder: 'Select a study...',
34220
- }, loading: !client || loading, disabled: !client || !(queryConfig === null || queryConfig === void 0 ? void 0 : queryConfig.owner), footer: (React__default.createElement("div", { key: "footer", style: {
34277
+ }, loading: loading, disabled: !authUser || !queryConfig.name || !queryConfig.owner, footer: (React__default.createElement("div", { key: "footer", style: {
34221
34278
  width: '100%',
34222
34279
  display: 'flex',
34223
34280
  justifyContent: 'center',
34224
34281
  color: 'var(--grey4)',
34225
- } }, "".concat(studies === null || studies === void 0 ? void 0 : studies.total_count, " studies"))) }));
34282
+ } }, "Showing ".concat((_c = studies === null || studies === void 0 ? void 0 : studies.length) !== null && _c !== void 0 ? _c : 0, " of ").concat(total, " runs"))), onScrollReachEnd: onScrollReachEnd }));
34226
34283
  };
34227
34284
 
34228
34285
  var SelectProject = function (_a) {
34229
34286
  var _b;
34230
- var authUser = _a.authUser, client = _a.client, setSelProject = _a.setSelProject, queryConfig = _a.queryConfig, environment = _a.environment;
34231
- var _c = useState(), projects = _c[0], setProjects = _c[1];
34287
+ var authUser = _a.authUser, client = _a.client, projectOwner = _a.projectOwner, setSelProject = _a.setSelProject, environment = _a.environment;
34232
34288
  var comboBoxRef = useRef();
34289
+ var _c = useState(), projects = _c[0], setProjects = _c[1];
34233
34290
  var _d = useState(false), loading = _d[0], setLoading = _d[1];
34234
- var fetchProjects = useCallback(function (owner) {
34235
- if (!client)
34291
+ var totalRunsRef = useRef({
34292
+ loaded: 0,
34293
+ total: undefined
34294
+ });
34295
+ var _e = useState(0), total = _e[0], setTotal = _e[1];
34296
+ var _f = useState({
34297
+ owner: projectOwner !== null && projectOwner !== void 0 ? projectOwner : (authUser && [authUser.username]),
34298
+ page: 1,
34299
+ perPage: 10,
34300
+ }), queryConfig = _f[0], setQueryConfig = _f[1];
34301
+ // resetting query
34302
+ useEffect(function () {
34303
+ // reset total loaded
34304
+ totalRunsRef.current = {
34305
+ loaded: 0,
34306
+ total: undefined
34307
+ };
34308
+ // deselect items
34309
+ if (comboBoxRef.current) {
34310
+ comboBoxRef.current.selectItem(null);
34311
+ }
34312
+ setProjects([]);
34313
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { owner: projectOwner, page: 1 })); });
34314
+ }, [projectOwner]);
34315
+ var fetchProjects = useCallback(function (queryConfig) {
34316
+ if (!authUser)
34317
+ return;
34318
+ if (!queryConfig.owner)
34319
+ return;
34320
+ var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34321
+ if (total && loaded >= total)
34236
34322
  return;
34237
34323
  setLoading(true);
34238
- client.projects.listProjects(__assign$3({ owner: owner, page: 1, perPage: 25 }, queryConfig))
34324
+ client.projects.listProjects(queryConfig)
34239
34325
  .then(function (_a) {
34240
34326
  var data = _a.data;
34241
- setProjects(data);
34327
+ setProjects(function (state) { return state ? __spreadArray$2(__spreadArray$2([], state, true), data.resources, true) : __spreadArray$2([], data.resources, true); });
34328
+ setTotal(data.total_count);
34329
+ totalRunsRef.current.loaded += data.resources.length;
34330
+ totalRunsRef.current.total = data.total_count;
34242
34331
  })
34243
34332
  .finally(function () {
34244
34333
  setLoading(false);
34245
34334
  });
34246
- }, [client, queryConfig]);
34247
- useEffect(function () {
34248
- // recent selection on refetch
34249
- if (comboBoxRef.current) {
34250
- comboBoxRef.current.selectItem(null);
34251
- }
34252
- }, [queryConfig]);
34253
- // initial fetch
34335
+ }, [authUser, client.projects]);
34254
34336
  useEffect(function () {
34255
- if (!authUser)
34337
+ fetchProjects(queryConfig);
34338
+ }, [fetchProjects, queryConfig]);
34339
+ var onScrollReachEnd = useCallback(function () {
34340
+ // already loaded all runs
34341
+ var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34342
+ if (total && loaded >= total)
34256
34343
  return;
34257
- fetchProjects([authUser.username]);
34258
- }, [authUser, fetchProjects]);
34259
- return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment, items: (_b = projects === null || projects === void 0 ? void 0 : projects.resources) !== null && _b !== void 0 ? _b : [], setSelected: setSelProject, inputProps: {
34344
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { page: q.page ? q.page + 1 : 1 })); });
34345
+ }, []);
34346
+ return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment, items: projects !== null && projects !== void 0 ? projects : [], setSelected: setSelProject, inputProps: {
34260
34347
  placeholder: 'Select a project...',
34261
- }, loading: !client || loading, disabled: !client || !(queryConfig === null || queryConfig === void 0 ? void 0 : queryConfig.owner), footer: (React__default.createElement("div", { key: "footer", style: {
34348
+ }, loading: loading, disabled: !authUser || !queryConfig.owner, footer: (React__default.createElement("div", { key: "footer", style: {
34262
34349
  width: '100%',
34263
34350
  display: 'flex',
34264
34351
  justifyContent: 'center',
34265
34352
  color: 'var(--grey4)',
34266
- } }, "".concat(projects === null || projects === void 0 ? void 0 : projects.total_count, " projects"))) }));
34353
+ } }, "Showing ".concat((_b = projects === null || projects === void 0 ? void 0 : projects.length) !== null && _b !== void 0 ? _b : 0, " of ").concat(total, " projects"))), onScrollReachEnd: onScrollReachEnd }));
34267
34354
  };
34268
34355
 
34269
34356
  var SelectRecipe = function (_a) {
34270
34357
  var _b, _c;
34271
- var projectName = _a.projectName, authUser = _a.authUser, client = _a.client, setSelRecipe = _a.setSelRecipe, environment = _a.environment;
34358
+ var authUser = _a.authUser, client = _a.client, projectName = _a.projectName, projectOwner = _a.projectOwner, setSelRecipe = _a.setSelRecipe, environment = _a.environment;
34359
+ var comboBoxRef = useRef();
34272
34360
  var _d = useState(), recipes = _d[0], setRecipes = _d[1];
34361
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
34273
34362
  var totalRecipesRef = useRef({
34274
34363
  loaded: 0,
34275
34364
  total: undefined
34276
34365
  });
34277
- var _e = useState(0), total = _e[0], setTotal = _e[1];
34278
- var _f = useState(1), page = _f[0], setPage = _f[1];
34279
- var comboBoxRef = useRef();
34280
- var _g = useState(false), loading = _g[0], setLoading = _g[1];
34281
- var fetchRecipes = useCallback(function (name, owner) {
34282
- if (!client)
34366
+ var _f = useState(0), total = _f[0], setTotal = _f[1];
34367
+ var _g = useState({
34368
+ owner: projectOwner !== null && projectOwner !== void 0 ? projectOwner : (authUser && authUser.username),
34369
+ name: projectName,
34370
+ page: 1,
34371
+ perPage: 10,
34372
+ }), queryConfig = _g[0], setQueryConfig = _g[1];
34373
+ // resetting query
34374
+ useEffect(function () {
34375
+ // reset total loaded
34376
+ totalRecipesRef.current = {
34377
+ loaded: 0,
34378
+ total: undefined
34379
+ };
34380
+ // deselect items
34381
+ if (comboBoxRef.current) {
34382
+ comboBoxRef.current.selectItem(null);
34383
+ }
34384
+ setRecipes([]);
34385
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { owner: projectOwner, name: projectName, page: 1 })); });
34386
+ }, [projectOwner, projectName]);
34387
+ var fetchRecipes = useCallback(function (queryConfig) {
34388
+ if (!authUser)
34389
+ return;
34390
+ if (!queryConfig.owner || !queryConfig.name)
34283
34391
  return;
34284
34392
  // we've already loaded all recipes
34285
34393
  var _a = totalRecipesRef.current, total = _a.total, loaded = _a.loaded;
34286
34394
  if (total && loaded >= total)
34287
34395
  return;
34288
34396
  setLoading(true);
34289
- client.projects.getProjectRecipes({
34290
- name: name,
34291
- owner: owner,
34292
- page: page,
34293
- perPage: 10,
34294
- })
34397
+ client.projects.getProjectRecipes(queryConfig)
34295
34398
  .then(function (_a) {
34296
34399
  var data = _a.data;
34297
34400
  setRecipes(function (state) { return state ? __spreadArray$2(__spreadArray$2([], state, true), data.resources, true) : __spreadArray$2([], data.resources, true); });
@@ -34302,28 +34405,15 @@ var SelectRecipe = function (_a) {
34302
34405
  .finally(function () {
34303
34406
  setLoading(false);
34304
34407
  });
34305
- }, [client, page]);
34408
+ }, [authUser, client.projects]);
34306
34409
  useEffect(function () {
34307
- // recent selection on refetch
34308
- if (comboBoxRef.current) {
34309
- comboBoxRef.current.selectItem(null);
34310
- }
34311
- }, [projectName]);
34312
- // initial fetch
34313
- useEffect(function () {
34314
- if (!authUser || !projectName)
34315
- return;
34316
- fetchRecipes(projectName, authUser.username);
34317
- }, [authUser, fetchRecipes, projectName]);
34410
+ fetchRecipes(queryConfig);
34411
+ }, [fetchRecipes, queryConfig]);
34318
34412
  var onScrollReachEnd = useCallback(function () {
34319
- console.log(totalRecipesRef.current);
34320
34413
  var _a = totalRecipesRef.current, total = _a.total, loaded = _a.loaded;
34321
34414
  if (total && loaded >= total)
34322
34415
  return;
34323
- setPage(function (p) {
34324
- p++;
34325
- return p;
34326
- });
34416
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { page: q.page ? q.page + 1 : 1 })); });
34327
34417
  }, []);
34328
34418
  return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment, items: (_b = recipes === null || recipes === void 0 ? void 0 : recipes.map(function (r, i) { return (__assign$3(__assign$3({}, 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: {
34329
34419
  display: 'flex',
@@ -34332,7 +34422,7 @@ var SelectRecipe = function (_a) {
34332
34422
  }, id: "".concat(item.metadata.name, "-").concat(item.metadata.tag) },
34333
34423
  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: {
34334
34424
  placeholder: 'Select a recipe...',
34335
- }, loading: !client || loading, disabled: !client || !projectName, footer: (React__default.createElement("div", { key: "footer", style: {
34425
+ }, loading: loading, disabled: !authUser || !queryConfig.name || !queryConfig.owner, footer: (React__default.createElement("div", { key: "footer", style: {
34336
34426
  width: '100%',
34337
34427
  display: 'flex',
34338
34428
  justifyContent: 'center',
@@ -34343,31 +34433,47 @@ var SelectRecipe = function (_a) {
34343
34433
 
34344
34434
  var SelectRun = function (_a) {
34345
34435
  var _b, _c;
34346
- var projectOwner = _a.projectOwner, projectName = _a.projectName, jobId = _a.jobId, authUser = _a.authUser, client = _a.client, setSelRun = _a.setSelRun, environment = _a.environment;
34436
+ var authUser = _a.authUser, client = _a.client, projectOwner = _a.projectOwner, projectName = _a.projectName, jobId = _a.jobId, setSelRun = _a.setSelRun, environment = _a.environment;
34437
+ var comboBoxRef = useRef();
34347
34438
  var _d = useState(), runs = _d[0], setRuns = _d[1];
34439
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
34348
34440
  var totalRunsRef = useRef({
34349
34441
  loaded: 0,
34350
34442
  total: undefined
34351
34443
  });
34352
- var _e = useState(0), total = _e[0], setTotal = _e[1];
34353
- var _f = useState(1), page = _f[0], setPage = _f[1];
34354
- var comboBoxRef = useRef();
34355
- var _g = useState(false), loading = _g[0], setLoading = _g[1];
34356
- var fetchRuns = useCallback(function (name, owner, jobId) {
34357
- if (!client)
34444
+ var _f = useState(0), total = _f[0], setTotal = _f[1];
34445
+ var _g = useState({
34446
+ owner: projectOwner !== null && projectOwner !== void 0 ? projectOwner : (authUser && authUser.username),
34447
+ name: projectName,
34448
+ jobId: jobId,
34449
+ page: 1,
34450
+ perPage: 10,
34451
+ }), queryConfig = _g[0], setQueryConfig = _g[1];
34452
+ // resetting query
34453
+ useEffect(function () {
34454
+ // reset total loaded
34455
+ totalRunsRef.current = {
34456
+ loaded: 0,
34457
+ total: undefined
34458
+ };
34459
+ // deselect items
34460
+ if (comboBoxRef.current) {
34461
+ comboBoxRef.current.selectItem(null);
34462
+ }
34463
+ setRuns([]);
34464
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { jobId: jobId, owner: projectOwner, name: projectName, page: 1 })); });
34465
+ }, [jobId, projectOwner, projectName]);
34466
+ var fetchRuns = useCallback(function (queryConfig) {
34467
+ if (!authUser)
34468
+ return;
34469
+ if (!queryConfig.name || !queryConfig.owner || !queryConfig.jobId)
34358
34470
  return;
34359
34471
  // we've already loaded all Runs
34360
34472
  var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34361
34473
  if (total && loaded >= total)
34362
34474
  return;
34363
34475
  setLoading(true);
34364
- client.runs.listRuns({
34365
- name: name,
34366
- owner: owner,
34367
- jobId: jobId,
34368
- page: page,
34369
- perPage: 10,
34370
- })
34476
+ client.runs.listRuns(queryConfig)
34371
34477
  .then(function (_a) {
34372
34478
  var data = _a.data;
34373
34479
  setRuns(function (state) { return state ? __spreadArray$2(__spreadArray$2([], state, true), data.resources, true) : __spreadArray$2([], data.resources, true); });
@@ -34378,28 +34484,16 @@ var SelectRun = function (_a) {
34378
34484
  .finally(function () {
34379
34485
  setLoading(false);
34380
34486
  });
34381
- }, [client, page]);
34487
+ }, [authUser, client.runs]);
34382
34488
  useEffect(function () {
34383
- // recent selection on refetch
34384
- if (comboBoxRef.current) {
34385
- comboBoxRef.current.selectItem(null);
34386
- }
34387
- }, [projectName]);
34388
- // initial fetch
34389
- useEffect(function () {
34390
- if (!authUser || !projectName)
34391
- return;
34392
- var owner = projectOwner !== null && projectOwner !== void 0 ? projectOwner : authUser.username;
34393
- fetchRuns(projectName, owner, jobId);
34394
- }, [authUser, fetchRuns, jobId, projectName, projectOwner]);
34489
+ fetchRuns(queryConfig);
34490
+ }, [fetchRuns, queryConfig]);
34395
34491
  var onScrollReachEnd = useCallback(function () {
34492
+ // already loaded all runs
34396
34493
  var _a = totalRunsRef.current, total = _a.total, loaded = _a.loaded;
34397
34494
  if (total && loaded >= total)
34398
34495
  return;
34399
- setPage(function (p) {
34400
- p++;
34401
- return p;
34402
- });
34496
+ setQueryConfig(function (q) { return (__assign$3(__assign$3({}, q), { page: q.page ? q.page + 1 : 1 })); });
34403
34497
  }, []);
34404
34498
  return (React__default.createElement(ComboBox, { ref: comboBoxRef, environment: environment, items: (_b = runs === null || runs === void 0 ? void 0 : runs.map(function (r) { return (__assign$3(__assign$3({}, r), { name: "".concat(r.recipe.metadata.name, " : ").concat(r.status.status) })); })) !== null && _b !== void 0 ? _b : [], renderItem: function (item, i) { return (React__default.createElement("div", { style: {
34405
34499
  display: 'flex',
@@ -34420,13 +34514,13 @@ var SelectRun = function (_a) {
34420
34514
  justifyContent: 'flex-end'
34421
34515
  }, className: 'secondary' }, "".concat(i)))); }, setSelected: setSelRun, inputProps: {
34422
34516
  placeholder: 'Select a run...',
34423
- }, loading: !client || loading, disabled: !client || !projectName, footer: (React__default.createElement("div", { key: "footer", style: {
34517
+ }, loading: loading, disabled: !authUser || !queryConfig.name || !queryConfig.owner, footer: (React__default.createElement("div", { key: "footer", style: {
34424
34518
  width: '100%',
34425
34519
  display: 'flex',
34426
34520
  justifyContent: 'center',
34427
34521
  color: 'var(--grey4)',
34428
34522
  padding: '6px 0px',
34429
- } }, "Showing ".concat((_c = runs === null || runs === void 0 ? void 0 : runs.length) !== null && _c !== void 0 ? _c : 0, " of ").concat(total, " recipes"))), onScrollReachEnd: onScrollReachEnd }));
34523
+ } }, "Showing ".concat((_c = runs === null || runs === void 0 ? void 0 : runs.length) !== null && _c !== void 0 ? _c : 0, " of ").concat(total, " runs"))), onScrollReachEnd: onScrollReachEnd }));
34430
34524
  };
34431
34525
 
34432
34526
  var getAction$1 = function (key) {