Skip to content

Commit

Permalink
Pager feature in Spinnaker application navigation bar as an optional …
Browse files Browse the repository at this point in the history
…feature (#8715)

* chore(core): disable pager feature in nav by default

* Add unit test for pager button

* add(core): test for disable pager duty check

* chore(test): Add test for pagerduty feature enable
  • Loading branch information
KeisukeYamashita committed Nov 11, 2020
1 parent 3eba2c6 commit c6b23a7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IPipeline } from '../../domain';
import { ApplicationDataSource } from '../service/applicationDataSource';

import { ApplicationNavigation } from './ApplicationNavigation';
import { SETTINGS } from 'core/config';

describe('ApplicationNavigation', () => {
let $uiRouter: UIRouterReact;
Expand All @@ -36,7 +37,7 @@ describe('ApplicationNavigation', () => {
spyOn(StateMatcher.prototype, 'find').and.callFake(() => undefined as any);
});

it('should render header, categories, and pagerduty button', () => {
it('should render header, categories', () => {
const app = ApplicationModelBuilder.createApplicationForTests(
'testapp',
mockPipelineDataSourceConfig,
Expand Down Expand Up @@ -70,6 +71,23 @@ describe('ApplicationNavigation', () => {
const navSections = wrapper.find('NavSection');
expect(navSections.length).toEqual(3);

const pagerDutyButton = wrapper.find('.page-category');
expect(pagerDutyButton.length).toEqual(0);
});

it('should render pager button', () => {
SETTINGS.feature.pagerDuty = true;
const app = ApplicationModelBuilder.createApplicationForTests('testapp');
app.attributes.pdApiKey = 'fake-api-key';

const wrapper = mount(
<RecoilRoot>
<UIRouterContext.Provider value={$uiRouter}>
<ApplicationNavigation app={app} />
</UIRouterContext.Provider>
</RecoilRoot>,
);

const pagerDutyButton = wrapper.find('.page-category');
expect(pagerDutyButton.length).toEqual(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { useRecoilValue } from 'recoil';
import { useCurrentStateAndParams } from '@uirouter/react';
import { find, isEqual } from 'lodash';
import { SETTINGS } from 'core/config/settings';

import { AppRefresher } from './AppRefresher';
import { NavSection } from './NavSection';
Expand Down Expand Up @@ -73,22 +74,24 @@ export const ApplicationNavigation = ({ app }: IApplicationNavigationProps) => {
.map((section, i) => (
<NavSection key={`section-${i}`} dataSources={section} app={app} />
))}
<div className="nav-section clickable">
<div className="page-category flex-container-h middle text-semibold" onClick={pageApplicationOwner}>
<div className="nav-row-item sp-margin-s-right">
{!isExpanded ? (
<Tooltip value="Page App Owner" placement="right">
<div>
<Icon className="nav-item-icon" name="spMenuPager" size="medium" color="danger" />
</div>
</Tooltip>
) : (
<Icon className="nav-item-icon" name="spMenuPager" size="medium" color="danger" />
)}
{SETTINGS.feature.pagerDuty && app.attributes.pdApiKey && (
<div className="nav-section clickable">
<div className="page-category flex-container-h middle text-semibold" onClick={pageApplicationOwner}>
<div className="nav-row-item sp-margin-s-right">
{!isExpanded ? (
<Tooltip value="Page App Owner" placement="right">
<div>
<Icon className="nav-item-icon" name="spMenuPager" size="medium" color="danger" />
</div>
</Tooltip>
) : (
<Icon className="nav-item-icon" name="spMenuPager" size="medium" color="danger" />
)}
</div>
<span className="nav-name"> Page App Owner</span>
</div>
<span className="nav-name"> Page App Owner</span>
</div>
</div>
)}
</div>
);
};

0 comments on commit c6b23a7

Please sign in to comment.