*/
import * as React from 'react';
import HelpTooltip from '../../../components/controls/HelpTooltip';
-import { withCurrentUser } from '../../../components/hoc/withCurrentUser';
import { Alert } from '../../../components/ui/Alert';
import { translate } from '../../../helpers/l10n';
-import { hasGlobalPermission } from '../../../helpers/users';
-import { Permissions } from '../../../types/permissions';
import Conditions from './Conditions';
import Projects from './Projects';
import QualityGatePermissions from './QualityGatePermissions';
export interface DetailsContentProps {
- currentUser: T.CurrentUser;
isDefault?: boolean;
metrics: T.Dict<T.Metric>;
onAddCondition: (condition: T.Condition) => void;
}
export function DetailsContent(props: DetailsContentProps) {
- const { currentUser, isDefault, metrics, qualityGate, updatedConditionId } = props;
+ const { isDefault, metrics, qualityGate, updatedConditionId } = props;
const conditions = qualityGate.conditions || [];
const actions = qualityGate.actions || {};
- const displayPermissions = hasGlobalPermission(currentUser, Permissions.QualityGateAdmin);
-
return (
<div className="layout-page-main-inner">
{isDefault && (qualityGate.conditions === undefined || qualityGate.conditions.length === 0) && (
/>
)}
</div>
- {displayPermissions && (
+ {actions.delegate && (
<div className="width-50 big-padded-left">
<QualityGatePermissions qualityGate={qualityGate} />
</div>
);
}
-export default React.memo(withCurrentUser(DetailsContent));
+export default React.memo(DetailsContent);
import { shallow } from 'enzyme';
import * as React from 'react';
import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
-import { mockCondition, mockLoggedInUser } from '../../../../helpers/testMocks';
+import { mockCondition } from '../../../../helpers/testMocks';
import { DetailsContent, DetailsContentProps } from '../DetailsContent';
it('should render correctly', () => {
shallowRender({ isDefault: true, qualityGate: mockQualityGate({ conditions: [] }) })
).toMatchSnapshot('is default, no conditions');
expect(
- shallowRender({ currentUser: mockLoggedInUser({ permissions: { global: ['gateadmin'] } }) })
+ shallowRender({
+ qualityGate: mockQualityGate({ actions: { delegate: true } })
+ })
).toMatchSnapshot('Admin');
});
function shallowRender(props: Partial<DetailsContentProps> = {}) {
return shallow(
<DetailsContent
- currentUser={mockLoggedInUser()}
metrics={{}}
onAddCondition={jest.fn()}
onRemoveCondition={jest.fn()}