Skip to content

Commit

Permalink
Add validation to file set form field, add DialogFooter UI component
Browse files Browse the repository at this point in the history
  • Loading branch information
bmquinn committed Jul 3, 2024
1 parent d0a1328 commit 0e0a011
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
10 changes: 10 additions & 0 deletions app/assets/js/components/UI/Dialog/Dialog.styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ const DialogTitle = styled(Dialog.Title, {
fontWeight: "700",
});

const DialogFooter = styled(Dialog.Footer, {
display: "flex",
justifyContent: "flex-end",
padding: "1rem",
borderTop: "1px solid #e5e7eb",
marginTop: "auto", // Pushes the footer to the bottom of the dialog
});


export {
DialogClose,
DialogContent,
DialogOverlay,
DialogTitle,
DialogTrigger,
DialogFooter
};
14 changes: 10 additions & 4 deletions app/assets/js/components/Work/Tabs/Preservation/FileSetModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Dialog from "@radix-ui/react-dialog";
import {
DialogClose,
DialogContent,
DialogFooter,
DialogOverlay,
DialogTitle
} from "@js/components/UI/Dialog/Dialog.styled";
Expand Down Expand Up @@ -224,7 +225,7 @@ function WorkTabsPreservationFileSetModal({
data-testid="fileset-form"
>
<div>
<section className="modal-card-body">
<section>
{uploadError && (
<Notification isDanger>{uploadError}</Notification>
)}
Expand Down Expand Up @@ -277,7 +278,7 @@ function WorkTabsPreservationFileSetModal({
)}
</section>

<footer className="modal-card-foot is-justify-content-flex-end">
<DialogFooter>
{s3UploadLocation && (
<>
<Button
Expand All @@ -288,12 +289,17 @@ function WorkTabsPreservationFileSetModal({
>
Cancel
</Button>
<Button isPrimary type="submit" data-testid="submit-button">
<Button
disabled={!s3UploadLocation}
isPrimary
type="submit"
data-testid="submit-button"
>
Ingest fileset
</Button>
</>
)}
</footer>
</DialogFooter>
</div>
</form>
</FormProvider>
Expand Down
16 changes: 10 additions & 6 deletions app/assets/js/components/Work/Tabs/Preservation/ReplaceFileSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Dialog from "@radix-ui/react-dialog";
import {
DialogClose,
DialogContent,
DialogFooter,
DialogOverlay,
DialogTitle
} from "@js/components/UI/Dialog/Dialog.styled";
Expand Down Expand Up @@ -269,25 +270,28 @@ function WorkTabsPreservationReplaceFileSet({
</UIFormField>
</section>

<footer className="modal-card-foot is-justify-content-flex-end">
<DialogFooter>
{s3UploadLocation && (
<>
<Button
isText
type="button"
onClick={() => {
handleCancel();
}}
onClick={handleCancel}
data-testid="cancel-button"
>
Cancel
</Button>
<Button isPrimary type="submit" data-testid="submit-button">
<Button
isPrimary
disabled={!s3UploadLocation}
type="submit"
data-testid="submit-button"
>
Upload File
</Button>
</>
)}
</footer>
</DialogFooter>
</div>
</form>
</FormProvider>
Expand Down

0 comments on commit 0e0a011

Please sign in to comment.