Skip to content

Commit

Permalink
feat(tourView,i18n): issues/133 empty state tour
Browse files Browse the repository at this point in the history
* tourView, apply empty state display, add translation
* i18n, tour view string replacements for en-us
* images & styling, tourView subscriptions svg
  • Loading branch information
cdcabrera committed Nov 19, 2019
1 parent edc6169 commit 8574c1c
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 16 deletions.
7 changes: 7 additions & 0 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
"rhelLegendHypervisorLabel": "Hypervisors",
"rhelLegendSocketsLabel": "Physical systems",
"rhelLegendThresholdLabel": "Subscription threshold"
},
"curiosity-tour": {
"emptyStateIconAlt": "{{appName}} logo",
"emptyStateTitle": "{{appName}} is an early access beta",
"emptyStateDescription": "{{appName}} helps you understand your total subscription usage and capacity over time. Take a quick tour to learn more.",
"emptyStateButton": "Take a tour",
"emptyStateLink": "Learn more"
}
}
10 changes: 5 additions & 5 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ msgstr \\"\\"
msgid \\"curiosity-graph.tooltipNoData\\"
msgstr \\"\\"
#: src/components/tourView/tourView.js:44
#: src/components/tourView/tourView.js:50
msgid \\"curiosity-tour.emptyStateButton\\"
msgstr \\"\\"
#: src/components/tourView/tourView.js:41
#: src/components/tourView/tourView.js:47
msgid \\"curiosity-tour.emptyStateDescription\\"
msgstr \\"\\"
#: src/components/tourView/tourView.js:31
#: src/components/tourView/tourView.js:37
msgid \\"curiosity-tour.emptyStateIconAlt\\"
msgstr \\"\\"
#: src/components/tourView/tourView.js:52
#: src/components/tourView/tourView.js:58
msgid \\"curiosity-tour.emptyStateLink\\"
msgstr \\"\\"
#: src/components/tourView/tourView.js:36
#: src/components/tourView/tourView.js:42
msgid \\"curiosity-tour.emptyStateTitle\\"
msgstr \\"\\"
Expand Down
130 changes: 126 additions & 4 deletions src/components/tourView/__tests__/__snapshots__/tourView.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,44 @@ exports[`TourView Component should have a fallback title: title 1`] = `
/>
</PageHeader>
<PageSection>
Subscription watch
helps you understand your total subscription usage and capacity over time.
<EmptyState
variant="full"
>
<img
alt={
Object {
"appName": "Subscription Watch",
}
}
aria-hidden={true}
className="curiosity-emptystate-img-icon"
src="subscriptions.svg"
/>
<Title
headingLevel="h5"
size="lg"
>
<Component />
</Title>
<EmptyStateBody>
<Component />
</EmptyStateBody>
<Component
variant="primary"
>
t('curiosity-tour.emptyStateButton')
</Component>
<EmptyStateSecondaryActions>
<Component
component="a"
href="https://access.redhat.com/products/subscription-central"
target="_blank"
variant="link"
>
t('curiosity-tour.emptyStateLink')
</Component>
</EmptyStateSecondaryActions>
</EmptyState>
</PageSection>
</Fragment>
`;
Expand All @@ -22,8 +58,94 @@ exports[`TourView Component should render a non-connected component: non-connect
/>
</PageHeader>
<PageSection>
Subscription watch
helps you understand your total subscription usage and capacity over time.
<EmptyState
variant="full"
>
<img
alt={
Object {
"appName": "Subscription Watch",
}
}
aria-hidden={true}
className="curiosity-emptystate-img-icon"
src="subscriptions.svg"
/>
<Title
headingLevel="h5"
size="lg"
>
<Component />
</Title>
<EmptyStateBody>
<Component />
</EmptyStateBody>
<Component
variant="primary"
>
t('curiosity-tour.emptyStateButton')
</Component>
<EmptyStateSecondaryActions>
<Component
component="a"
href="https://access.redhat.com/products/subscription-central"
target="_blank"
variant="link"
>
t('curiosity-tour.emptyStateLink')
</Component>
</EmptyStateSecondaryActions>
</EmptyState>
</PageSection>
</Fragment>
`;

exports[`TourView Component should render a translated component: translated 1`] = `
<Fragment>
<PageHeader>
<PageHeaderTitle
title="Lorem ipsum"
/>
</PageHeader>
<PageSection>
<EmptyState
variant="full"
>
<img
alt={
Object {
"appName": "Subscription Watch",
}
}
aria-hidden={true}
className="curiosity-emptystate-img-icon"
src="subscriptions.svg"
/>
<Title
headingLevel="h5"
size="lg"
>
<Component />
</Title>
<EmptyStateBody>
<Component />
</EmptyStateBody>
<Component
variant="primary"
>
t('curiosity-tour.emptyStateButton')
</Component>
<EmptyStateSecondaryActions>
<Component
component="a"
href="https://access.redhat.com/products/subscription-central"
target="_blank"
variant="link"
>
t('curiosity-tour.emptyStateLink')
</Component>
</EmptyStateSecondaryActions>
</EmptyState>
</PageSection>
</Fragment>
`;
15 changes: 14 additions & 1 deletion src/components/tourView/__tests__/tourView.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { TourView } from '../tourView';
import { TranslatedTourView, TourView } from '../tourView';

describe('TourView Component', () => {
it('should render a non-connected component', () => {
Expand All @@ -16,6 +16,19 @@ describe('TourView Component', () => {
expect(component).toMatchSnapshot('non-connected');
});

it('should render a translated component', () => {
const props = {
routeDetail: {
routeItem: {
title: 'Lorem ipsum'
}
}
};

const component = shallow(<TranslatedTourView {...props} />);
expect(component).toMatchSnapshot('translated');
});

it('should have a fallback title', () => {
const props = {};

Expand Down
62 changes: 56 additions & 6 deletions src/components/tourView/tourView.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,64 @@
import React from 'react';
import PropTypes from 'prop-types';
import { PageHeader, PageHeaderTitle } from '@redhat-cloud-services/frontend-components';
import { PageSection } from '@patternfly/react-core';
import {
Button,
EmptyState,
EmptyStateVariant,
EmptyStateBody,
EmptyStateSecondaryActions,
PageSection,
Title
} from '@patternfly/react-core';
import { helpers } from '../../common';
import { translateComponent } from '../i18n/i18n';
import subscriptionsSvg from '../../images/subscriptions.svg';

const TourView = ({ routeDetail }) => (
/**
* FixMe: Patternfly EmptyStateIcon can't pass a basic image
* Requires the use of function based component syntax
*/
/**
* FixMe: Patternfly EmptyStateBody and Title appear to throw an error on translate string replacement
* Wrap with a fragment to pass.
*/
const TourView = ({ routeDetail, t }) => (
<React.Fragment>
<PageHeader>
<PageHeaderTitle
title={(routeDetail.routeItem && routeDetail.routeItem.title) || helpers.UI_DISPLAY_START_NAME}
/>
</PageHeader>
<PageSection>
{helpers.UI_DISPLAY_START_NAME} helps you understand your total subscription usage and capacity over time.
<EmptyState variant={EmptyStateVariant.full}>
<img
src={subscriptionsSvg}
className="curiosity-emptystate-img-icon"
alt={t('curiosity-tour.emptyStateIconAlt', { appName: helpers.UI_DISPLAY_CONFIG_NAME })}
aria-hidden
/>
<Title headingLevel="h5" size="lg">
<React.Fragment>
{t('curiosity-tour.emptyStateTitle', { appName: helpers.UI_DISPLAY_CONFIG_NAME })}
</React.Fragment>
</Title>
<EmptyStateBody>
<React.Fragment>
{t('curiosity-tour.emptyStateDescription', { appName: helpers.UI_DISPLAY_START_NAME })}
</React.Fragment>
</EmptyStateBody>
<Button variant="primary">{t('curiosity-tour.emptyStateButton')}</Button>
<EmptyStateSecondaryActions>
<Button
component="a"
variant="link"
target="_blank"
href="https://access.redhat.com/products/subscription-central"
>
{t('curiosity-tour.emptyStateLink')}
</Button>
</EmptyStateSecondaryActions>
</EmptyState>
</PageSection>
</React.Fragment>
);
Expand All @@ -22,11 +68,15 @@ TourView.propTypes = {
routeItem: PropTypes.shape({
title: PropTypes.string
})
})
}),
t: PropTypes.func
};

TourView.defaultProps = {
routeDetail: {}
routeDetail: {},
t: helpers.noopTranslate
};

export { TourView as default, TourView };
const TranslatedTourView = translateComponent(TourView);

export { TranslatedTourView as default, TranslatedTourView, TourView };
36 changes: 36 additions & 0 deletions src/images/subscriptions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/styles/_tour.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.curiosity {
.curiosity-emptystate-img-icon {
height: 100px;
}
}
1 change: 1 addition & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import 'app';
@import 'common';
@import 'usage-graph';
@import 'tour';
1 change: 1 addition & 0 deletions tests/__snapshots__/dist.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ Array [
"./build/static/media/pfbg_768*jpg",
"./build/static/media/pfbg_768@2x*jpg",
"./build/static/media/pfbg_992@2x*jpg",
"./build/static/media/subscriptions*svg",
]
`;

0 comments on commit 8574c1c

Please sign in to comment.