pollination-react-io 1.13.3 → 1.14.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.
@@ -6,6 +6,7 @@ declare type CloudFileMeta = FileMeta & {
6
6
  export interface SelectCloudArtifactsProps {
7
7
  projectOwner?: string;
8
8
  projectName?: string;
9
+ jobId?: string;
9
10
  fileNameMatch?: string;
10
11
  onChange?: (artifact: CloudFileMeta) => void;
11
12
  client?: APIClient;
@@ -2,7 +2,7 @@ import { FileMeta } from '@pollination-solutions/pollination-sdk';
2
2
  import { FileWithPath } from 'react-dropzone';
3
3
  import { APIClient } from './useAPIClient';
4
4
  export declare const useArtifacts: (owner: string, name: string, client: APIClient) => {
5
- listArtifacts: (path?: string[]) => Promise<FileMeta[]>;
5
+ listArtifacts: (path?: string[], jobId?: string) => Promise<FileMeta[]>;
6
6
  deleteArtifact: (path: string) => Promise<void>;
7
7
  downloadArtifact: (path: string) => Promise<any>;
8
8
  uploadArtifact: (folderRoot: FileMeta | undefined, file: FileWithPath) => Promise<import("@pollination-solutions/pollination-sdk").S3UploadRequest>;
@@ -21684,16 +21684,29 @@ function getHost(key, defaultValue) {
21684
21684
  }
21685
21685
 
21686
21686
  var useArtifacts = function (owner, name, client) {
21687
- var listArtifacts = useCallback(function (path) {
21687
+ var listArtifacts = useCallback(function (path, jobId) {
21688
21688
  if (!client || !client.artifacts)
21689
21689
  return new Promise(function (resolve) { return resolve([]); });
21690
- return client.artifacts.listArtifacts({
21691
- owner: owner,
21692
- name: name,
21693
- page: 1,
21694
- perPage: 50,
21695
- path: path
21696
- }).then(function (r) { return r.data; });
21690
+ // any string val except ''
21691
+ if (jobId) {
21692
+ return client.jobs.searchJobFolder({
21693
+ owner: owner,
21694
+ name: name,
21695
+ jobId: jobId,
21696
+ page: 1,
21697
+ perPage: 50,
21698
+ path: path
21699
+ }).then(function (r) { return r.data; });
21700
+ }
21701
+ else {
21702
+ return client.artifacts.listArtifacts({
21703
+ owner: owner,
21704
+ name: name,
21705
+ page: 1,
21706
+ perPage: 50,
21707
+ path: path
21708
+ }).then(function (r) { return r.data; });
21709
+ }
21697
21710
  }, [client, owner, name]);
21698
21711
  var downloadArtifact = useCallback(function (path) {
21699
21712
  if (!client)
@@ -39788,7 +39801,7 @@ var getFileIcon$1 = function (type, disabled) {
39788
39801
 
39789
39802
  var SelectCloudArtifacts = function (_a) {
39790
39803
  var _b, _c;
39791
- var projectOwner = _a.projectOwner, projectName = _a.projectName, _d = _a.fileNameMatch, fileNameMatch = _d === void 0 ? '.*' : _d, onChange = _a.onChange, client = _a.client;
39804
+ var projectOwner = _a.projectOwner, projectName = _a.projectName, jobId = _a.jobId, _d = _a.fileNameMatch, fileNameMatch = _d === void 0 ? '.*' : _d, onChange = _a.onChange, client = _a.client;
39792
39805
  var host = getHost();
39793
39806
  var listArtifacts = useArtifacts(projectOwner, projectName, client).listArtifacts;
39794
39807
  var _e = useState(false), loading = _e[0], setLoading = _e[1];
@@ -39797,14 +39810,14 @@ var SelectCloudArtifacts = function (_a) {
39797
39810
  var _h = useState(), selArtifact = _h[0], setSelArtifact = _h[1];
39798
39811
  useEffect(function () {
39799
39812
  setLoading(true);
39800
- listArtifacts(path)
39813
+ listArtifacts(path, jobId)
39801
39814
  .then(function (facts) {
39802
39815
  var folders = facts.filter(function (f) { return f.file_type === 'folder'; });
39803
39816
  var files = facts.filter(function (f) { return f.file_type === 'file'; });
39804
39817
  setArtifacts({ folders: folders, files: files });
39805
39818
  })
39806
39819
  .finally(function () { return setLoading(false); });
39807
- }, [client, fileNameMatch, host, listArtifacts, path]);
39820
+ }, [client, fileNameMatch, host, jobId, listArtifacts, path]);
39808
39821
  useEffect(function () {
39809
39822
  if (!selArtifact || selArtifact.file_type !== 'folder')
39810
39823
  return;
@@ -39836,7 +39849,7 @@ var SelectCloudArtifacts = function (_a) {
39836
39849
  var items = useMemo(function () {
39837
39850
  return __spreadArray(__spreadArray([], artifacts.folders, true), artifacts.files, true).map(function (a) {
39838
39851
  var match = a.file_name.match(fileMatchRegex);
39839
- var disabled = a.file_type === 'folder' || (match && match.length) > 1 ? false : true;
39852
+ var disabled = a.file_type === 'folder' || (match && match.length > 0) ? false : true;
39840
39853
  return (__assign(__assign({}, a), { name: a.file_name, id: a.key, disabled: disabled }));
39841
39854
  })
39842
39855
  .sort(function (a, b) { return a.file_type === 'folder' ? -1 : 1; });