Skip to content

Commit

Permalink
Merge pull request #1077 from PintoGideon/Archive-Feed-Fix
Browse files Browse the repository at this point in the history
Archive feed fix
  • Loading branch information
PintoGideon authored Feb 27, 2024
2 parents 08c8481 + d94b120 commit e9af288
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 199 deletions.
97 changes: 41 additions & 56 deletions src/components/CreateFeed/createFeedHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ export const createFeedInstanceWithDircopy = async (
state: PipelineState,
) => {
const { chrisFiles, localFiles } = data;

let dirpath: string[] = [];
let feed: Feed;
const dirpath: string[] = [];

if (selectedConfig.includes("swift_storage")) {
dirpath = chrisFiles.map((path: string) => path);
dirpath.push(...chrisFiles);
}

if (selectedConfig.includes("local_select")) {
Expand All @@ -92,70 +90,57 @@ export const createFeedInstanceWithDircopy = async (
try {
await uploadLocalFiles(localFiles, path, setUploadFileCallback);
} catch (error) {
const errObj = catchError(error);
errorCallback(errObj);
errorCallback(catchError(error));
return null;
}
}

try {
const client = ChrisAPIClient.getClient();
const dircopy = await getPlugin("pl-dircopy");

if (dircopy instanceof Plugin) {
try {
const createdInstance = await client.createPluginInstance(
dircopy.data.id,
{
//@ts-ignore
dir: dirpath.join(","),
},
);
const { pipelineToAdd, computeInfo, titleInfo, selectedPipeline } =
state;

const id = pipelineToAdd?.data.id;
const resources = selectedPipeline?.[id];
if (createdInstance) {
if (resources) {
const { parameters } = resources;

const nodes_info = client.computeWorkflowNodesInfo(parameters.data);

for (const node of nodes_info) {
// Set compute info
const activeNode = computeInfo?.[id][node.piping_id];
// Set Title
const titleSet = titleInfo?.[id][node.piping_id];

if (activeNode) {
const compute_node = activeNode.currentlySelected;
node.compute_resource_name = compute_node;
}

if (titleSet) {
node.title = titleSet;
}
}

await client.createWorkflow(id, {
previous_plugin_inst_id: createdInstance.data.id,
nodes_info: JSON.stringify(nodes_info),
});
}
if (!(dircopy instanceof Plugin)) {
return null;
}

const createdInstance = await client.createPluginInstance(dircopy.data.id, {
//@ts-ignore
dir: dirpath.join(","),
});

const { pipelineToAdd, computeInfo, titleInfo, selectedPipeline } = state;
const id = pipelineToAdd?.data.id;
const resources = selectedPipeline?.[id];

if (createdInstance && resources) {
const { parameters } = resources;
const nodes_info = client.computeWorkflowNodesInfo(parameters.data);

feed = (await createdInstance.getFeed()) as Feed;
return feed;
for (const node of nodes_info) {
const activeNode = computeInfo?.[id][node.piping_id];
const titleSet = titleInfo?.[id][node.piping_id];

if (activeNode) {
node.compute_resource_name = activeNode.currentlySelected;
}

if (titleSet) {
node.title = titleSet;
}
} catch (error) {
console.log("Error", error);
}
return null;

//when the `post` finishes, the dircopyInstances's internal collection is updated
await client.createWorkflow(id, {
previous_plugin_inst_id: createdInstance.data.id,
nodes_info: JSON.stringify(nodes_info),
});

return (await createdInstance.getFeed()) as Feed;
}

return null;
} catch (error) {
const errorObj = catchError(error);
errorCallback(errorObj);
errorCallback(catchError(error));
return null;
}
};

Expand All @@ -165,7 +150,7 @@ export const createFeedInstanceWithFS = async (
selectedPlugin: Plugin | undefined,
errorCallback: (error: any) => void,
) => {
let feed;
let feed: Feed | null = null;
if (selectedPlugin) {
if (selectedPlugin instanceof Plugin) {
const data = await getRequiredObject(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Feeds/FeedListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const TableSelectable: React.FunctionComponent = () => {
search={search}
/>

{feedsToDisplay && <IconContainer allFeeds={feedsToDisplay} />}
{feedsToDisplay && <IconContainer />}
</div>
{isLoading ||
isFetching ||
Expand Down
Loading

0 comments on commit e9af288

Please sign in to comment.