-
Notifications
You must be signed in to change notification settings - Fork 1
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 #160 from khanlab/show-logs-no-react
Show logs in task tables
- Loading branch information
Showing
8 changed files
with
164 additions
and
88 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
autobidsportal/static/lib/autobids-react/src/TaskList/TaskList.js
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,30 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import TaskListItem from "./TaskListItem"; | ||
|
||
function TaskList(props) { | ||
const { children } = props; | ||
|
||
return ( | ||
<div className="table-responsive" style={{ maxHeight: "400px" }}> | ||
<table className="table table-light overflow-auto"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Start Date and Time</th> | ||
<th scope="col">End Date and Time</th> | ||
<th scope="col">Completion Status</th> | ||
<th scope="col"></th> | ||
</tr> | ||
</thead> | ||
<tbody>{children}</tbody> | ||
</table> | ||
</div> | ||
); | ||
} | ||
|
||
TaskList.propTypes = { | ||
children: PropTypes.arrayOf(PropTypes.instanceOf(TaskListItem)), | ||
}; | ||
|
||
export default TaskList; |
48 changes: 48 additions & 0 deletions
48
autobidsportal/static/lib/autobids-react/src/TaskList/TaskListItem.js
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,48 @@ | ||
import React, { useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import TaskLogModal from "./TaskLogModal"; | ||
|
||
function TaskListItem(props) { | ||
const { start, end, complete, log } = props; | ||
|
||
const [modalOpen, setModalOpen] = useState(false); | ||
|
||
const modalElement = document.getElementById("autobidsModal"); | ||
const openModal = () => setModalOpen(true); | ||
modalElement.addEventListener("hidden.bs.modal", (event) => | ||
setModalOpen(false) | ||
); | ||
|
||
return ( | ||
<> | ||
<tr> | ||
<td>{start}</td> | ||
<td>{end}</td> | ||
<td>{complete}</td> | ||
<td> | ||
<button | ||
className="btn btn-primary btn-sm" | ||
type="button" | ||
onClick={openModal} | ||
data-bs-toggle="modal" | ||
data-bs-target="#autobidsModal" | ||
disabled={!log} | ||
> | ||
View log | ||
</button> | ||
</td> | ||
</tr> | ||
{modalOpen ? <TaskLogModal log={log} /> : null} | ||
</> | ||
); | ||
} | ||
|
||
TaskListItem.propTypes = { | ||
start: PropTypes.string.isRequired, | ||
end: PropTypes.string.isRequired, | ||
complete: PropTypes.string.isRequired, | ||
log: PropTypes.string, | ||
}; | ||
|
||
export default TaskListItem; |
31 changes: 31 additions & 0 deletions
31
autobidsportal/static/lib/autobids-react/src/TaskList/TaskLogModal.js
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,31 @@ | ||
import React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import PropTypes from "prop-types"; | ||
|
||
function TaskLogModal(props) { | ||
const { log } = props; | ||
|
||
return ReactDOM.createPortal( | ||
<> | ||
<div className="modal-header"> | ||
<h5 className="modal-title">Task log</h5> | ||
<button | ||
type="button" | ||
className="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="close" | ||
></button> | ||
</div> | ||
<div className="modal-body"> | ||
<pre>{log}</pre> | ||
</div> | ||
</>, | ||
document.querySelector("#autobidsModalContent") | ||
); | ||
} | ||
|
||
TaskLogModal.propTypes = { | ||
log: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default TaskLogModal; |
3 changes: 3 additions & 0 deletions
3
autobidsportal/static/lib/autobids-react/src/TaskList/index.js
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,3 @@ | ||
export { default as TaskList } from "./TaskList"; | ||
export { default as TaskListItem } from "./TaskListItem"; | ||
export { default as TaskLogModal } from "./TaskLogModal"; |
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