-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3564 from nulib/deploy/staging
Deploy v9.0.2 to production
- Loading branch information
Showing
12 changed files
with
297 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
app/assets/js/components/Work/Tabs/Preservation/FilesetActionStatesModal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import * as Dialog from "@radix-ui/react-dialog"; | ||
|
||
import { | ||
DialogClose, | ||
DialogContent, | ||
DialogOverlay, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@js/components/UI/Dialog/Dialog.styled"; | ||
import { Icon, Tag } from "@nulib/design-system"; | ||
import React, { useEffect } from "react"; | ||
import { useLazyQuery, useQuery } from "@apollo/client"; | ||
|
||
import { ACTION_STATES } from "@js/components/Work/work.gql"; | ||
import UIDate from "@js/components/UI/Date"; | ||
|
||
const FilesetActionsStatesModal = ({ closeModal, id, isVisible }) => { | ||
const [getActionStates, { data, error, loading }] = | ||
useLazyQuery(ACTION_STATES); | ||
|
||
useEffect(() => { | ||
if (id) { | ||
getActionStates({ | ||
variables: { | ||
objectId: id, | ||
}, | ||
}); | ||
} | ||
}, [id]); | ||
|
||
if (loading) return <p>Loading ...</p>; | ||
if (error) return `Error! ${error}`; | ||
|
||
const columns = ["action", "outcome", "notes", "inserted at", "updated at"]; | ||
const getTagProps = (actionState) => { | ||
return { | ||
isSuccess: actionState.outcome === "OK", | ||
isDanger: actionState?.outcome === "ERROR", | ||
}; | ||
}; | ||
|
||
return ( | ||
<Dialog.Root open={isVisible} onOpenChange={closeModal}> | ||
<Dialog.Portal> | ||
<DialogOverlay /> | ||
<DialogContent data-testid="fileset-action-states"> | ||
<DialogClose> | ||
<Icon isSmall aria-label="Close"> | ||
<Icon.Close /> | ||
</Icon> | ||
</DialogClose> | ||
<DialogTitle css={{ textAlign: "left" }}> | ||
Fileset Action States | ||
</DialogTitle> | ||
{id && ( | ||
<> | ||
<p className="mt-3 mb-3">Fileset Id: {id}</p> | ||
<table className="table" data-testid="action-states"> | ||
<thead> | ||
<tr> | ||
{columns.map((column) => ( | ||
<th key={column} style={{ textTransform: "capitalize" }}> | ||
{column} | ||
</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{data && | ||
data.actionStates.map((actionState, idx) => ( | ||
<tr key={idx} data-testid="action-state-row"> | ||
<td>{actionState.action}</td> | ||
<td> | ||
<Tag {...getTagProps(actionState)}> | ||
{actionState.outcome} | ||
</Tag> | ||
</td> | ||
<td>{actionState.notes}</td> | ||
<td> | ||
<UIDate dateString={actionState.insertedAt} /> | ||
</td> | ||
<td> | ||
<UIDate dateString={actionState.updatedAt} /> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</> | ||
)} | ||
</DialogContent> | ||
</Dialog.Portal> | ||
</Dialog.Root> | ||
); | ||
}; | ||
|
||
export default FilesetActionsStatesModal; |
Oops, something went wrong.