diff --git a/frontend/src/app.css b/frontend/src/app.css index 266f5ebcd1..fe63346c64 100644 --- a/frontend/src/app.css +++ b/frontend/src/app.css @@ -1,3 +1,8 @@ + + +html { height: 100%; overflow:auto; } +body { height: 100%; } + :root { /* FONT SIZE */ --h1-size: 1.25rem; diff --git a/frontend/src/component/common/util.js b/frontend/src/component/common/util.js index 78f024d2e1..a9b699c494 100644 --- a/frontend/src/component/common/util.js +++ b/frontend/src/component/common/util.js @@ -15,6 +15,10 @@ const dateOptions = { year: 'numeric', }; +export const scrollToTop = () => { + window.scrollTo(0, 0); +}; + export const formatFullDateTimeWithLocale = (v, locale, tz) => { if (tz) { dateTimeOptions.timeZone = tz; diff --git a/frontend/src/component/feature/view/view-component.jsx b/frontend/src/component/feature/view/view-component.jsx index b29ae6745b..a58cf79a78 100644 --- a/frontend/src/component/feature/view/view-component.jsx +++ b/frontend/src/component/feature/view/view-component.jsx @@ -17,6 +17,8 @@ import FeatureTagComponent from '../feature-tag-component'; import StatusUpdateComponent from './status-update-component'; import AddTagDialog from '../add-tag-dialog-container'; +import { scrollToTop } from '../../common/util'; + const TABS = { strategies: 0, view: 1, @@ -31,6 +33,10 @@ export default class ViewFeatureToggleComponent extends React.Component { this.isFeatureView = !!props.fetchFeatureToggles; } + componentDidMount() { + scrollToTop(); + } + static propTypes = { activeTab: PropTypes.string.isRequired, featureToggleName: PropTypes.string.isRequired, diff --git a/frontend/src/component/layout/main.jsx b/frontend/src/component/layout/main.jsx index 61afcae50c..696c762d4f 100644 --- a/frontend/src/component/layout/main.jsx +++ b/frontend/src/component/layout/main.jsx @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; +import classnames from 'classnames'; import { Layout, Content, Footer, Grid, Cell } from 'react-mdl'; import styles from '../styles.module.scss'; @@ -17,8 +18,8 @@ export default class App extends PureComponent { return (
- - + + {this.props.children} diff --git a/frontend/src/component/reporting/__tests__/reporting-test.js b/frontend/src/component/reporting/__tests__/reporting-test.js index 677fefcf23..597b710818 100644 --- a/frontend/src/component/reporting/__tests__/reporting-test.js +++ b/frontend/src/component/reporting/__tests__/reporting-test.js @@ -1,5 +1,7 @@ import React from 'react'; import { Provider } from 'react-redux'; +import { HashRouter } from 'react-router-dom'; + import { createStore } from 'redux'; import { mount } from 'enzyme/build'; @@ -22,9 +24,11 @@ jest.mock('react-mdl', () => ({ test('changing projects renders only toggles from that project', () => { const wrapper = mount( - - {}} /> - + + + {}} /> + + ); const select = wrapper.find('.mdl-textfield__input').first(); diff --git a/frontend/src/component/reporting/report-toggle-list-item.jsx b/frontend/src/component/reporting/report-toggle-list-item.jsx index ac26157459..12ecf11069 100644 --- a/frontend/src/component/reporting/report-toggle-list-item.jsx +++ b/frontend/src/component/reporting/report-toggle-list-item.jsx @@ -1,6 +1,7 @@ import React from 'react'; import classnames from 'classnames'; import PropTypes from 'prop-types'; +import { useHistory } from 'react-router-dom'; import { Checkbox } from 'react-mdl'; import CheckIcon from '@material-ui/icons/Check'; @@ -14,6 +15,7 @@ import styles from './reporting.module.scss'; const ReportToggleListItem = ({ name, stale, lastSeenAt, createdAt, type, checked, bulkActionsOn, setFeatures }) => { const nameMatches = feature => feature.name === name; + const history = useHistory(); const handleChange = () => { setFeatures(prevState => { @@ -91,12 +93,16 @@ const ReportToggleListItem = ({ name, stale, lastSeenAt, createdAt, type, checke return renderStatus(, 'Active'); }; + const navigateToFeature = () => { + history.push(`/features/strategies/${name}`); + }; + const statusClasses = classnames(styles.active, { [styles.stale]: stale, }); return ( - +