-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openShiftView,rhelView): issues/157 openshift route (#164)
* routerTypes, apply openshift view, update route detail filter * router, expand passed values to getRouteDetail * rhelView, apply translation for titles * openshiftView, translation, mirror rhelView, filter core values * graphCard, prop for cardTitle * i18n, locale, heading, title strings
- Loading branch information
Showing
15 changed files
with
272 additions
and
38 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
59 changes: 59 additions & 0 deletions
59
src/components/openshiftView/__tests__/__snapshots__/opensiftView.test.js.snap
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,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`OpenshiftView Component should have a fallback title: title 1`] = ` | ||
<Fragment> | ||
<PageHeader> | ||
<PageHeaderTitle | ||
title="Subscription Watch" | ||
/> | ||
</PageHeader> | ||
<PageSection> | ||
<Connect(GraphCard) | ||
cardTitle="t(curiosity-graph.coresHeading)" | ||
filterGraphData={ | ||
Array [ | ||
Object { | ||
"fill": "#8bc1f7", | ||
"id": "cores", | ||
"stroke": "#06c", | ||
}, | ||
Object { | ||
"id": "threshold", | ||
}, | ||
] | ||
} | ||
key="lorem ipsum" | ||
productId="lorem ipsum" | ||
/> | ||
</PageSection> | ||
</Fragment> | ||
`; | ||
|
||
exports[`OpenshiftView Component should render a non-connected component: non-connected 1`] = ` | ||
<Fragment> | ||
<PageHeader> | ||
<PageHeaderTitle | ||
title="Dolor sit" | ||
/> | ||
</PageHeader> | ||
<PageSection> | ||
<Connect(GraphCard) | ||
cardTitle="t(curiosity-graph.coresHeading)" | ||
filterGraphData={ | ||
Array [ | ||
Object { | ||
"fill": "#8bc1f7", | ||
"id": "cores", | ||
"stroke": "#06c", | ||
}, | ||
Object { | ||
"id": "threshold", | ||
}, | ||
] | ||
} | ||
key="lorem ipsum" | ||
productId="lorem ipsum" | ||
/> | ||
</PageSection> | ||
</Fragment> | ||
`; |
30 changes: 30 additions & 0 deletions
30
src/components/openshiftView/__tests__/opensiftView.test.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 { shallow } from 'enzyme'; | ||
import { OpenshiftView } from '../openshiftView'; | ||
|
||
describe('OpenshiftView Component', () => { | ||
it('should render a non-connected component', () => { | ||
const props = { | ||
routeDetail: { | ||
pathParameter: 'lorem ipsum', | ||
routeItem: { | ||
title: 'Dolor sit' | ||
} | ||
} | ||
}; | ||
|
||
const component = shallow(<OpenshiftView {...props} />); | ||
expect(component).toMatchSnapshot('non-connected'); | ||
}); | ||
|
||
it('should have a fallback title', () => { | ||
const props = { | ||
routeDetail: { | ||
pathParameter: 'lorem ipsum' | ||
} | ||
}; | ||
|
||
const component = shallow(<OpenshiftView {...props} />); | ||
expect(component).toMatchSnapshot('title'); | ||
}); | ||
}); |
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,63 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withTranslation } from 'react-i18next'; | ||
import { | ||
chart_color_blue_100 as chartColorBlueLight, | ||
chart_color_blue_300 as chartColorBlueDark | ||
} from '@patternfly/react-tokens'; | ||
import { PageHeader, PageHeaderTitle } from '@redhat-cloud-services/frontend-components'; | ||
import { PageSection } from '@patternfly/react-core'; | ||
import GraphCard from '../graphCard/graphCard'; | ||
import { helpers } from '../../common'; | ||
|
||
class OpenshiftView extends React.Component { | ||
componentDidMount() {} | ||
|
||
render() { | ||
const { routeDetail, t } = this.props; | ||
|
||
return ( | ||
<React.Fragment> | ||
<PageHeader> | ||
<PageHeaderTitle | ||
title={(routeDetail.routeItem && routeDetail.routeItem.title) || helpers.UI_DISPLAY_CONFIG_NAME} | ||
/> | ||
</PageHeader> | ||
<PageSection> | ||
<GraphCard | ||
key={routeDetail.pathParameter} | ||
filterGraphData={[ | ||
{ id: 'cores', fill: chartColorBlueLight.value, stroke: chartColorBlueDark.value }, | ||
{ id: 'threshold' } | ||
]} | ||
productId={routeDetail.pathParameter} | ||
cardTitle={t('curiosity-graph.coresHeading')} | ||
errorRoute={routeDetail.errorRoute} | ||
/> | ||
</PageSection> | ||
</React.Fragment> | ||
); | ||
} | ||
} | ||
|
||
OpenshiftView.propTypes = { | ||
routeDetail: PropTypes.shape({ | ||
pathParameter: PropTypes.string.isRequired, | ||
routeItem: PropTypes.shape({ | ||
title: PropTypes.string | ||
}), | ||
errorRoute: PropTypes.shape({ | ||
to: PropTypes.string | ||
}) | ||
}), | ||
t: PropTypes.func | ||
}; | ||
|
||
OpenshiftView.defaultProps = { | ||
routeDetail: {}, | ||
t: helpers.noopTranslate | ||
}; | ||
|
||
const TranslatedOpenshiftView = withTranslation()(OpenshiftView); | ||
|
||
export { TranslatedOpenshiftView as default, TranslatedOpenshiftView, OpenshiftView }; |
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.