mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
## About the changes Creating the first version of the Dark theme Refactor: colors variables Refactor: use theme variable instead - this change will help us to use MuiCssBaseline, and we can use classes directly for easy customization when we can't identify MUI classes Refactor: adjusting some files components - i’ve touched also the structure of some files, not only the colors variables (but only to adjust the style, not functionality) Fix: dark mode persistence on refresh (by Nuno) Feat: dark mode sees light logos, and light mode sees dark logos (by Nuno) --------- Co-authored-by: Nuno Góis <github@nunogois.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { Link } from 'react-router-dom';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import { Alert } from '@mui/material';
|
|
import { IFeatureToggle } from 'interfaces/featureToggle';
|
|
import { formatFeaturePath } from '../../FeatureStrategyEdit/FeatureStrategyEdit';
|
|
import { useFeature } from 'hooks/api/getters/useFeature/useFeature';
|
|
|
|
interface IFeatureStrategyEnabledProps {
|
|
projectId: string;
|
|
featureId: string;
|
|
environmentId: string;
|
|
}
|
|
|
|
export const FeatureStrategyEnabled: FC<IFeatureStrategyEnabledProps> = ({
|
|
projectId,
|
|
featureId,
|
|
environmentId,
|
|
children,
|
|
}) => {
|
|
const featurePagePath = formatFeaturePath(projectId, featureId);
|
|
const { feature } = useFeature(projectId, featureId);
|
|
|
|
const featurePageLink = (
|
|
<Link to={featurePagePath}>feature toggle page</Link>
|
|
);
|
|
|
|
return (
|
|
<ConditionallyRender
|
|
condition={isFeatureEnabledInEnvironment(feature, environmentId)}
|
|
show={children}
|
|
elseShow={
|
|
<Alert severity="warning">
|
|
This feature toggle is currently disabled in the{' '}
|
|
<strong>{environmentId}</strong> environment. Any changes
|
|
made here will not take effect until the toggle has been
|
|
enabled on the {featurePageLink}.
|
|
</Alert>
|
|
}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const isFeatureEnabledInEnvironment = (
|
|
feature: IFeatureToggle,
|
|
environmentId: string
|
|
): boolean => {
|
|
const environment = feature.environments.find(environment => {
|
|
return environment.name === environmentId;
|
|
});
|
|
|
|
if (!environment) {
|
|
return false;
|
|
}
|
|
|
|
return environment.enabled;
|
|
};
|