Skip to content

Commit

Permalink
chore: Change request flags removed (#4601)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Sep 4, 2023
1 parent ad9d9d9 commit 5ae86ef
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 49 deletions.
Expand Up @@ -18,8 +18,6 @@ import { APPROVE_CHANGE_REQUEST } from 'component/providers/AccessProvider/permi
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
import AccessContext from 'contexts/AccessContext';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import CheckBox from '@mui/icons-material/Check';
import Clear from '@mui/icons-material/Clear';

Expand All @@ -28,7 +26,6 @@ export const ReviewButton: FC<{
onReject: () => void;
onApprove: () => void;
}> = ({ disabled, onReject, onApprove, children }) => {
const { uiConfig } = useUiConfig();
const { isAdmin } = useContext(AccessContext);
const projectId = useRequiredPathParam('projectId');
const id = useRequiredPathParam('id');
Expand Down Expand Up @@ -111,21 +108,14 @@ export const ReviewButton: FC<{
Approve changes
</ListItemText>
</MenuItem>
<ConditionallyRender
condition={Boolean(
uiConfig?.flags?.changeRequestReject
)}
show={
<MenuItem onClick={onReject}>
<ListItemIcon>
<Clear fontSize="small" />
</ListItemIcon>
<ListItemText>
Reject changes
</ListItemText>
</MenuItem>
}
/>
<MenuItem onClick={onReject}>
<ListItemIcon>
<Clear fontSize="small" />
</ListItemIcon>
<ListItemText>
Reject changes
</ListItemText>
</MenuItem>
</MenuList>
</ClickAwayListener>
</Paper>
Expand Down
10 changes: 3 additions & 7 deletions frontend/src/component/segments/EditSegment/EditSegment.tsx
Expand Up @@ -76,16 +76,14 @@ export const EditSegment = ({ modal }: IEditSegmentProps) => {
const highestPermissionChangeRequestEnv =
useHighestPermissionChangeRequestEnvironment(segment?.project);
const changeRequestEnv = highestPermissionChangeRequestEnv();
const activateSegmentChangeRequests =
uiConfig?.flags?.segmentChangeRequests && changeRequestEnv;
const { addChange } = useChangeRequestApi();

const handleSubmit = async (e: React.FormEvent) => {
if (segment) {
e.preventDefault();
clearErrors();
try {
if (activateSegmentChangeRequests) {
if (changeRequestEnv) {
await addChange(segment.project || '', changeRequestEnv, {
action: 'updateSegment',
feature: null,
Expand All @@ -102,9 +100,7 @@ export const EditSegment = ({ modal }: IEditSegmentProps) => {
}
setToastData({
title: `Segment ${
activateSegmentChangeRequests
? 'change added to draft'
: 'updated'
changeRequestEnv ? 'change added to draft' : 'updated'
}`,
type: 'success',
});
Expand Down Expand Up @@ -143,7 +139,7 @@ export const EditSegment = ({ modal }: IEditSegmentProps) => {
disabled={!hasValidConstraints || overSegmentValuesLimit}
data-testid={SEGMENT_SAVE_BTN_ID}
>
{activateSegmentChangeRequests ? 'Add to draft' : 'Save'}
{changeRequestEnv ? 'Add to draft' : 'Save'}
</UpdateButton>
</SegmentForm>
</FormTemplate>
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/interfaces/uiConfig.ts
Expand Up @@ -52,8 +52,6 @@ export interface IFlags {
advancedPlayground?: boolean;
customRootRolesKillSwitch?: boolean;
strategyVariant?: boolean;
segmentChangeRequests?: boolean;
changeRequestReject?: boolean;
lastSeenByEnvironment?: boolean;
newApplicationList?: boolean;
integrationsRework?: boolean;
Expand Down
4 changes: 0 additions & 4 deletions src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -70,7 +70,6 @@ exports[`should create default config 1`] = `
"flags": {
"anonymiseEventLog": false,
"caseInsensitiveInOperators": false,
"changeRequestReject": false,
"customRootRolesKillSwitch": false,
"demo": false,
"disableBulkToggle": false,
Expand All @@ -97,7 +96,6 @@ exports[`should create default config 1`] = `
"personalAccessTokensKillSwitch": false,
"proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false,
"segmentChangeRequests": false,
"slackAppAddon": false,
"strategyVariant": false,
"strictSchemaValidation": false,
Expand All @@ -107,7 +105,6 @@ exports[`should create default config 1`] = `
"experiments": {
"anonymiseEventLog": false,
"caseInsensitiveInOperators": false,
"changeRequestReject": false,
"customRootRolesKillSwitch": false,
"demo": false,
"disableBulkToggle": false,
Expand All @@ -134,7 +131,6 @@ exports[`should create default config 1`] = `
"personalAccessTokensKillSwitch": false,
"proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false,
"segmentChangeRequests": false,
"slackAppAddon": false,
"strategyVariant": false,
"strictSchemaValidation": false,
Expand Down
10 changes: 3 additions & 7 deletions src/lib/services/segment-service.ts
Expand Up @@ -104,10 +104,8 @@ export class SegmentService implements ISegmentService {
}

async update(id: number, data: unknown, user: User): Promise<void> {
if (this.flagResolver.isEnabled('segmentChangeRequests')) {
const input = await segmentSchema.validateAsync(data);
await this.stopWhenChangeRequestsEnabled(input.project, user);
}
const input = await segmentSchema.validateAsync(data);
await this.stopWhenChangeRequestsEnabled(input.project, user);
return this.unprotectedUpdate(id, data, user);
}

Expand Down Expand Up @@ -138,9 +136,7 @@ export class SegmentService implements ISegmentService {

async delete(id: number, user: User): Promise<void> {
const segment = await this.segmentStore.get(id);
if (this.flagResolver.isEnabled('segmentChangeRequests')) {
await this.stopWhenChangeRequestsEnabled(segment.project, user);
}
await this.stopWhenChangeRequestsEnabled(segment.project, user);
await this.segmentStore.delete(id);
await this.eventStore.store({
type: SEGMENT_DELETED,
Expand Down
10 changes: 0 additions & 10 deletions src/lib/types/experimental.ts
Expand Up @@ -24,8 +24,6 @@ export type IFlagKey =
| 'slackAppAddon'
| 'filterInvalidClientMetrics'
| 'lastSeenByEnvironment'
| 'segmentChangeRequests'
| 'changeRequestReject'
| 'customRootRolesKillSwitch'
| 'newApplicationList'
| 'integrationsRework'
Expand Down Expand Up @@ -115,14 +113,6 @@ const flags: IFlags = {
process.env.LAST_SEEN_BY_ENVIRONMENT,
false,
),
segmentChangeRequests: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_SEGMENT_CHANGE_REQUESTS,
false,
),
changeRequestReject: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_CHANGE_REQUEST_REJECT,
false,
),
customRootRolesKillSwitch: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_CUSTOM_ROOT_ROLES_KILL_SWITCH,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Expand Up @@ -40,7 +40,6 @@ process.nextTick(async () => {
strategyVariant: true,
slackAppAddon: true,
lastSeenByEnvironment: true,
segmentChangeRequests: true,
newApplicationList: true,
doraMetrics: true,
instanceHealthDashboard: true,
Expand Down

0 comments on commit 5ae86ef

Please sign in to comment.