mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
refactor(edge): deprecate IsEdgeDevice [EE-5046] (#8534)
This commit is contained in:
parent
814fc9dfc0
commit
308a78db21
18 changed files with 21 additions and 109 deletions
|
@ -32,11 +32,9 @@ export function EnvironmentTypeTag({
|
|||
|
||||
function getTypeLabel(environment: Environment) {
|
||||
if (isEdgeEnvironment(environment.Type)) {
|
||||
if (environment.Edge.AsyncMode) {
|
||||
return 'Edge Agent Async';
|
||||
}
|
||||
|
||||
return 'Edge Agent Standard';
|
||||
return environment.Edge.AsyncMode
|
||||
? 'Edge Agent Async'
|
||||
: 'Edge Agent Standard';
|
||||
}
|
||||
|
||||
if (isLocalEnvironment(environment)) {
|
||||
|
|
|
@ -108,7 +108,6 @@ export interface EnvironmentOptions {
|
|||
meta?: EnvironmentMetadata;
|
||||
azure?: AzureSettings;
|
||||
tls?: TLSSettings;
|
||||
isEdgeDevice?: boolean;
|
||||
pollFrequency?: number;
|
||||
edge?: EdgeSettings;
|
||||
tunnelServerAddr?: string;
|
||||
|
@ -167,7 +166,6 @@ interface CreateEdgeAgentEnvironment {
|
|||
tunnelServerAddr?: string;
|
||||
meta?: EnvironmentMetadata;
|
||||
pollFrequency: number;
|
||||
isEdgeDevice?: boolean;
|
||||
edge: EdgeSettings;
|
||||
}
|
||||
|
||||
|
@ -175,7 +173,6 @@ export function createEdgeAgentEnvironment({
|
|||
name,
|
||||
portainerUrl,
|
||||
meta = { tagIds: [] },
|
||||
isEdgeDevice,
|
||||
pollFrequency,
|
||||
edge,
|
||||
}: CreateEdgeAgentEnvironment) {
|
||||
|
@ -188,7 +185,6 @@ export function createEdgeAgentEnvironment({
|
|||
skipVerify: true,
|
||||
skipClientVerify: true,
|
||||
},
|
||||
isEdgeDevice,
|
||||
pollFrequency,
|
||||
edge,
|
||||
meta,
|
||||
|
@ -216,7 +212,6 @@ async function createEnvironment(
|
|||
GroupID: groupId,
|
||||
TagIds: arrayToJson(tagIds),
|
||||
CheckinInterval: options.pollFrequency,
|
||||
IsEdgeDevice: options.isEdgeDevice,
|
||||
};
|
||||
|
||||
const { tls, azure } = options;
|
||||
|
|
|
@ -152,7 +152,6 @@ export type Environment = {
|
|||
Kubernetes: KubernetesSettings;
|
||||
Nomad: NomadSettings;
|
||||
PublicURL?: string;
|
||||
IsEdgeDevice?: boolean;
|
||||
UserTrusted: boolean;
|
||||
AMTDeviceGUID?: string;
|
||||
Edge: EnvironmentEdge;
|
||||
|
|
|
@ -10,8 +10,6 @@ import { PageHeader } from '@@/PageHeader';
|
|||
import { Widget, WidgetBody, WidgetTitle } from '@@/Widget';
|
||||
import { FormSection } from '@@/form-components/FormSection';
|
||||
|
||||
import { useCreateEdgeDeviceParam } from '../hooks/useCreateEdgeDeviceParam';
|
||||
|
||||
import { EnvironmentSelector } from './EnvironmentSelector';
|
||||
import {
|
||||
EnvironmentOptionValue,
|
||||
|
@ -20,8 +18,6 @@ import {
|
|||
} from './environment-types';
|
||||
|
||||
export function EnvironmentTypeSelectView() {
|
||||
const createEdgeDevice = useCreateEdgeDeviceParam();
|
||||
|
||||
const [types, setTypes] = useState<EnvironmentOptionValue[]>([]);
|
||||
const { trackEvent } = useAnalytics();
|
||||
const router = useRouter();
|
||||
|
@ -50,14 +46,12 @@ export function EnvironmentTypeSelectView() {
|
|||
<EnvironmentSelector
|
||||
value={types}
|
||||
onChange={setTypes}
|
||||
createEdgeDevice={createEdgeDevice}
|
||||
options={existingEnvironmentTypes}
|
||||
/>
|
||||
<p className="control-label !mb-2">Set up new environments</p>
|
||||
<EnvironmentSelector
|
||||
value={types}
|
||||
onChange={setTypes}
|
||||
createEdgeDevice={createEdgeDevice}
|
||||
options={newEnvironmentTypes}
|
||||
hiddenSpacingCount={
|
||||
existingEnvironmentTypes.length -
|
||||
|
@ -102,7 +96,6 @@ export function EnvironmentTypeSelectView() {
|
|||
|
||||
router.stateService.go('portainer.wizard.endpoints.create', {
|
||||
envType: types,
|
||||
...(createEdgeDevice ? { edgeDevice: createEdgeDevice } : {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,28 +6,18 @@ interface Props {
|
|||
value: EnvironmentOptionValue[];
|
||||
onChange(value: EnvironmentOptionValue[]): void;
|
||||
options: EnvironmentOption[];
|
||||
createEdgeDevice?: boolean;
|
||||
hiddenSpacingCount?: number;
|
||||
}
|
||||
|
||||
const hasEdge: EnvironmentOptionValue[] = [
|
||||
'dockerStandalone',
|
||||
'dockerSwarm',
|
||||
'kubernetes',
|
||||
];
|
||||
|
||||
export function EnvironmentSelector({
|
||||
value,
|
||||
onChange,
|
||||
createEdgeDevice,
|
||||
options,
|
||||
hiddenSpacingCount,
|
||||
}: Props) {
|
||||
const filteredOptions = filterEdgeDevicesIfNeed(options, createEdgeDevice);
|
||||
|
||||
return (
|
||||
<BoxSelector
|
||||
options={filteredOptions}
|
||||
options={options}
|
||||
isMulti
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
|
@ -36,14 +26,3 @@ export function EnvironmentSelector({
|
|||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function filterEdgeDevicesIfNeed(
|
||||
types: EnvironmentOption[],
|
||||
createEdgeDevice?: boolean
|
||||
) {
|
||||
if (!createEdgeDevice) {
|
||||
return [...types];
|
||||
}
|
||||
|
||||
return [...types.filter((eType) => hasEdge.includes(eType.id))];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import { BadgeIcon } from '@@/BadgeIcon';
|
|||
|
||||
import { AnalyticsStateKey } from '../types';
|
||||
import { EdgeAgentTab } from '../shared/EdgeAgentTab';
|
||||
import { useFilterEdgeOptionsIfNeeded } from '../useOnlyEdgeOptions';
|
||||
|
||||
import { AgentTab } from './AgentTab';
|
||||
import { APITab } from './APITab';
|
||||
|
@ -24,7 +23,7 @@ interface Props {
|
|||
isDockerStandalone?: boolean;
|
||||
}
|
||||
|
||||
const defaultOptions: BoxSelectorOption<
|
||||
const options: BoxSelectorOption<
|
||||
'agent' | 'api' | 'socket' | 'edgeAgentStandard' | 'edgeAgentAsync'
|
||||
>[] = _.compact([
|
||||
{
|
||||
|
@ -65,11 +64,6 @@ const defaultOptions: BoxSelectorOption<
|
|||
]);
|
||||
|
||||
export function WizardDocker({ onCreate, isDockerStandalone }: Props) {
|
||||
const options = useFilterEdgeOptionsIfNeeded(
|
||||
defaultOptions,
|
||||
'edgeAgentStandard'
|
||||
);
|
||||
|
||||
const [creationType, setCreationType] = useState(options[0].value);
|
||||
|
||||
const tab = getTab(creationType);
|
||||
|
|
|
@ -15,7 +15,6 @@ import { BEFeatureIndicator } from '@@/BEFeatureIndicator';
|
|||
|
||||
import { AnalyticsStateKey } from '../types';
|
||||
import { EdgeAgentTab } from '../shared/EdgeAgentTab';
|
||||
import { useFilterEdgeOptionsIfNeeded } from '../useOnlyEdgeOptions';
|
||||
|
||||
import { AgentPanel } from './AgentPanel';
|
||||
import { KubeConfigTeaserForm } from './KubeConfigTeaserForm';
|
||||
|
@ -30,7 +29,7 @@ type CreationType =
|
|||
| 'edgeAgentAsync'
|
||||
| 'kubeconfig';
|
||||
|
||||
const defaultOptions: BoxSelectorOption<CreationType>[] = _.compact([
|
||||
const options: BoxSelectorOption<CreationType>[] = _.compact([
|
||||
{
|
||||
id: 'agent_endpoint',
|
||||
icon: Zap,
|
||||
|
@ -67,8 +66,6 @@ const defaultOptions: BoxSelectorOption<CreationType>[] = _.compact([
|
|||
]);
|
||||
|
||||
export function WizardKubernetes({ onCreate }: Props) {
|
||||
const options = useFilterEdgeOptionsIfNeeded(defaultOptions, 'agent');
|
||||
|
||||
const [creationType, setCreationType] = useState(options[0].value);
|
||||
|
||||
const tab = getTab(creationType);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { EnvironmentCreationTypes } from '@/react/portainer/environments/types';
|
||||
|
||||
import { Value, BoxSelectorOption } from '@@/BoxSelector/types';
|
||||
|
||||
import { useCreateEdgeDeviceParam } from '../hooks/useCreateEdgeDeviceParam';
|
||||
|
||||
export function useFilterEdgeOptionsIfNeeded<
|
||||
T extends Value = EnvironmentCreationTypes
|
||||
>(options: BoxSelectorOption<T>[], edgeValue: T) {
|
||||
const createEdgeDevice = useCreateEdgeDeviceParam();
|
||||
|
||||
if (!createEdgeDevice) {
|
||||
return options;
|
||||
}
|
||||
|
||||
return options.filter((option) => option.value === edgeValue);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
import { useCurrentStateAndParams } from '@uirouter/react';
|
||||
|
||||
export function useCreateEdgeDeviceParam() {
|
||||
const {
|
||||
params: { edgeDevice: edgeDeviceParam },
|
||||
} = useCurrentStateAndParams();
|
||||
|
||||
const createEdgeDevice = edgeDeviceParam ? edgeDeviceParam === 'true' : false;
|
||||
|
||||
return createEdgeDevice;
|
||||
}
|
|
@ -19,7 +19,6 @@ export interface SystemInfoResponse {
|
|||
platform: ContainerPlatform;
|
||||
agents: number;
|
||||
edgeAgents: number;
|
||||
edgeDevices: number;
|
||||
}
|
||||
|
||||
async function getSystemInfo() {
|
||||
|
|
|
@ -54,7 +54,6 @@ function UpgradeBEBanner() {
|
|||
nodeCount: nodesCount,
|
||||
platform: systemInfo.platform,
|
||||
edgeAgents: systemInfo.edgeAgents,
|
||||
edgeDevices: systemInfo.edgeDevices,
|
||||
agents: systemInfo.agents,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue