pollination-react-io 1.27.0 → 1.28.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,5 @@
1
+ import React from 'react';
2
+ import { FilePreviewProps } from './FilePreview.types';
3
+ import './FilePreview.scss';
4
+ declare const FilePreview: React.FC<FilePreviewProps>;
5
+ export default FilePreview;
@@ -0,0 +1,12 @@
1
+ import { FileMeta } from "@pollination-solutions/pollination-sdk";
2
+ import { HTMLProps } from "react";
3
+ import { APIClient } from "../hooks";
4
+ export interface FilePreviewProps {
5
+ projectOwner?: string;
6
+ projectName?: string;
7
+ jobId?: string;
8
+ value?: FileMeta;
9
+ client: APIClient;
10
+ inputProps?: HTMLProps<HTMLInputElement>;
11
+ onPreviewChange?: (...any: any) => void;
12
+ }
@@ -4,6 +4,7 @@ export interface SelectCloudArtifactsProps {
4
4
  projectOwner?: string;
5
5
  projectName?: string;
6
6
  jobId?: string;
7
+ runId?: string;
7
8
  value?: FileMeta;
8
9
  hidden?: boolean;
9
10
  fileNameMatch?: string;
@@ -2,8 +2,8 @@ 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[], jobId?: string) => Promise<FileMeta[]>;
5
+ listArtifacts: (path?: string[], jobId?: string, runId?: string) => Promise<FileMeta[]>;
6
6
  deleteArtifact: (path: string) => Promise<void>;
7
- downloadArtifact: (path: string) => Promise<any>;
7
+ downloadArtifact: (path: string, jobId?: string) => Promise<any>;
8
8
  uploadArtifact: (folderRoot: FileMeta | undefined, file: FileWithPath) => Promise<import("@pollination-solutions/pollination-sdk").S3UploadRequest>;
9
9
  };
@@ -37658,11 +37658,11 @@ var useAPIClient = function (config) {
37658
37658
  };
37659
37659
 
37660
37660
  var useArtifacts = function (owner, name, client) {
37661
- var listArtifacts = useCallback(function (path, jobId) {
37661
+ var listArtifacts = useCallback(function (path, jobId, runId) {
37662
37662
  if (!client || !client.artifacts)
37663
37663
  return new Promise(function (resolve) { return resolve([]); });
37664
37664
  // any string val except ''
37665
- if (jobId) {
37665
+ if (jobId && !runId) {
37666
37666
  return client.jobs.searchJobFolder({
37667
37667
  owner: owner,
37668
37668
  name: name,
@@ -37672,6 +37672,16 @@ var useArtifacts = function (owner, name, client) {
37672
37672
  path: path
37673
37673
  }).then(function (r) { return r.data; });
37674
37674
  }
37675
+ else if (!jobId && runId) {
37676
+ return client.runs.listRunArtifacts({
37677
+ owner: owner,
37678
+ name: name,
37679
+ runId: runId,
37680
+ page: 1,
37681
+ perPage: 50,
37682
+ path: path
37683
+ }).then(function (r) { return r.data; });
37684
+ }
37675
37685
  else {
37676
37686
  return client.artifacts.listArtifacts({
37677
37687
  owner: owner,
@@ -37682,14 +37692,24 @@ var useArtifacts = function (owner, name, client) {
37682
37692
  }).then(function (r) { return r.data; });
37683
37693
  }
37684
37694
  }, [client, owner, name]);
37685
- var downloadArtifact = useCallback(function (path) {
37695
+ var downloadArtifact = useCallback(function (path, jobId) {
37686
37696
  if (!client)
37687
37697
  return;
37688
- return client.artifacts.downloadArtifact({
37689
- owner: owner,
37690
- name: name,
37691
- path: path
37692
- }).then(function (r) { return r.data; });
37698
+ if (jobId) {
37699
+ return client.jobs.downloadJobArtifact({
37700
+ owner: owner,
37701
+ name: name,
37702
+ jobId: jobId,
37703
+ path: path
37704
+ }).then(function (r) { return r.data; });
37705
+ }
37706
+ else {
37707
+ return client.artifacts.downloadArtifact({
37708
+ owner: owner,
37709
+ name: name,
37710
+ path: path
37711
+ }).then(function (r) { return r.data; });
37712
+ }
37693
37713
  }, [client, owner, name]);
37694
37714
  var deleteArtifact = useCallback(function (path) { return __awaiter$1(void 0, void 0, void 0, function () {
37695
37715
  var key;
@@ -40582,6 +40602,7 @@ var getFileIcon$1 = function (type, disabled) {
40582
40602
  return React__default.createElement(Building$1, { size: size, style: { fill: disabled ? 'inherit' : '#F5B34C' } });
40583
40603
  case '3dm':
40584
40604
  case 'vtkjs':
40605
+ case 'vsf':
40585
40606
  case 'vtp':
40586
40607
  return React__default.createElement(Building$1, { size: size, style: { fill: disabled ? 'inherit' : '#F08C00' } });
40587
40608
  case 'jpg':
@@ -40609,7 +40630,7 @@ var longDebounce$3 = useDebounce(500);
40609
40630
  var shortDebounce$3 = useDebounce(200);
40610
40631
  var SelectCloudArtifacts = function (_a) {
40611
40632
  var _b, _c;
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;
40633
+ var projectOwner = _a.projectOwner, projectName = _a.projectName, jobId = _a.jobId, runId = _a.runId, value = _a.value, hidden = _a.hidden, _d = _a.fileNameMatch, fileNameMatch = _d === void 0 ? '.*' : _d, onChange = _a.onChange, client = _a.client;
40613
40634
  var comboBoxRef = useRef(null);
40614
40635
  var valueRef = useRef();
40615
40636
  var listArtifacts = useArtifacts(projectOwner, projectName, client).listArtifacts;
@@ -40635,14 +40656,14 @@ var SelectCloudArtifacts = function (_a) {
40635
40656
  if (!client || !client.projects)
40636
40657
  return;
40637
40658
  setLoading(true);
40638
- listArtifacts(path, jobId)
40659
+ listArtifacts(path, jobId, runId)
40639
40660
  .then(function (facts) {
40640
40661
  var folders = facts.filter(function (f) { return f.file_type === 'folder'; });
40641
40662
  var files = facts.filter(function (f) { return f.file_type === 'file'; });
40642
40663
  setArtifacts({ folders: folders, files: files });
40643
40664
  })
40644
40665
  .finally(function () { return setLoading(false); });
40645
- }, [jobId, listArtifacts, path]);
40666
+ }, [runId, jobId, listArtifacts, path]);
40646
40667
  useEffect(function () {
40647
40668
  if (!selArtifact || selArtifact.file_type !== 'folder')
40648
40669
  return;