Skip to content

Commit

Permalink
fix: Update the code for running pipelines:
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon committed Jun 6, 2024
1 parent ca04733 commit 6b2e48a
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 232 deletions.
87 changes: 45 additions & 42 deletions src/components/NewLibrary/Cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export const Status = ({ item }: { item: SelectionPayload }) => {
}

if (type === "folder") {
const currentStatus = folderDownloadStatus[payload.data.id];
const folderStatus = folderDownloadStatus?.[payload.data.id];
const currentStatus = folderStatus?.status;

return (
<>
{currentStatus === FolderDownloadTypes.finished ? (
{currentStatus && currentStatus === FolderDownloadTypes.finished ? (
<Button
variant="plain"
icon={<CheckCircleIcon color="#3E8635" width="2em" height="2em" />}
Expand Down Expand Up @@ -104,47 +105,49 @@ const Cart = () => {
}}
open={state.openCart}
>
<Grid hasGutter={true}>
<GridItem span={6}>
<Button
onClick={() => createFeed()}
style={{ marginRight: "0.5em" }}
size="sm"
variant="primary"
>
Create Feed
</Button>
<Button onClick={() => mutate()} size="sm" variant="primary">
Download
</Button>
</GridItem>
<div style={{ display: "flex", gap: "10px", alignItems: "center" }}>
<Button onClick={() => createFeed()} size="sm" variant="primary">
Create Feed
</Button>

<GridItem span={6}>
<Button
size="sm"
onClick={() => {
dispatch(clearCart());
// Clear out errors if any
handleDownloadMutation.reset();
resetErrors();
}}
style={{
marginRight: "0.5em",
}}
>
Clear All
</Button>
<Button
onClick={() => {
handleDeleteMutation.mutate();
}}
size="sm"
variant="danger"
>
Delete
</Button>
</GridItem>
</Grid>
<Button
onClick={() => mutate({ type: "download" })}
size="sm"
variant="primary"
>
Download
</Button>

<Button
onClick={() => mutate({ type: "anonymize" })}
size="sm"
variant="primary"
>
Anonymize
</Button>

<Button
size="sm"
onClick={() => {
dispatch(clearCart());
handleDownloadMutation.reset();
resetErrors();
}}
style={{
marginRight: "0.5em",
}}
>
Clear All
</Button>

<Button
onClick={() => handleDeleteMutation.mutate()}
size="sm"
variant="danger"
>
Delete
</Button>
</div>

<List
style={{ marginTop: "2rem" }}
Expand Down
2 changes: 2 additions & 0 deletions src/components/NewLibrary/context/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ export const downloadFileStatus = (
export const downloadFolderStatus = (
folder: FileBrowserFolder,
status: FolderDownloadTypes,
pipelineType: string,
) => {
return {
type: Types.SET_FOLDER_DOWNLOAD_STATUS,
payload: {
id: folder.data.id,
status,
pipelineType,
},
};
};
Expand Down
18 changes: 14 additions & 4 deletions src/components/NewLibrary/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export interface LibraryState {
[key: string]: DownloadTypes;
};
folderDownloadStatus: {
[key: string]: FolderDownloadTypes;
[key: string]: {
status: FolderDownloadTypes;
pipelineType: string;
};
};
}

Expand Down Expand Up @@ -82,7 +85,10 @@ export type LibraryPayload = {

[Types.SET_FOLDER_DOWNLOAD_FROM_COOKIES]: {
status: {
[key: string]: FolderDownloadTypes;
[key: string]: {
status: FolderDownloadTypes;
pipelineType: string;
};
};
};

Expand All @@ -102,6 +108,7 @@ export type LibraryPayload = {
[Types.SET_FOLDER_DOWNLOAD_STATUS]: {
id: number;
status: FolderDownloadTypes;
pipelineType: string;
};

[Types.CLEAR_DOWNLOAD_FILE_STATUS]: {
Expand Down Expand Up @@ -164,13 +171,16 @@ export const libraryReducer = (
}

case Types.SET_FOLDER_DOWNLOAD_STATUS: {
const { id, status } = action.payload;
const { id, status, pipelineType } = action.payload;

return {
...state,
folderDownloadStatus: {
...state.folderDownloadStatus,
[id]: status,
[id]: {
status,
pipelineType,
},
},
};
}
Expand Down
Loading

0 comments on commit 6b2e48a

Please sign in to comment.