Skip to content

Commit

Permalink
[UX feedback] Do not render page headers while loading on Overview & …
Browse files Browse the repository at this point in the history
…Sources pages
  • Loading branch information
cee-chen committed Jun 18, 2021
1 parent 6c305e5 commit 8bea24e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ describe('OrganizationSources', () => {

expect(wrapper.find(SourcesTable)).toHaveLength(1);
});

it('does not render a page header when data is loading (to prevent a jump after redirect)', () => {
setMockValues({ ...mockValues, dataLoading: true });
const wrapper = shallow(<OrganizationSources />);

expect(wrapper.prop('pageHeader')).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ export const OrganizationSources: React.FC = () => {
<WorkplaceSearchPageTemplate
pageChrome={[NAV.SOURCES]}
pageViewTelemetry="organization_sources"
pageHeader={{
pageTitle: ORG_SOURCES_HEADER_TITLE,
description: ORG_SOURCES_HEADER_DESCRIPTION,
rightSideItems: [
<EuiButtonTo
to={getSourcesPath(ADD_SOURCE_PATH, true)}
data-test-subj="AddSourceButton"
fill
>
{ORG_SOURCES_LINK}
</EuiButtonTo>,
],
}}
pageHeader={
dataLoading
? undefined
: {
pageTitle: ORG_SOURCES_HEADER_TITLE,
description: ORG_SOURCES_HEADER_DESCRIPTION,
rightSideItems: [
<EuiButtonTo
to={getSourcesPath(ADD_SOURCE_PATH, true)}
data-test-subj="AddSourceButton"
fill
>
{ORG_SOURCES_LINK}
</EuiButtonTo>,
],
}
}
isLoading={dataLoading}
isEmptyState={!contentSources.length}
emptyState={<Redirect to={getSourcesPath(ADD_SOURCE_PATH, true)} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ describe('Overview', () => {
expect(mockActions.initializeOverview).toHaveBeenCalled();
});

it('does not render a page header when data is loading (to prevent a jump between non/onboarding headers)', () => {
setMockValues({ dataLoading: true });
const wrapper = shallow(<Overview />);

expect(wrapper.prop('pageHeader')).toBeUndefined();
});

it('renders onboarding state', () => {
setMockValues({ dataLoading: false });
const wrapper = shallow(<Overview />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ export const Overview: React.FC = () => {

const hideOnboarding = hasUsers && hasOrgSources && isOldAccount && orgName !== defaultOrgName;

const headerTitle = dataLoading || hideOnboarding ? HEADER_TITLE : ONBOARDING_HEADER_TITLE;
const headerDescription =
dataLoading || hideOnboarding ? HEADER_DESCRIPTION : ONBOARDING_HEADER_DESCRIPTION;
const headerTitle = hideOnboarding ? HEADER_TITLE : ONBOARDING_HEADER_TITLE;
const headerDescription = hideOnboarding ? HEADER_DESCRIPTION : ONBOARDING_HEADER_DESCRIPTION;

return (
<WorkplaceSearchPageTemplate
pageChrome={[]}
pageHeader={{
pageTitle: headerTitle,
description: headerDescription,
}}
pageHeader={
dataLoading ? undefined : { pageTitle: headerTitle, description: headerDescription }
}
pageViewTelemetry="overview"
isLoading={dataLoading}
>
Expand Down

0 comments on commit 8bea24e

Please sign in to comment.