Skip to content

Commit

Permalink
Merge pull request #1057 from PintoGideon/SingePlugin-bugfix
Browse files Browse the repository at this point in the history
Singe plugin bugfix
  • Loading branch information
PintoGideon authored Feb 9, 2024
2 parents 581004b + 945fb10 commit b457c65
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
15 changes: 7 additions & 8 deletions src/components/CreateFeed/SelectionAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ export const SelectionAlertWrap = ({
Creating analysis from {selectData.length}{" "}
{pluralize("item", selectData.length)} 
<ChipGroup numChips={2}>
{selectData &&
selectData.map((path: string) => {
return (
<Chip isReadOnly key={path}>
{path.split("/").reverse().shift()}
</Chip>
);
})}
{selectData?.map((path: string) => {
return (
<Chip isReadOnly key={path}>
{path.split("/").reverse().shift()}
</Chip>
);
})}
</ChipGroup>
</div>
);
Expand Down
10 changes: 4 additions & 6 deletions src/components/SinglePlugin/PluginCatalogComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Tabs,
TabTitleText,
Tab,
Spinner,
ClipboardCopy,
CodeBlock,
CodeBlockCode,
Expand All @@ -24,6 +23,7 @@ import {
ListItem,
DropdownList,
} from "@patternfly/react-core";
import { Alert } from "antd";
import { UserAltIcon, CheckCircleIcon } from "@patternfly/react-icons";
import { PluginMeta, Plugin, PluginInstance } from "@fnndsc/chrisapi";
import { useNavigate } from "react-router";
Expand Down Expand Up @@ -118,10 +118,8 @@ export const DropdownPluginVersions = ({
padding: "0",
}}
icon={
plugin.data.version === parameterPayload?.version ? (
plugin.data.version === parameterPayload?.version && (
<CheckCircleIcon style={{ color: "green" }} />
) : (
<span></span>
)
}
onKeyDown={(event) => {
Expand Down Expand Up @@ -150,7 +148,7 @@ export const DropdownPluginVersions = ({

const onFocus = () => {
const element = document.getElementById("toggle-basic");
element && element.focus();
element?.focus();
};

const onSelect = () => {
Expand Down Expand Up @@ -279,7 +277,7 @@ export const HeaderCardPlugin = ({
<div dangerouslySetInnerHTML={{ __html: readme }} />
) : (
<div style={{ margin: "auto" }}>
<Spinner diameter="80px" />
<Alert type="info" description="No github repo found." />
</div>
)}
</Tab>
Expand Down
12 changes: 6 additions & 6 deletions src/components/SinglePlugin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SinglePlugin = () => {
const repo = currentPluginMeta.data.public_repo.split("github.com/")[1];
const ghreadme = await fetch(`https://api.github.com/repos/${repo}/readme`);
if (!ghreadme.ok) {
throw new Error("Failed to fetch repo.");
return;
}
const { download_url, content }: { download_url: string; content: string } =
await ghreadme.json();
Expand Down Expand Up @@ -73,7 +73,7 @@ const SinglePlugin = () => {
const readme = await fetchReadme(pluginMeta);
return {
currentPluginMeta: pluginMeta,
plugins: results["resource"],
plugins: results.resource,
readme,
};
} catch (error: any) {
Expand Down Expand Up @@ -108,7 +108,7 @@ const SinglePlugin = () => {
: [];

if (parameters.length > 0) {
parameters.forEach((param) => {
for (const param of parameters) {
const generateInput = {
[param.data.id]: {
flag: param.data.flag,
Expand All @@ -123,7 +123,7 @@ const SinglePlugin = () => {
},
};
generatedCommand += unpackParametersIntoString(generateInput);
});
}

setParameterPayload({
generatedCommand,
Expand Down Expand Up @@ -154,10 +154,10 @@ const SinglePlugin = () => {
};

React.useEffect(() => {
if (data && data.plugins && data.plugins.length > 0) {
if (data?.plugins && data.plugins.length > 0) {
setPluginParameters(data.plugins[0]);
}
}, [data, setPluginParameters]);
}, [data?.plugins[0], setPluginParameters]);

return (
<WrapperConnect>
Expand Down

0 comments on commit b457c65

Please sign in to comment.