Skip to content

[ERP-2110 & ERP-2111] Replaced all remaining Alert and Text Components #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/tool/guide/Config/AlertHelper.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Alert, AlertIcon, Box, CloseButton, Flex } from "@chakra-ui/react";

import React from "react";

export default function AlertHelper({
alertDismissible = true,
alertType = "info",
alertMsg = null,
onClose = {},
children = null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really a fan of having two different props to set the same thing, as you have to know internal details of the component in order to know which prop has precedent. Is there a reason to not use one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we can just make one props to support multiple types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}) {
return (
<>
Expand All @@ -13,9 +15,9 @@ export default function AlertHelper({
<Box w="100%">
<Alert display="flex" status={alertType}>
<AlertIcon />
{alertMsg && typeof alertMsg === "function"
? alertMsg()
: `${alertMsg}`}
{children && typeof children === "string"
? `${children}`
: React.isValidElement(children) && children}
{alertDismissible && (
<CloseButton
size="sm"
Expand Down
5 changes: 3 additions & 2 deletions src/components/tool/guide/Config/ConfigMultipleNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export default function ConfigMultipleNumbers({
<AlertHelper
alertDismissible={alertDismissible}
alertType={alertType}
alertMsg={alertMsg}
onClose={onClose}
/>
>
{alertMsg}
</AlertHelper>
)}
</>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/tool/guide/Config/ConfigPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ export default function ConfigPicker({
<AlertHelper
alertDismissible={alertDismissible}
alertType={alertType}
alertMsg={alertMsg}
onClose={onClose}
/>
>
{alertMsg}
</AlertHelper>
)}
</>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/tool/guide/Config/ConfigSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ export default function ConfigSlider({
<AlertHelper
alertDismissible={alertDismissible}
alertType={alertType}
alertMsg={alertMsg}
onClose={onClose}
/>
>
{alertMsg}
</AlertHelper>
)}
</>
);
Expand Down
54 changes: 24 additions & 30 deletions src/components/tool/guide/EresearchJob/EresearchJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,6 @@ const getConfigGroups = (config, onConfigChange = () => {}) => {
};
},
nodes: () => {
const mpiAlertMsg = () => {
return (
<TextWithLink
textBeforeLink={"Only use more than 1 node if you are using "}
link={{
href: "https://hpc-wiki.info/hpc/MPI",
text: "MPI",
isExternal: true,
}}
hasExternalIcon={true}
textAfterLink={"-type software."}
/>
);
};
return {
element: (key, selected) => (
<ConfigSlider
Expand All @@ -109,7 +95,18 @@ const getConfigGroups = (config, onConfigChange = () => {}) => {
}}
showAlert={config?.nodes > 1}
alertType="warning"
alertMsg={mpiAlertMsg}
alertMsg={
<TextWithLink
textBeforeLink={"Only use more than 1 node if you are using "}
link={{
href: "https://hpc-wiki.info/hpc/MPI",
text: "MPI",
isExternal: true,
}}
hasExternalIcon={true}
textAfterLink={"-type software."}
/>
}
/>
),
show: (config) =>
Expand Down Expand Up @@ -211,20 +208,6 @@ const getConfigGroups = (config, onConfigChange = () => {}) => {
["GPU", "Accelerated GPU"],
];
}
const customAlertMsg = () => {
return (
<TextWithLink
textBeforeLink={"IPUs are currently unavailable. Please "}
link={{
href: "https://eresearchqut.atlassian.net/servicedesk/customer/portals",
text: "contact eResearch if interested",
isExternal: true,
}}
hasExternalIcon={true}
textAfterLink={"."}
/>
);
};
return {
element: (key, selected) => (
<ConfigPicker
Expand All @@ -239,7 +222,18 @@ const getConfigGroups = (config, onConfigChange = () => {}) => {
}}
showAlert={config?.hardware === "IPU"}
alertType="warning"
alertMsg={customAlertMsg}
alertMsg={
<TextWithLink
textBeforeLink={"IPUs are currently unavailable. Please "}
link={{
href: "https://eresearchqut.atlassian.net/servicedesk/customer/portals",
text: "contact eResearch if interested",
isExternal: true,
}}
hasExternalIcon={true}
textAfterLink={"."}
/>
}
/>
),
show: (config) => config?.service,
Expand Down
8 changes: 4 additions & 4 deletions src/components/tool/guide/HuggingFacePipeline/Model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CloseIcon, ExternalLinkIcon } from "@chakra-ui/icons";
import {
Alert,
Box,
Button,
Flex,
Expand All @@ -26,6 +25,7 @@ import {
} from "@choc-ui/chakra-autocomplete";

import useData from "../../../hooks/useData";
import AlertHelper from "../Config/AlertHelper";

function ModelAutoComplete({ model, onModelChange, models }) {
return (
Expand Down Expand Up @@ -238,9 +238,9 @@ export function Model({ model, onModelChange, task }) {

if (modelsError) {
return (
<Alert status="error">
Error retrieving models: {modelsError.message}
</Alert>
<AlertHelper alertType={"error"} alertDismissible={false}>
{`Error retrieving models: ${modelsError.message}`}
</AlertHelper>
);
} else if (modelsLoading) {
return <Progress colorScheme="yellow" isIndeterminate />;
Expand Down
18 changes: 13 additions & 5 deletions src/components/tool/guide/Instructions/AccessInstructions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Code, Link } from "@chakra-ui/react";
import { Code } from "@chakra-ui/react";

import TextWithLink from "../../../navigation/TextWithLink";
import CopyBox from "../../../output/CopyBox";
import InstructionHeading from "./components/InstructionHeading";
import InstructionText from "./components/InstructionText";
Expand Down Expand Up @@ -37,10 +38,17 @@ export function AccessInstructions({ service, port, node, username }) {
)}
<InstructionHeading>Access the tool</InstructionHeading>
<InstructionText>
In your web browser, navigate to the following address:{" "}
<Link href={`http://localhost:${port}`} isExternal color="blue.500">
http://localhost:{port}
</Link>
<TextWithLink
textBeforeLink={
"In your web browser, navigate to the following address: "
}
link={{
href: `http://localhost:${port}`,
text: `http://localhost:${port}`,
color: "blue.500",
isExternal: true,
}}
/>
</InstructionText>
<CopyBox>http://localhost:{port}</CopyBox>
</>
Expand Down
Loading
Loading