-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add status filter and buttons to pause and export (#134)
* add status filter dropdown and action buttons to pause and export * update test snapshots * use entry.connection as index
- Loading branch information
Showing
36 changed files
with
2,683 additions
and
1,154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import FileSaver from 'file-saver'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import Button from '../Common/Button'; | ||
import Styles from './IconButton.styles.scss'; | ||
import IconDownload from '../../icons/IconDownload'; | ||
|
||
const ExportHarButton = ({ rawData }) => { | ||
const downloadHar = () => { | ||
const formattedHar = JSON.stringify(rawData, null, 4); | ||
|
||
FileSaver.saveAs(new Blob([formattedHar]), 'network.har'); | ||
}; | ||
|
||
return ( | ||
<Button | ||
className={Styles['icon-button']} | ||
onClick={downloadHar} | ||
> | ||
<IconDownload className={Styles['action-icon']} /> | ||
</Button> | ||
); | ||
}; | ||
|
||
ExportHarButton.propTypes = { | ||
rawData: PropTypes.string, | ||
}; | ||
|
||
ExportHarButton.defaultProps = { | ||
rawData: '', | ||
}; | ||
|
||
export default ExportHarButton; |
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,12 @@ | ||
@import "./../../styles/variables"; | ||
|
||
.icon-button { | ||
padding: $size-xs $size-xs-s; | ||
height: $filter-button-height; | ||
|
||
.action-icon { | ||
fill: $brand-primary-dark-gray; | ||
height: $size-s; | ||
width: $size-s; | ||
} | ||
} |
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,13 @@ | ||
import React from 'react'; | ||
|
||
import Button from '../Common/Button'; | ||
import Styles from './IconButton.styles.scss'; | ||
import IconUpload from '../../icons/IconImport'; | ||
|
||
const ImportHarButton = () => ( | ||
<Button className={Styles['icon-button']}> | ||
<IconUpload className={Styles['action-icon']} /> | ||
</Button> | ||
); | ||
|
||
export default ImportHarButton; |
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,35 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import Button from '../Common/Button'; | ||
import Styles from './IconButton.styles.scss'; | ||
import IconPause from '../../icons/IconPause'; | ||
import { useNetwork } from '../../state/network/Context'; | ||
import IconResume from '../../icons/IconResume'; | ||
|
||
const PauseResumeButton = () => { | ||
const { callbacks } = useNetwork(); | ||
const [isPaused, setIsPaused] = useState(false); | ||
|
||
const pause = () => { | ||
setIsPaused(true); | ||
callbacks.onPause(); | ||
}; | ||
|
||
const resume = () => { | ||
setIsPaused(false); | ||
callbacks.onResume(); | ||
}; | ||
|
||
return ( | ||
<Button | ||
className={Styles['icon-button']} | ||
onClick={isPaused ? resume : pause} | ||
> | ||
{isPaused ? | ||
<IconResume className={Styles['action-icon']} /> : | ||
<IconPause className={Styles['action-icon']} />} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default PauseResumeButton; |
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,27 @@ | ||
import React from 'react'; | ||
|
||
import Button from '../Common/Button'; | ||
import IconReset from '../../icons/IconReset'; | ||
import Styles from './IconButton.styles.scss'; | ||
import { useNetwork } from '../../state/network/Context'; | ||
|
||
const ResetButton = () => { | ||
const { actions, callbacks } = useNetwork(); | ||
|
||
const handleReset = () => { | ||
window.history.pushState({}, document.title, '/'); | ||
actions.resetState(); | ||
callbacks.onReset(); | ||
}; | ||
|
||
return ( | ||
<Button | ||
className={Styles['icon-button']} | ||
onClick={handleReset} | ||
> | ||
<IconReset className={Styles['action-icon']} /> | ||
</Button> | ||
); | ||
}; | ||
|
||
export default ResetButton; |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
import React from 'react'; | ||
|
||
import Dropdown from '../Common/Dropdown'; | ||
import { useNetwork } from '../../state/network/Context'; | ||
import { STATUS_FILTERS } from '../../constants'; | ||
|
||
const StatusFilter = () => { | ||
const { state, actions } = useNetwork(); | ||
const filter = state.get('statusFilter'); | ||
|
||
return ( | ||
<Dropdown | ||
items={STATUS_FILTERS} | ||
onChange={actions.updateStatusFilter} | ||
selected={filter} | ||
/> | ||
); | ||
}; | ||
|
||
export default StatusFilter; |
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 classNames from 'classnames/bind'; | ||
|
||
import { useNetwork } from '../../state/network/Context'; | ||
import Button from '../Common/Button'; | ||
import { TYPE_FILTERS } from '../../constants'; | ||
import Styles from '../../Containers/FilterContainer.styles.scss'; | ||
|
||
const context = classNames.bind(Styles); | ||
|
||
const TypeFilter = () => { | ||
const { state, actions } = useNetwork(); | ||
const filter = state.get('typeFilter'); | ||
|
||
return TYPE_FILTERS.map(({ name, filterBy }) => { | ||
const selectedFilter = filterBy.value === filter.value; | ||
|
||
return ( | ||
<Button | ||
key={name} | ||
className={context({ active: selectedFilter })} | ||
onClick={() => actions.updateTypeFilter(filterBy)} | ||
variant="text" | ||
> | ||
{name} | ||
</Button> | ||
); | ||
}); | ||
}; | ||
|
||
export default TypeFilter; |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.