Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gitar] Cleaning up stale flag: featuresExportImport with value false #1696

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
const server = testServerSetup();
test('all options are drawn', async () => {
testServerRoute(server, '/api/admin/ui-config', {
flags: {
featuresExportImport: true,
},
flags: {},
});

render(<FeatureToggleListActions onExportClick={() => {}} />);
Expand All @@ -19,5 +17,5 @@
await userEvent.click(batchReviveButton!);

await screen.findByText('New feature flag');
await screen.findByText('Export');

Check failure on line 20 in frontend/src/component/feature/FeatureToggleList/FeatureToggleListActions/FeatureToggleActions.test.tsx

View workflow job for this annotation

GitHub Actions / build

src/component/feature/FeatureToggleList/FeatureToggleListActions/FeatureToggleActions.test.tsx > all options are drawn

TestingLibraryElementError: Unable to find an element with the text: Export. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. Ignored nodes: comments, script, style <body> <div aria-hidden="true" > <div class="css-1l4w6pd" > <button aria-controls="feature-flag-list-actions-menu" aria-expanded="true" aria-haspopup="true" class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-gpbbjl-MuiButtonBase-root-MuiIconButton-root" data-mui-internal-clone-element="true" id="feature-flag-list-actions" tabindex="0" type="button" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root" data-testid="MoreVertIcon" focusable="false" viewBox="0 0 24 24" > <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" /> </svg> <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" /> </button> </div> <div aria-atomic="true" aria-live="polite" class="css-gqbqkz" data-testid="ANNOUNCER_ELEMENT_TEST_ID" role="status" /> </div> <div class="MuiPopover-root MuiModal-root css-rbassn-MuiModal-root-MuiPopover-root" id="feature-flag-list-actions-menu" role="presentation" > <div aria-hidden="true" class="MuiBackdrop-root MuiBackdrop-invisible MuiModal-backdrop css-g3hgs1-MuiBackdrop-root-MuiModal-backdrop" style="opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" /> <div data-testid="sentinelStart" tabindex="0" /> <div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation8 MuiPopover-paper css-1flyh6l-MuiPaper-root-MuiPopover-paper" style="opacity: 1; transform: none; transition: opacity 0ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,transform 0ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; top: 16px; left: 16px; transform-origin: -16px -16px;" tabindex="-1" > <ul aria-labelledby="feature-flag-list-actions" class="MuiList-root MuiList-padding css-h4y409-MuiList-root" role="menu" tabindex="-1" > <a aria-disabled="true" aria-label="Access denied" class="MuiButtonBase-root MuiMenuItem-root Mui-disabled MuiMenuItem-gutters Mui-disabled MuiMenuItem-root Mui-disabled MuiMenuItem-gutters css-15rhwx4-MuiButtonBase-root-MuiMenuItem-root" data-mui-internal-clone-element="true" href="/projects/default?create=true" role="menuitem" tabindex="-1" > <div class="MuiListItemIcon-root css-anneze-MuiListItemIcon-root" > <svg aria-hidden="true" class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root" data-testid="AddIcon" focusable="false" viewBox="0 0 24 24" > <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> </svg> </div> <div class="MuiListItemText-root css-tlelie-MuiListItemText-root" > <p class="MuiTypography-root MuiTypography-body2 css-1w3yta-MuiTypography-root" > New feature flag </p> </div> </a> </ul> </div> <div data-testid="sentinelEnd" tabindex="0" /> </div> </body> Ignored nodes: comments, script, style <body> <div aria-hidden="true" > <div class="css-1l4w6pd" > <button aria-controls="feature-flag-list-actions-menu
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ import {
import Add from '@mui/icons-material/Add';
import MoreVert from '@mui/icons-material/MoreVert';
import { Link } from 'react-router-dom';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { useUiFlag } from 'hooks/useUiFlag';
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC';
import { useCreateFeaturePath } from 'component/feature/CreateFeatureButton/useCreateFeaturePath';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import IosShare from '@mui/icons-material/IosShare';

const StyledActions = styled('div')(({ theme }) => ({
const StyledActions = styled('div')((_) => ({
display: 'flex',
justifyContent: 'center',
}));
Expand All @@ -35,12 +32,11 @@ interface IFeatureFlagListActions {
onExportClick: () => void;
}

export const FeatureToggleListActions: FC<IFeatureFlagListActions> = ({
onExportClick,
}: IFeatureFlagListActions) => {
export const FeatureToggleListActions: FC<IFeatureFlagListActions> = (
_: IFeatureFlagListActions,
) => {
const { trackEvent } = usePlausibleTracker();
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const featuresExportImport = useUiFlag('featuresExportImport');
const createFeature = useCreateFeaturePath({
query: '',
project: 'default',
Expand Down Expand Up @@ -123,31 +119,6 @@ export const FeatureToggleListActions: FC<IFeatureFlagListActions> = ({
</MenuItem>
)}
</PermissionHOC>
<ConditionallyRender
condition={featuresExportImport}
show={
<MenuItem
onClick={() => {
onExportClick();
handleClose();
trackEvent('search-feature-buttons', {
props: {
action: 'export',
},
});
}}
>
<ListItemIcon>
<IosShare />
</ListItemIcon>
<ListItemText>
<Typography variant='body2'>
Export
</Typography>
</ListItemText>
</MenuItem>
}
/>
</MenuList>
</StyledPopover>
</StyledActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { useFavoriteFeaturesApi } from 'hooks/api/actions/useFavoriteFeaturesApi
import { FavoriteIconCell } from 'component/common/Table/cells/FavoriteIconCell/FavoriteIconCell';
import { FavoriteIconHeader } from 'component/common/Table/FavoriteIconHeader/FavoriteIconHeader';
import { useEnvironments } from 'hooks/api/getters/useEnvironments/useEnvironments';
import { ExportDialog } from './ExportDialog';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { focusable } from 'themes/themeStyles';
import { FeatureEnvironmentSeenCell } from 'component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell';
import useToast from 'hooks/useToast';
Expand Down Expand Up @@ -58,15 +56,11 @@ export const FeatureToggleListTable: VFC = () => {
const featureSearchFeedback = useUiFlag('featureSearchFeedback');
const { trackEvent } = usePlausibleTracker();
const { environments } = useEnvironments();
const enabledEnvironments = environments
.filter((env) => env.enabled)
.map((env) => env.name);
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
const isMediumScreen = useMediaQuery(theme.breakpoints.down('lg'));
const [showExportDialog, setShowExportDialog] = useState(false);

const { setToastApiError } = useToast();
const { uiConfig } = useUiConfig();

const variant =
featureSearchFeedback !== false
Expand Down Expand Up @@ -429,17 +423,6 @@ export const FeatureToggleListTable: VFC = () => {
</Box>
}
/>
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.featuresExportImport)}
show={
<ExportDialog
showExportDialog={showExportDialog}
data={data}
onClose={() => setShowExportDialog(false)}
environments={enabledEnvironments}
/>
}
/>
</PageContent>
);
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { type ReactNode, type FC, useState } from 'react';
import {
Box,
Button,
IconButton,
Tooltip,
useMediaQuery,
useTheme,
} from '@mui/material';
import { Box, Button, useMediaQuery, useTheme } from '@mui/material';
import useLoading from 'hooks/useLoading';
import { PageHeader } from 'component/common/PageHeader/PageHeader';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
Expand All @@ -18,14 +11,12 @@ import ResponsiveButton from 'component/common/ResponsiveButton/ResponsiveButton
import { useSearchParams } from 'react-router-dom';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
import { ExportDialog } from 'component/feature/FeatureToggleList/ExportDialog';
import type { FeatureSchema } from 'openapi';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import ReviewsOutlined from '@mui/icons-material/ReviewsOutlined';
import { useFeedback } from 'component/feedbackNew/useFeedback';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { CreateFeatureDialog } from './CreateFeatureDialog';
import IosShare from '@mui/icons-material/IosShare';
import type { OverridableStringUnion } from '@mui/types';
import type { ButtonPropsVariantOverrides } from '@mui/material/Button/Button';

Expand Down Expand Up @@ -85,20 +76,11 @@ export const FlagCreationButton = ({

export const ProjectFeatureTogglesHeader: FC<
IProjectFeatureTogglesHeaderProps
> = ({
isLoading,
totalItems,
searchQuery,
onChangeSearchQuery,
environmentsToExport,
actions,
}) => {
const projectId = useRequiredPathParam('projectId');
> = ({ isLoading, totalItems, searchQuery, onChangeSearchQuery, actions }) => {
const headerLoadingRef = useLoading(isLoading || false);
const [showTitle, setShowTitle] = useState(true);
const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
const featuresExportImportFlag = useUiFlag('featuresExportImport');
const [showExportDialog, setShowExportDialog] = useState(false);
const { trackEvent } = usePlausibleTracker();
const projectOverviewRefactorFeedback = useUiFlag(
Expand Down Expand Up @@ -162,48 +144,6 @@ export const ProjectFeatureTogglesHeader: FC<
/>
{actions}
<PageHeader.Divider sx={{ marginLeft: 0 }} />
<ConditionallyRender
condition={featuresExportImportFlag}
show={
<>
<Tooltip
title='Export all project flags'
arrow
>
<IconButton
data-loading
onClick={() =>
setShowExportDialog(true)
}
sx={(theme) => ({
marginRight: theme.spacing(2),
})}
>
<IosShare />
</IconButton>
</Tooltip>

<ConditionallyRender
condition={!isLoading}
show={
<ExportDialog
showExportDialog={
showExportDialog
}
project={projectId}
data={[]}
onClose={() =>
setShowExportDialog(false)
}
environments={
environmentsToExport || []
}
/>
}
/>
</>
}
/>
<ConditionallyRender
condition={
projectOverviewRefactorFeedback &&
Expand Down
24 changes: 1 addition & 23 deletions frontend/src/component/project/Project/Project.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useNavigate } from 'react-router';
import useLoading from 'hooks/useLoading';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { ReactComponent as ImportSvg } from 'assets/icons/import.svg';
import {
StyledDiv,
StyledFavoriteIconButton,
Expand All @@ -22,8 +21,6 @@ import ProjectEnvironment from '../ProjectEnvironment/ProjectEnvironment';
import { ProjectFeaturesArchive } from './ProjectFeaturesArchive/ProjectFeaturesArchive';
import ProjectFlags from './ProjectFlags';
import ProjectHealth from './ProjectHealth/ProjectHealth';
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
Expand All @@ -34,7 +31,6 @@ import { ProjectChangeRequests } from '../../changeRequest/ProjectChangeRequests
import { ProjectSettings } from './ProjectSettings/ProjectSettings';
import { useFavoriteProjectsApi } from 'hooks/api/actions/useFavoriteProjectsApi/useFavoriteProjectsApi';
import { ImportModal } from './Import/ImportModal';
import { IMPORT_BUTTON } from 'utils/testIds';
import { EnterpriseBadge } from 'component/common/EnterpriseBadge/EnterpriseBadge';
import { Badge } from 'component/common/Badge/Badge';
import type { UiFlags } from 'interfaces/uiConfig';
Expand Down Expand Up @@ -216,25 +212,7 @@ export const Project = () => {
</StyledName>
</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-project
>
<ImportSvg />
</PermissionIconButton>
}
/>
</StyledDiv>
<StyledDiv />
</StyledTopRow>
</StyledInnerContainer>

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 @@ -53,7 +53,6 @@ export type UiFlags = {
maintenanceMode?: boolean;
messageBanner?: Variant;
banner?: Variant;
featuresExportImport?: boolean;
caseInsensitiveInOperators?: boolean;
notifications?: boolean;
personalAccessTokensKillSwitch?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,4 @@
]
},
"packageManager": "[email protected]"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
importTogglesValidateSchema,
} from '../../openapi';
import type { IAuthRequest } from '../../routes/unleash-types';
import { extractUsername } from '../../util';
import { BadDataError, InvalidOperationError } from '../../error';
import ApiUser from '../../types/api-user';

Expand Down Expand Up @@ -118,7 +117,6 @@ class ExportImportController extends Controller {
): Promise<void> {
this.verifyExportImportEnabled();
const query = req.body;
const userName = extractUsername(req);

const data = await this.exportService.export(query, req.audit);

Expand Down Expand Up @@ -173,11 +171,7 @@ class ExportImportController extends Controller {
}

private verifyExportImportEnabled() {
if (!this.config.flagResolver.isEnabled('featuresExportImport')) {
throw new InvalidOperationError(
'Feature export/import is not enabled',
);
}
throw new InvalidOperationError('Feature export/import is not enabled');
}
}
export default ExportImportController;
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,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 @@ -155,9 +155,7 @@ beforeAll(async () => {
db.stores,
{
experimental: {
flags: {
featuresExportImport: true,
},
flags: {},
},
},
db.rawDatabase,
Expand Down
1 change: 0 additions & 1 deletion src/lib/openapi/spec/ui-config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export const uiConfigSchema = {
name: 'disabled',
enabled: false,
},
featuresExportImport: true,
},
additionalProperties: {
anyOf: [
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type IFlagKey =
| 'responseTimeWithAppNameKillSwitch'
| 'maintenanceMode'
| 'messageBanner'
| 'featuresExportImport'
| 'caseInsensitiveInOperators'
| 'strictSchemaValidation'
| 'personalAccessTokensKillSwitch'
Expand Down Expand Up @@ -99,10 +98,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_MESSAGE_BANNER_PAYLOAD ?? '',
},
},
featuresExportImport: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_FEATURES_EXPORT_IMPORT,
true,
),
caseInsensitiveInOperators: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_CASE_INSENSITIVE_IN_OPERATORS,
false,
Expand Down
Loading