Skip to content

Commit

Permalink
Updates from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Feb 9, 2021
1 parent da33132 commit dc62dc7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import { mount } from 'enzyme';
import React from 'react';
import { CallOut, CallOutMessage } from '.';
import { TestProviders } from '../../mock';
import { CallOut } from './callout';
import { CallOutMessage } from './callout_types';

describe('callout', () => {
let message: CallOutMessage = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import { mount } from 'enzyme';
import React from 'react';
import { NeedAdminForUpdateRulesCallOut } from './index';
import { TestProviders } from '../../../../common/mock';
import { NeedAdminForUpdateRulesCallOut } from '.';
import * as userInfo from '../../user_info';

describe('need_admin_for_update_callout', () => {
Expand All @@ -18,7 +18,7 @@ describe('need_admin_for_update_callout', () => {

describe('hasIndexManage is "null"', () => {
const hasIndexManage = null;
test('renders when "signalIndexMappingOutdated" is true', () => {
test('Does NOT render when "signalIndexMappingOutdated" is true', () => {
jest
.spyOn(userInfo, 'useUserData')
.mockImplementation(
Expand All @@ -30,7 +30,7 @@ describe('need_admin_for_update_callout', () => {
</TestProviders>
);
expect(wrapper.exists('[data-test-subj="callout-need-admin-for-update-rules"]')).toEqual(
true
false
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const needAdminForUpdateRulesMessage: CallOutMessage = {
* - Have the permissions to be able to read "signalIndexMappingOutdated" and that condition is "true"
* - Have the permissions to be able to read "hasIndexManage" and that condition is "false"
*
* Some users do not have sufficient privileges to be able to determine if "signalIndexMappingOutdated"
* is outdated or not. Same could apply to "hasIndexManage". When users do not have enough permissions
* to determine if "signalIndexMappingOutdated" is true or false, the permissions system returns a "null"
* instead.
*
* If the user has the permissions to see that signalIndexMappingOutdated is true and that
* hasIndexManage is also true, then the user should be performing the update on the page which is
* why we do not show it for that condition.
Expand All @@ -34,11 +39,11 @@ const NeedAdminForUpdateCallOutComponent = (): JSX.Element => {
const signalIndexMappingIsOutdated =
signalIndexMappingOutdated != null && signalIndexMappingOutdated;

const userHasIndexManage = hasIndexManage != null && hasIndexManage;
const userDoesntHaveIndexManage = hasIndexManage != null && !hasIndexManage;

return (
<CallOutPersistentSwitcher
condition={signalIndexMappingIsOutdated && !userHasIndexManage}
condition={signalIndexMappingIsOutdated && userDoesntHaveIndexManage}
message={needAdminForUpdateRulesMessage}
/>
);
Expand Down

0 comments on commit dc62dc7

Please sign in to comment.