mirror of https://github.com/portainer/portainer
feat(edge): hide FDO features behind a flag [EE-5128] (#8600)
parent
8345d1471e
commit
01ea9afe33
|
@ -1557,7 +1557,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// List of supported features
|
// List of supported features
|
||||||
var SupportedFeatureFlags = []featureflags.Feature{}
|
var SupportedFeatureFlags = []featureflags.Feature{
|
||||||
|
"fdo",
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ AuthenticationMethod = iota
|
_ AuthenticationMethod = iota
|
||||||
|
|
|
@ -19,10 +19,10 @@ export function TextTip({
|
||||||
children,
|
children,
|
||||||
}: PropsWithChildren<Props>) {
|
}: PropsWithChildren<Props>) {
|
||||||
return (
|
return (
|
||||||
<p className={clsx('small inline-flex items-center gap-1', className)}>
|
<div className={clsx('small inline-flex items-center gap-1', className)}>
|
||||||
<Icon icon={icon} mode={getMode(color)} className="shrink-0" />
|
<Icon icon={icon} mode={getMode(color)} className="shrink-0" />
|
||||||
<span className="text-muted">{children}</span>
|
<span className="text-muted">{children}</span>
|
||||||
</p>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,20 @@ import { Button } from '@@/buttons';
|
||||||
import { Link } from '@@/Link';
|
import { Link } from '@@/Link';
|
||||||
|
|
||||||
import { useSettings } from '../../settings/queries';
|
import { useSettings } from '../../settings/queries';
|
||||||
|
import {
|
||||||
|
FeatureFlag,
|
||||||
|
useFeatureFlag,
|
||||||
|
} from '../../feature-flags/useFeatureFlag';
|
||||||
|
|
||||||
export function ImportFdoDeviceButton() {
|
export function ImportFdoDeviceButton() {
|
||||||
|
const flagEnabledQuery = useFeatureFlag(FeatureFlag.FDO);
|
||||||
|
|
||||||
const isFDOEnabledQuery = useSettings(
|
const isFDOEnabledQuery = useSettings(
|
||||||
(settings) => settings.fdoConfiguration.enabled
|
(settings) => settings.fdoConfiguration.enabled,
|
||||||
|
flagEnabledQuery.data
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isFDOEnabledQuery.data) {
|
if (!isFDOEnabledQuery.data || !flagEnabledQuery.data) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +28,7 @@ export function ImportFdoDeviceButton() {
|
||||||
icon={Plus}
|
icon={Plus}
|
||||||
as={Link}
|
as={Link}
|
||||||
props={{ to: 'portainer.endpoints.importDevice' }}
|
props={{ to: 'portainer.endpoints.importDevice' }}
|
||||||
|
className="ml-[5px]"
|
||||||
>
|
>
|
||||||
Import FDO device
|
Import FDO device
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { usePublicSettings } from '../settings/queries';
|
||||||
|
|
||||||
|
export enum FeatureFlag {
|
||||||
|
FDO = 'fdo',
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useFeatureFlag(
|
||||||
|
flag: FeatureFlag,
|
||||||
|
{
|
||||||
|
onSuccess,
|
||||||
|
enabled = true,
|
||||||
|
}: { onSuccess?: (isEnabled: boolean) => void; enabled?: boolean } = {}
|
||||||
|
) {
|
||||||
|
return usePublicSettings<boolean>({
|
||||||
|
select: (settings) => settings.Features[flag],
|
||||||
|
onSuccess,
|
||||||
|
enabled,
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,22 +1,6 @@
|
||||||
import { useRouter } from '@uirouter/react';
|
import { useRouter } from '@uirouter/react';
|
||||||
|
|
||||||
import { usePublicSettings } from '@/react/portainer/settings/queries';
|
import { FeatureFlag, useFeatureFlag } from './useFeatureFlag';
|
||||||
|
|
||||||
export enum FeatureFlag {}
|
|
||||||
|
|
||||||
export function useFeatureFlag(
|
|
||||||
flag: FeatureFlag,
|
|
||||||
{
|
|
||||||
onSuccess,
|
|
||||||
enabled = true,
|
|
||||||
}: { onSuccess?: (isEnabled: boolean) => void; enabled?: boolean } = {}
|
|
||||||
) {
|
|
||||||
return usePublicSettings<boolean>({
|
|
||||||
select: (settings) => settings.Features[flag],
|
|
||||||
onSuccess,
|
|
||||||
enabled,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useRedirectFeatureFlag(
|
export function useRedirectFeatureFlag(
|
||||||
flag: FeatureFlag,
|
flag: FeatureFlag,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentType } from 'react';
|
import { ComponentType } from 'react';
|
||||||
|
|
||||||
import { FeatureFlag, useFeatureFlag } from './useRedirectFeatureFlag';
|
import { FeatureFlag, useFeatureFlag } from './useFeatureFlag';
|
||||||
|
|
||||||
export function withFeatureFlag<T>(
|
export function withFeatureFlag<T>(
|
||||||
WrappedComponent: ComponentType<T>,
|
WrappedComponent: ComponentType<T>,
|
||||||
|
|
|
@ -3,6 +3,10 @@ import { Formik, Field, Form } from 'formik';
|
||||||
import { Laptop } from 'lucide-react';
|
import { Laptop } from 'lucide-react';
|
||||||
|
|
||||||
import { FDOConfiguration } from '@/portainer/hostmanagement/fdo/model';
|
import { FDOConfiguration } from '@/portainer/hostmanagement/fdo/model';
|
||||||
|
import {
|
||||||
|
FeatureFlag,
|
||||||
|
useFeatureFlag,
|
||||||
|
} from '@/react/portainer/feature-flags/useFeatureFlag';
|
||||||
|
|
||||||
import { Switch } from '@@/form-components/SwitchField/Switch';
|
import { Switch } from '@@/form-components/SwitchField/Switch';
|
||||||
import { FormControl } from '@@/form-components/FormControl';
|
import { FormControl } from '@@/form-components/FormControl';
|
||||||
|
@ -28,6 +32,25 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SettingsFDO({ settings, onSubmit }: Props) {
|
export function SettingsFDO({ settings, onSubmit }: Props) {
|
||||||
|
const flagEnabledQuery = useFeatureFlag(FeatureFlag.FDO);
|
||||||
|
|
||||||
|
if (!flagEnabledQuery.data) {
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Widget.Body>
|
||||||
|
<TextTip color="blue">
|
||||||
|
Since FDO is still an experimental feature that requires additional
|
||||||
|
infrastructure, it has been temporarily hidden in the UI.
|
||||||
|
</TextTip>
|
||||||
|
</Widget.Body>
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <SettingsFDOForm settings={settings} onSubmit={onSubmit} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SettingsFDOForm({ settings, onSubmit }: Props) {
|
||||||
const fdoConfiguration = settings ? settings.fdoConfiguration : null;
|
const fdoConfiguration = settings ? settings.fdoConfiguration : null;
|
||||||
const initialFDOEnabled = fdoConfiguration ? fdoConfiguration.enabled : false;
|
const initialFDOEnabled = fdoConfiguration ? fdoConfiguration.enabled : false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue