Skip to content

Commit

Permalink
catch checked insufficient genes case in submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
vincerubinetti committed Dec 6, 2024
1 parent d2cf02e commit 4e85ec1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions frontend/src/pages/NewAnalysis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const genesetContextOptions: SelectOption<GenesetContext>[] = [
];

const geneMin = 5;
const geneMinMessage = `GenePlexus needs at least ${geneMin} genes to work properly`;
const geneMinMessage = `GenePlexus needs at least ${geneMin} valid genes to work properly`;

const NewAnalysisPage = () => {
/** raw text list of input gene ids */
Expand Down Expand Up @@ -233,12 +233,19 @@ const NewAnalysisPage = () => {
scrollTo("#enter-genes");
return;
}

if (splitGenes.length < geneMin) {
window.alert(geneMinMessage);
scrollTo("#enter-genes");
return;
}

if ((checkGenesData?.success || Infinity) < geneMin) {
window.alert(geneMinMessage);
scrollTo("#pre-check-genes");
return;
}

/** send inputs to load analysis page */
navigate("/analysis", {
state: {
Expand Down Expand Up @@ -490,6 +497,8 @@ const NewAnalysisPage = () => {
placeholder="Comma, tab, or line-separated list of entrez IDs, symbols, or ensembl gene/protein/transcript IDs"
tooltip="Genes to be used as negative training examples, in addition to those automatically selected by our algorithm."
/>

<span>{formatNumber(splitNegatives.length)} negative genes</span>
</Collapsible>
</Section>

Expand Down Expand Up @@ -518,7 +527,8 @@ const NewAnalysisPage = () => {

{checkGenesStatus === "loading" && (
<Alert type="loading">
Checking {formatNumber(splitGenes.length)} genes
Checking {formatNumber(splitGenes.length + splitNegatives.length)}{" "}
genes
</Alert>
)}
{checkGenesStatus === "error" && (
Expand Down Expand Up @@ -623,7 +633,13 @@ const NewAnalysisPage = () => {
<Button
text="Submit"
icon={<FaPaperPlane />}
style={{ opacity: splitGenes.length < geneMin ? 0.5 : 1 }}
style={{
opacity:
splitGenes.length < geneMin ||
(checkGenesData?.success || Infinity) < geneMin
? 0.5
: 1,
}}
onClick={submitAnalysis}
/>
</Section>
Expand Down

0 comments on commit 4e85ec1

Please sign in to comment.