-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Kedro-viz-890]/run-export-modal #898
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
dccf5f2
run-export-modal component
Huongg 1163132
pass state to RunExportModal
Huongg d0af3d5
move callback handle export to its own component
Huongg 905caa9
import RunExportModal in Details component
Huongg 8ee6f7c
remove console.log
Huongg f71d3aa
set fix width for primary button
Huongg 364d90f
update timing
Huongg 02fde8d
test for RunExportModal
Huongg 146916e
run-export-modal component
Huongg bbab40a
pass state to RunExportModal
Huongg cb69bd2
move callback handle export to its own component
Huongg 269731d
import RunExportModal in Details component
Huongg c6d733f
remove console.log
Huongg f968c68
set fix width for primary button
Huongg b12dc20
update timing
Huongg 78ced62
test for RunExportModal
Huongg 6339920
Merge branch 'kedro-viz-890/run-export-modal' of github.com:kedro-org…
Huongg b69ab00
update classname and label
Huongg c300702
create context for button timeout
Huongg 86bca44
use ButtonTimeoutContext in RunExportModal
Huongg 28e0ea8
use ButtonTimeoutContext in RunDetailsModal
Huongg f4a61d3
update test with mock test for Context
Huongg 25f73af
Merge branch 'main'
Huongg a525385
use visible props instead
Huongg e025dd0
change hasInteracted to hasNotInteracted
Huongg f9a8993
update test to reflect with new props
Huongg 4a0d649
sorting a-z
Huongg a4caf9e
update description for ButtonTimeoutContext
Huongg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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
3 changes: 3 additions & 0 deletions
3
src/components/experiment-tracking/run-export-modal.js/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 @@ | ||
import RunExportModal from './run-export-modal'; | ||
|
||
export default RunExportModal; |
76 changes: 76 additions & 0 deletions
76
src/components/experiment-tracking/run-export-modal.js/run-export-modal.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,76 @@ | ||
import React, { useState, useCallback, useContext, useEffect } from 'react'; | ||
import { CSVLink } from 'react-csv'; | ||
|
||
import { constructExportData } from '../../../utils/experiment-tracking-utils'; | ||
import { ButtonTimeoutContext } from '../../../utils/button-timeout-context'; | ||
|
||
import Button from '../../ui/button'; | ||
import Modal from '../../ui/modal'; | ||
|
||
import './run-export-modal.css'; | ||
|
||
const RunExportModal = ({ | ||
runMetadata, | ||
runTrackingData, | ||
setShowRunExportModal, | ||
theme, | ||
visible, | ||
}) => { | ||
const [exportData, setExportData] = useState([]); | ||
const { isSuccessful, showModal, handleClick } = | ||
useContext(ButtonTimeoutContext); | ||
|
||
const updateExportData = useCallback(() => { | ||
setExportData(constructExportData(runMetadata, runTrackingData)); | ||
}, [runMetadata, runTrackingData]); | ||
|
||
// only if the component is visible first, then apply isSuccessful to show or hide modal | ||
useEffect(() => { | ||
if (visible && isSuccessful) { | ||
setShowRunExportModal(showModal); | ||
} | ||
}, [showModal, setShowRunExportModal, isSuccessful, visible]); | ||
|
||
return ( | ||
<div className="pipeline-run-export-modal pipeline-run-export-modal--experiment-tracking"> | ||
<Modal | ||
closeModal={() => setShowRunExportModal(false)} | ||
theme={theme} | ||
title="Export experiment run" | ||
visible={visible} | ||
> | ||
<div className="run-export-modal-button-wrapper"> | ||
<Button | ||
mode="secondary" | ||
onClick={() => setShowRunExportModal(false)} | ||
size="small" | ||
> | ||
Cancel | ||
</Button> | ||
<CSVLink | ||
asyncOnClick={true} | ||
data={exportData} | ||
filename="run-data.csv" | ||
onClick={updateExportData} | ||
> | ||
<Button | ||
mode={isSuccessful ? 'success' : 'primary'} | ||
onClick={handleClick} | ||
size="small" | ||
> | ||
{isSuccessful ? ( | ||
<> | ||
Done <span className="success-check-mark">✅</span> | ||
</> | ||
) : ( | ||
'Export all and close' | ||
)} | ||
</Button> | ||
</CSVLink> | ||
</div> | ||
</Modal> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RunExportModal; |
16 changes: 16 additions & 0 deletions
16
src/components/experiment-tracking/run-export-modal.js/run-export-modal.scss
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,16 @@ | ||
.pipeline-run-export-modal--experiment-tracking .modal__title { | ||
text-align: left; | ||
margin-left: 30px; | ||
} | ||
|
||
.run-export-modal-button-wrapper { | ||
display: flex; | ||
justify-content: space-around; | ||
|
||
Huongg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
width: 100%; | ||
} | ||
|
||
// set fix width for export button for when the text is shorter, eg "Done" | ||
.pipeline-run-export-modal--experiment-tracking .button__btn--primary { | ||
width: 160px; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to leave
this function here locally in the component itself, rather than in the parent component
experiment-primary-toolbar
, orexperiment-wrapper
, as it's easier to manage local state, rather than passing it down through props