Skip to content

Commit

Permalink
refactor: General Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon committed Apr 26, 2024
1 parent 2955258 commit 797e874
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
21 changes: 11 additions & 10 deletions src/components/AddPipeline/AddPipeline.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { PluginInstance } from "@fnndsc/chrisapi";
import { Button, Modal, ModalVariant } from "@patternfly/react-core";
import { useMutation } from "@tanstack/react-query";
import { Alert } from "antd";
Expand All @@ -13,12 +14,9 @@ import {
import { getPluginInstanceStatusRequest } from "../../store/resources/actions";
import { SpinContainer } from "../Common";

import { fetchResource } from "../../api/common";
import Pipelines from "../PipelinesCopy";
import {
PipelineContext,
Types,
PipelineProvider,
} from "../PipelinesCopy/context";
import { PipelineContext, Types } from "../PipelinesCopy/context";

const AddPipeline = () => {
const { state, dispatch } = useContext(PipelineContext);
Expand Down Expand Up @@ -76,11 +74,14 @@ const AddPipeline = () => {
nodes_info: JSON.stringify(nodes_info),
});

// Use the pagination helper here
const pluginInstances = await workflow.getPluginInstances({
limit: 1000,
});
const instanceItems = pluginInstances.getItems();
const fn = workflow.getPluginInstances;
const boundFn = fn.bind(workflow);
const params = { limit: 100, offset: 0 };
const { resource: instanceItems } = await fetchResource<PluginInstance>(
params,
boundFn,
);

if (instanceItems && alreadyAvailableInstances) {
const firstInstance = instanceItems[instanceItems.length - 1];
const completeList = [...alreadyAvailableInstances, ...instanceItems];
Expand Down
13 changes: 6 additions & 7 deletions src/components/DeleteNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PluginInstance } from "@fnndsc/chrisapi";
import { Button, Modal, ModalVariant } from "@patternfly/react-core";
import { useMutation } from "@tanstack/react-query";
import { Alert } from "antd";
import { useEffect } from "react";
import { useEffect, Fragment } from "react";
import { useDispatch } from "react-redux";
import { fetchResource } from "../../api/common";
import { useTypedSelector } from "../../store/hooks";
Expand Down Expand Up @@ -33,10 +33,9 @@ const DeleteNode = () => {
const status = selectedPlugin.data.status;

if (!statuses.includes(status)) {
// Always cancel an active node first to avoid side effects
await selectedPlugin.put({
status: "cancelled",
});
throw new Error(
"Cannot delete actively running node at the moment...",
);
}

await selectedPlugin.delete();
Expand Down Expand Up @@ -91,7 +90,7 @@ const DeleteNode = () => {
isOpen={isModalOpen}
onClose={handleModalToggle}
actions={[
<>
<Fragment key="button-actions">
<Button
key="confirm"
variant="primary"
Expand All @@ -102,7 +101,7 @@ const DeleteNode = () => {
<Button key="cancel" variant="primary" onClick={handleModalToggle}>
Cancel
</Button>
</>,
</Fragment>,
]}
>
<span>
Expand Down

0 comments on commit 797e874

Please sign in to comment.