mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
feat: export project level feature toggles (#3120)
This commit is contained in:
parent
79e351e484
commit
0d80be784c
@ -13,7 +13,7 @@ interface IExportDialogProps {
|
|||||||
showExportDialog: boolean;
|
showExportDialog: boolean;
|
||||||
data: FeatureSchema[];
|
data: FeatureSchema[];
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
environments: IEnvironment[];
|
environments: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledSelect = styled(GeneralSelect)(({ theme }) => ({
|
const StyledSelect = styled(GeneralSelect)(({ theme }) => ({
|
||||||
@ -27,15 +27,15 @@ export const ExportDialog = ({
|
|||||||
onClose,
|
onClose,
|
||||||
environments,
|
environments,
|
||||||
}: IExportDialogProps) => {
|
}: IExportDialogProps) => {
|
||||||
const [selected, setSelected] = useState(environments[0].name);
|
const [selected, setSelected] = useState(environments[0]);
|
||||||
const { createExport } = useExportApi();
|
const { createExport } = useExportApi();
|
||||||
const ref = createRef<HTMLDivElement>();
|
const ref = createRef<HTMLDivElement>();
|
||||||
const { setToastApiError } = useToast();
|
const { setToastApiError } = useToast();
|
||||||
|
|
||||||
const getOptions = () =>
|
const getOptions = () =>
|
||||||
environments.map(env => ({
|
environments.map(env => ({
|
||||||
key: env.name,
|
key: env,
|
||||||
label: env.name,
|
label: env,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const getPayload = () => {
|
const getPayload = () => {
|
||||||
|
@ -59,7 +59,9 @@ const { value: storedParams, setValue: setStoredParams } = createLocalStorage(
|
|||||||
export const FeatureToggleListTable: VFC = () => {
|
export const FeatureToggleListTable: VFC = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { environments } = useEnvironments();
|
const { environments } = useEnvironments();
|
||||||
const enabledEnvironment = environments.filter(env => env.enabled);
|
const enabledEnvironments = environments
|
||||||
|
.filter(env => env.enabled)
|
||||||
|
.map(env => env.name);
|
||||||
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
||||||
const isMediumScreen = useMediaQuery(theme.breakpoints.down('lg'));
|
const isMediumScreen = useMediaQuery(theme.breakpoints.down('lg'));
|
||||||
const [showExportDialog, setShowExportDialog] = useState(false);
|
const [showExportDialog, setShowExportDialog] = useState(false);
|
||||||
@ -387,7 +389,7 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
showExportDialog={showExportDialog}
|
showExportDialog={showExportDialog}
|
||||||
data={data}
|
data={data}
|
||||||
onClose={() => setShowExportDialog(false)}
|
onClose={() => setShowExportDialog(false)}
|
||||||
environments={enabledEnvironment}
|
environments={enabledEnvironments}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { styled, useMediaQuery, useTheme } from '@mui/material';
|
import {
|
||||||
|
IconButton,
|
||||||
|
styled,
|
||||||
|
Tooltip,
|
||||||
|
useMediaQuery,
|
||||||
|
useTheme,
|
||||||
|
} from '@mui/material';
|
||||||
import { Add } from '@mui/icons-material';
|
import { Add } from '@mui/icons-material';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import { SortingRule, useFlexLayout, useSortBy, useTable } from 'react-table';
|
import { SortingRule, useFlexLayout, useSortBy, useTable } from 'react-table';
|
||||||
@ -47,6 +53,9 @@ import { useGlobalLocalStorage } from 'hooks/useGlobalLocalStorage';
|
|||||||
import { useConditionallyHiddenColumns } from 'hooks/useConditionallyHiddenColumns';
|
import { useConditionallyHiddenColumns } from 'hooks/useConditionallyHiddenColumns';
|
||||||
import { flexRow } from 'themes/themeStyles';
|
import { flexRow } from 'themes/themeStyles';
|
||||||
import VariantsWarningTooltip from 'component/feature/FeatureView/FeatureVariants/VariantsTooltipWarning';
|
import VariantsWarningTooltip from 'component/feature/FeatureView/FeatureVariants/VariantsTooltipWarning';
|
||||||
|
import FileDownload from '@mui/icons-material/FileDownload';
|
||||||
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
|
import { ExportDialog } from 'component/feature/FeatureToggleList/ExportDialog';
|
||||||
|
|
||||||
const StyledResponsiveButton = styled(ResponsiveButton)(() => ({
|
const StyledResponsiveButton = styled(ResponsiveButton)(() => ({
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
@ -145,6 +154,8 @@ export const ProjectFeatureToggles = ({
|
|||||||
onChangeRequestToggleConfirm,
|
onChangeRequestToggleConfirm,
|
||||||
changeRequestDialogDetails,
|
changeRequestDialogDetails,
|
||||||
} = useChangeRequestToggle(projectId);
|
} = useChangeRequestToggle(projectId);
|
||||||
|
const [showExportDialog, setShowExportDialog] = useState(false);
|
||||||
|
const { uiConfig } = useUiConfig();
|
||||||
|
|
||||||
const onToggle = useCallback(
|
const onToggle = useCallback(
|
||||||
async (
|
async (
|
||||||
@ -377,7 +388,7 @@ export const ProjectFeatureToggles = ({
|
|||||||
getSearchContext,
|
getSearchContext,
|
||||||
} = useSearch(columns, searchValue, featuresData);
|
} = useSearch(columns, searchValue, featuresData);
|
||||||
|
|
||||||
const data = useMemo<object[]>(() => {
|
const data = useMemo(() => {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return Array(6).fill({
|
return Array(6).fill({
|
||||||
type: '-',
|
type: '-',
|
||||||
@ -542,6 +553,28 @@ export const ProjectFeatureToggles = ({
|
|||||||
setHiddenColumns={setHiddenColumns}
|
setHiddenColumns={setHiddenColumns}
|
||||||
/>
|
/>
|
||||||
<PageHeader.Divider sx={{ marginLeft: 0 }} />
|
<PageHeader.Divider sx={{ marginLeft: 0 }} />
|
||||||
|
<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>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<StyledResponsiveButton
|
<StyledResponsiveButton
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(getCreateTogglePath(projectId))
|
navigate(getCreateTogglePath(projectId))
|
||||||
@ -639,6 +672,17 @@ export const ProjectFeatureToggles = ({
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={Boolean(uiConfig?.flags?.featuresExportImport)}
|
||||||
|
show={
|
||||||
|
<ExportDialog
|
||||||
|
showExportDialog={showExportDialog}
|
||||||
|
data={data}
|
||||||
|
onClose={() => setShowExportDialog(false)}
|
||||||
|
environments={environments}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</PageContent>
|
</PageContent>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user