Skip to content

Commit

Permalink
fix: secondary input
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloster committed Oct 22, 2024
1 parent 8814c76 commit 7e72c17
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
51 changes: 33 additions & 18 deletions client/src/components/AnnoDialog/AnnoDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import { Button, Dialog, Classes, Tooltip } from "@blueprintjs/core";
import { AnnoDialogProps } from "./types";
import { DialogBody, DialogForm, ErrorText, SecondaryText } from "./style";

export function AnnoDialog(props: AnnoDialogProps): JSX.Element {
const {
isActive,
text,
title,
instruction,
cancelTooltipContent,
errorMessage,
validationError,
annoInput,
secondaryInstructions,
secondaryInput,
handleCancel,
handleSubmit,
primaryButtonText,
primaryButtonProps,
inputProps,
} = props;
function AnnoDialog({
isActive,
text,
title,
instruction,
cancelTooltipContent,
errorMessage,
validationError,
annoInput,
secondaryInstructions,
secondaryInput,
handleCancel,
handleSubmit,
primaryButtonText,
secondaryButtonText,
handleSecondaryButtonSubmit,
primaryButtonProps,
inputProps,
}: AnnoDialogProps): JSX.Element {
return (
<Dialog icon="tag" title={title} isOpen={isActive} onClose={handleCancel}>
<DialogForm
Expand All @@ -34,6 +35,7 @@ export function AnnoDialog(props: AnnoDialogProps): JSX.Element {
<ErrorText validationError={validationError}>
{errorMessage}
</ErrorText>
{/* we might rename, secondary button and secondary input are not related */}
{secondaryInstructions && (
<SecondaryText secondaryInstructions={secondaryInstructions}>
{secondaryInstructions}
Expand All @@ -46,6 +48,17 @@ export function AnnoDialog(props: AnnoDialogProps): JSX.Element {
<Tooltip content={cancelTooltipContent}>
<Button onClick={handleCancel}>Cancel</Button>
</Tooltip>
{/* we might rename, secondary button and secondary input are not related */}
{handleSecondaryButtonSubmit && secondaryButtonText ? (
<Button
onClick={handleSecondaryButtonSubmit}
disabled={!text || validationError}
intent="none"
type="button"
>
{secondaryButtonText}
</Button>
) : null}
<Button
{...primaryButtonProps}
{...inputProps}
Expand All @@ -62,3 +75,5 @@ export function AnnoDialog(props: AnnoDialogProps): JSX.Element {
</Dialog>
);
}

export default AnnoDialog;
2 changes: 2 additions & 0 deletions client/src/components/AnnoDialog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface AnnoDialogProps {
handleCancel: (e: SyntheticEvent<HTMLElement, Event>) => void;
handleSubmit: (e: MouseEvent<HTMLElement>) => void;
primaryButtonText: string;
secondaryButtonText?: string;
handleSecondaryButtonSubmit?: () => void;
primaryButtonProps: Record<string, unknown>;
inputProps: Record<string, unknown>;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { connect } from "react-redux";
import { AnnoDialog } from "components/AnnoDialog/AnnoDialog";
import AnnoDialog from "components/AnnoDialog/AnnoDialog";
import { LabelInput } from "components/LabelInput/LabelInput";

// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { connect } from "react-redux";
import { AnnoDialog } from "components/AnnoDialog/AnnoDialog";
import AnnoDialog from "components/AnnoDialog/AnnoDialog";
import { LabelInput } from "components/LabelInput/LabelInput";
import parseBulkGeneString from "util/parseBulkGeneString";
import actions from "actions";
Expand Down

0 comments on commit 7e72c17

Please sign in to comment.