Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions ui/src/__tests__/components/header/DomainDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,60 @@ describe('DomainDetails', () => {
expect(screen.getByText(organization)).toBeInTheDocument();
});

it('should hide cloud account details when showCloudAccountDetails is false', () => {
const domainMetadata = {
modified: '2020-02-12T21:44:37.792Z',
ypmId: 'test',
org: 'test',
auditEnabled: true,
account: 'aws-account-123',
gcpProject: 'gcp-project-456',
environment: 'qa',
};
const domainData = buildDomainDataForState(domainMetadata);
const state = {
...getStateWithDomainData(domainData),
domains: {
featureFlag: {
enabled: true,
showCloudAccountDetails: false,
},
},
};

renderWithRedux(<DomainDetails />, state);

expect(screen.queryByText('AWS ACCOUNT ID')).toBeNull();
expect(screen.queryByText('GCP PROJECT ID')).toBeNull();
expect(screen.queryByText('Onboard to AWS')).toBeNull();
});

it('should show cloud account details when showCloudAccountDetails is true', () => {
const domainMetadata = {
modified: '2020-02-12T21:44:37.792Z',
ypmId: 'test',
org: 'test',
auditEnabled: true,
account: 'aws-account-123',
environment: 'qa',
};
const domainData = buildDomainDataForState(domainMetadata);
const state = {
...getStateWithDomainData(domainData),
domains: {
featureFlag: {
enabled: true,
showCloudAccountDetails: true,
},
},
};

renderWithRedux(<DomainDetails />, state);

expect(screen.getByText('AWS ACCOUNT ID')).toBeInTheDocument();
expect(screen.getByText('GCP PROJECT ID')).toBeInTheDocument();
});

it('shows N/A when organization is empty and orgDomain is empty', () => {
const organization = '';
const orgDomain = '';
Expand Down
25 changes: 25 additions & 0 deletions ui/src/__tests__/redux/selectors/domains.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
selectShowInstances,
selectShowProviders,
selectShowMicrosegmentation,
selectShowCloudAccountDetails,
selectUserLink,
selectHeaderDetails,
selectProductMasterLink,
Expand Down Expand Up @@ -192,6 +193,30 @@ describe('test domains selectors', () => {
expect(selectShowMicrosegmentation(state)).toEqual(false);
});
});
describe('test selectShowCloudAccountDetails selector', () => {
it('should return true by default', () => {
expect(selectShowCloudAccountDetails(stateWithDomainsData)).toEqual(
true
);
});
it('should return false when explicitly disabled', () => {
const state = {
domains: {
featureFlag: {
enabled: true,
showCloudAccountDetails: false,
},
},
};
expect(selectShowCloudAccountDetails(state)).toEqual(false);
});
it('should return true when not set in object', () => {
const state = {
domains: { featureFlag: { enabled: true } },
};
expect(selectShowCloudAccountDetails(state)).toEqual(true);
});
});
describe('test selectUserLink selector', () => {
it('should return user link', () => {
const userLink = {
Expand Down
45 changes: 26 additions & 19 deletions ui/src/components/header/DomainDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
import {
selectProductMasterLink,
selectTimeZone,
selectShowCloudAccountDetails,
} from '../../redux/selectors/domains';
import { makeRolesExpires } from '../../redux/actions/roles';
import { makePoliciesExpires } from '../../redux/actions/policies';
Expand Down Expand Up @@ -548,22 +549,26 @@ class DomainDetails extends React.Component {
</ValueDiv>
<LabelDiv>AUDIT ENABLED</LabelDiv>
</SectionDiv>
<SectionDiv>
<ValueDiv>
{this.props.domainDetails.account
? this.props.domainDetails.account
: 'N/A'}
</ValueDiv>
<LabelDiv>AWS ACCOUNT ID</LabelDiv>
</SectionDiv>
<SectionDiv>
<ValueDiv>
{this.props.domainDetails.gcpProject
? this.props.domainDetails.gcpProject
: 'N/A'}
</ValueDiv>
<LabelDiv>GCP PROJECT ID</LabelDiv>
</SectionDiv>
{this.props.showCloudAccountDetails && (
<React.Fragment>
<SectionDiv>
<ValueDiv>
{this.props.domainDetails.account
? this.props.domainDetails.account
: 'N/A'}
</ValueDiv>
<LabelDiv>AWS ACCOUNT ID</LabelDiv>
</SectionDiv>
<SectionDiv>
<ValueDiv>
{this.props.domainDetails.gcpProject
? this.props.domainDetails.gcpProject
: 'N/A'}
</ValueDiv>
<LabelDiv>GCP PROJECT ID</LabelDiv>
</SectionDiv>
</React.Fragment>
)}
<ValueDiv>More Details</ValueDiv>
<IconContainer>
<Icon
Expand All @@ -579,7 +584,7 @@ class DomainDetails extends React.Component {
verticalAlign={'text-bottom'}
/>
</IconContainer>
{showOnBoardToAWS && (
{this.props.showCloudAccountDetails && showOnBoardToAWS ? (
<SectionDiv>
<Button
secondary
Expand All @@ -588,8 +593,9 @@ class DomainDetails extends React.Component {
Onboard to AWS
</Button>
</SectionDiv>
)}
{this.state.showOnBoardToAWSModal ? (
) : null}
{this.props.showCloudAccountDetails &&
this.state.showOnBoardToAWSModal ? (
<AddModal
isOpen={this.state.showOnBoardToAWSModal}
cancel={this.toggleOnboardToAWSModal}
Expand Down Expand Up @@ -729,6 +735,7 @@ const mapStateToProps = (state, props) => {
auditEnabled: selectDomainAuditEnabled(state),
timeZone: selectTimeZone(state),
userList: selectAllUsers(state),
showCloudAccountDetails: selectShowCloudAccountDetails(state),
};
};

Expand Down
1 change: 1 addition & 0 deletions ui/src/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const config = {
statusPath: process.env.UI_SESSION_SECRET_PATH || 'keys/cookie-session',
featureFlag: true,
showMicrosegmentation: true,
showCloudAccountDetails: true,
pageFeatureFlag: {
microsegmentation: {
policyValidation: true,
Expand Down
8 changes: 8 additions & 0 deletions ui/src/redux/selectors/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export const selectShowMicrosegmentation = (state) => {
if (ff && typeof ff === 'object') return ff.showMicrosegmentation !== false;
return true;
};

export const selectShowCloudAccountDetails = (state) => {
const ff = state.domains.featureFlag;
if (ff && typeof ff === 'object')
return ff.showCloudAccountDetails !== false;
return true;
};

export const selectAuthorityAttributes = (state) => {
return state.domains.authorityAttributes
? state.domains.authorityAttributes
Expand Down
4 changes: 4 additions & 0 deletions ui/src/server/handlers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,8 @@ Fetchr.registerService({
showInstances: appConfig.servicePageConfig?.showInstances !== false,
showProviders: appConfig.servicePageConfig?.showProviders !== false,
showMicrosegmentation: appConfig.showMicrosegmentation !== false,
showCloudAccountDetails:
appConfig.showCloudAccountDetails !== false,
});
},
});
Expand Down Expand Up @@ -3490,6 +3492,8 @@ module.exports.load = function (config, secrets) {
zmsLoginUrl: config.zmsLoginUrl,
timeZone: config.timeZone,
featureFlag: config.featureFlag,
showMicrosegmentation: config.showMicrosegmentation,
showCloudAccountDetails: config.showCloudAccountDetails,
pageFeatureFlag: config.pageFeatureFlag,
serviceHeaderLinks: config.serviceHeaderLinks,
templates: config.templates,
Expand Down
Loading