Skip to content

Commit

Permalink
chore: remove export import flag (#3371)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Mar 27, 2023
1 parent 69a473c commit 9abe859
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { FC, VFC, useEffect, useState, useContext } from 'react';
import { InstanceStatusBar } from 'component/common/InstanceStatus/InstanceStatusBar';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { Dialogue } from 'component/common/Dialogue/Dialogue';
import { Typography, useTheme } from '@mui/material';
import { Typography } from '@mui/material';
import { useNavigate } from 'react-router-dom';
import { IInstanceStatus } from 'interfaces/instance';
import { ADMIN } from 'component/providers/AccessProvider/permissions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const FeatureToggleListTable: VFC = () => {
const [showExportDialog, setShowExportDialog] = useState(false);
const { features = [], loading, refetchFeatures } = useFeatures();
const [searchParams, setSearchParams] = useSearchParams();
const { uiConfig } = useUiConfig();
const [initialState] = useState(() => ({
sortBy: [
{
Expand Down Expand Up @@ -311,28 +310,16 @@ export const FeatureToggleListTable: VFC = () => {
>
View archive
</Link>
<ConditionallyRender
condition={Boolean(
uiConfig?.flags?.featuresExportImport
)}
show={
<Tooltip
title="Export current selection"
arrow
>
<IconButton
onClick={() =>
setShowExportDialog(true)
}
sx={theme => ({
marginRight: theme.spacing(2),
})}
>
<FileDownload />
</IconButton>
</Tooltip>
}
/>
<Tooltip title="Export current selection" arrow>
<IconButton
onClick={() => setShowExportDialog(true)}
sx={theme => ({
marginRight: theme.spacing(2),
})}
>
<FileDownload />
</IconButton>
</Tooltip>

<CreateFeatureButton
loading={false}
Expand Down Expand Up @@ -383,16 +370,11 @@ export const FeatureToggleListTable: VFC = () => {
/>
}
/>
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.featuresExportImport)}
show={
<ExportDialog
showExportDialog={showExportDialog}
data={data}
onClose={() => setShowExportDialog(false)}
environments={enabledEnvironments}
/>
}
<ExportDialog
showExportDialog={showExportDialog}
data={data}
onClose={() => setShowExportDialog(false)}
environments={enabledEnvironments}
/>
</PageContent>
);
Expand Down
27 changes: 10 additions & 17 deletions frontend/src/component/project/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,16 @@ export const Project = () => {
</StyledProjectTitle>
</StyledDiv>
<StyledDiv>
<ConditionallyRender
condition={Boolean(
uiConfig?.flags?.featuresExportImport
)}
show={
<PermissionIconButton
permission={UPDATE_FEATURE}
projectId={projectId}
onClick={() => setModalOpen(true)}
tooltipProps={{ title: 'Import' }}
data-testid={IMPORT_BUTTON}
data-loading
>
<FileUpload />
</PermissionIconButton>
}
/>
<PermissionIconButton
permission={UPDATE_FEATURE}
projectId={projectId}
onClick={() => setModalOpen(true)}
tooltipProps={{ title: 'Import' }}
data-testid={IMPORT_BUTTON}
data-loading
>
<FileUpload />
</PermissionIconButton>
<ConditionallyRender
condition={!isOss()}
show={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,29 +583,21 @@ export const ProjectFeatureToggles = ({
setHiddenColumns={setHiddenColumns}
/>
<PageHeader.Divider sx={{ marginLeft: 0 }} />
<ConditionallyRender
condition={Boolean(
uiConfig?.flags?.featuresExportImport
)}
show={
<Tooltip
title="Export toggles visible in the table below"
arrow
>
<IconButton
onClick={() =>
setShowExportDialog(true)
}
sx={theme => ({
marginRight:
theme.spacing(2),
})}
>
<FileDownload />
</IconButton>
</Tooltip>
}
/>
<Tooltip
title="Export toggles visible in the table below"
arrow
>
<IconButton
onClick={() =>
setShowExportDialog(true)
}
sx={theme => ({
marginRight: theme.spacing(2),
})}
>
<FileDownload />
</IconButton>
</Tooltip>
<StyledResponsiveButton
onClick={() =>
navigate(getCreateTogglePath(projectId))
Expand Down Expand Up @@ -712,10 +704,7 @@ export const ProjectFeatureToggles = ({
}
/>
<ConditionallyRender
condition={
Boolean(uiConfig?.flags?.featuresExportImport) &&
!loading
}
condition={!loading}
show={
<ExportDialog
showExportDialog={showExportDialog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FileDownload } from '@mui/icons-material';
import type { FeatureSchema } from 'openapi';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { ExportDialog } from 'component/feature/FeatureToggleList/ExportDialog';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { ArchiveButton } from './ArchiveButton';
import { MoreActions } from './MoreActions';
import { ManageTags } from './ManageTags';
Expand All @@ -19,7 +18,6 @@ interface IProjectFeaturesBatchActionsProps {
export const ProjectFeaturesBatchActions: FC<
IProjectFeaturesBatchActionsProps
> = ({ selectedIds, data, projectId }) => {
const { uiConfig } = useUiConfig();
const [showExportDialog, setShowExportDialog] = useState(false);
const { trackEvent } = usePlausibleTracker();
const selectedData = useMemo(
Expand Down Expand Up @@ -56,17 +54,12 @@ export const ProjectFeaturesBatchActions: FC<
</Button>
<ManageTags projectId={projectId} data={selectedData} />
<MoreActions projectId={projectId} data={selectedData} />
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.featuresExportImport)}
show={
<ExportDialog
showExportDialog={showExportDialog}
data={selectedData}
onClose={() => setShowExportDialog(false)}
environments={environments}
onConfirm={trackExport}
/>
}
<ExportDialog
showExportDialog={showExportDialog}
data={selectedData}
onClose={() => setShowExportDialog(false)}
environments={environments}
onConfirm={trackExport}
/>
</>
);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface IFlags {
embedProxyFrontend?: boolean;
maintenanceMode?: boolean;
messageBanner?: boolean;
featuresExportImport?: boolean;
newProjectOverview?: boolean;
caseInsensitiveInOperators?: boolean;
crOnVariants?: boolean;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ exports[`should create default config 1`] = `
"crOnVariants": false,
"embedProxy": true,
"embedProxyFrontend": true,
"featuresExportImport": false,
"loginHistory": false,
"maintenanceMode": false,
"messageBanner": false,
Expand Down Expand Up @@ -103,7 +102,6 @@ exports[`should create default config 1`] = `
"crOnVariants": false,
"embedProxy": true,
"embedProxyFrontend": true,
"featuresExportImport": false,
"loginHistory": false,
"maintenanceMode": false,
"messageBanner": false,
Expand Down
12 changes: 0 additions & 12 deletions src/lib/features/export-import-toggles/export-import-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from '../../openapi';
import { IAuthRequest } from '../../routes/unleash-types';
import { extractUsername } from '../../util';
import { InvalidOperationError } from '../../error';

class ExportImportController extends Controller {
private logger: Logger;
Expand Down Expand Up @@ -119,7 +118,6 @@ class ExportImportController extends Controller {
req: IAuthRequest<unknown, unknown, ExportQuerySchema, unknown>,
res: Response,
): Promise<void> {
this.verifyExportImportEnabled();
const query = req.body;
const userName = extractUsername(req);
const data = await this.exportImportService.export(query, userName);
Expand All @@ -136,7 +134,6 @@ class ExportImportController extends Controller {
req: IAuthRequest<unknown, unknown, ImportTogglesSchema, unknown>,
res: Response,
): Promise<void> {
this.verifyExportImportEnabled();
const dto = req.body;
const { user } = req;
const validation = await this.startTransaction(async (tx) =>
Expand All @@ -155,7 +152,6 @@ class ExportImportController extends Controller {
req: IAuthRequest<unknown, unknown, ImportTogglesSchema, unknown>,
res: Response,
): Promise<void> {
this.verifyExportImportEnabled();
const dto = req.body;
const { user } = req;
await this.startTransaction(async (tx) =>
Expand All @@ -164,13 +160,5 @@ class ExportImportController extends Controller {

res.status(200).end();
}

private verifyExportImportEnabled() {
if (!this.config.flagResolver.isEnabled('featuresExportImport')) {
throw new InvalidOperationError(
'Feature export/import is not enabled',
);
}
}
}
export default ExportImportController;
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ beforeAll(async () => {
db.stores,
{
experimental: {
flags: {
featuresExportImport: true,
},
flags: {},
},
},
db.rawDatabase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ beforeAll(async () => {
db.stores,
{
experimental: {
flags: {
featuresExportImport: true,
},
flags: {},
},
},
db.rawDatabase,
Expand Down
4 changes: 0 additions & 4 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const flags = {
process.env.UNLEASH_EXPERIMENTAL_MESSAGE_BANNER,
false,
),
featuresExportImport: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_FEATURES_EXPORT_IMPORT,
false,
),
caseInsensitiveInOperators: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_CASE_INSENSITIVE_IN_OPERATORS,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ process.nextTick(async () => {
embedProxyFrontend: true,
anonymiseEventLog: false,
responseTimeWithAppNameKillSwitch: false,
featuresExportImport: true,
newProjectOverview: true,
bulkOperations: true,
projectStatusApi: true,
Expand Down

0 comments on commit 9abe859

Please sign in to comment.