mirror of https://github.com/portainer/portainer
feat(environments): add edge device [EE-4840] (#8246)
* feat(environments): add edge device [EE-4840] fix [EE-4840] * fix(home): fix testspull/6820/head
parent
6c193a8a45
commit
baf9c3db0a
@ -0,0 +1,71 @@
|
||||
import { useRouter } from '@uirouter/react';
|
||||
import { Plus } from 'lucide-react';
|
||||
|
||||
import { promptAsync } from '@/portainer/services/modal.service/prompt';
|
||||
|
||||
import { Button } from '@@/buttons';
|
||||
|
||||
import { usePublicSettings } from '../../queries';
|
||||
|
||||
enum DeployType {
|
||||
FDO = 'FDO',
|
||||
MANUAL = 'MANUAL',
|
||||
}
|
||||
|
||||
export function AddDeviceButton() {
|
||||
const router = useRouter();
|
||||
const isFDOEnabledQuery = usePublicSettings({
|
||||
select: (settings) => settings.IsFDOEnabled,
|
||||
});
|
||||
const isFDOEnabled = !!isFDOEnabledQuery.data;
|
||||
|
||||
return (
|
||||
<Button onClick={handleNewDeviceClick} icon={Plus}>
|
||||
Add Device
|
||||
</Button>
|
||||
);
|
||||
|
||||
async function handleNewDeviceClick() {
|
||||
const result = await getDeployType();
|
||||
|
||||
switch (result) {
|
||||
case DeployType.FDO:
|
||||
router.stateService.go('portainer.endpoints.importDevice');
|
||||
break;
|
||||
case DeployType.MANUAL:
|
||||
router.stateService.go('portainer.wizard.endpoints', {
|
||||
edgeDevice: true,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeployType(): Promise<DeployType> {
|
||||
if (!isFDOEnabled) {
|
||||
return Promise.resolve(DeployType.MANUAL);
|
||||
}
|
||||
|
||||
return promptAsync({
|
||||
title: 'How would you like to add an Edge Device?',
|
||||
inputType: 'radio',
|
||||
inputOptions: [
|
||||
{
|
||||
text: 'Provision bare-metal using Intel FDO',
|
||||
value: DeployType.FDO,
|
||||
},
|
||||
{
|
||||
text: 'Deploy agent manually',
|
||||
value: DeployType.MANUAL,
|
||||
},
|
||||
],
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Confirm',
|
||||
className: 'btn-primary',
|
||||
},
|
||||
},
|
||||
}) as Promise<DeployType>;
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
export interface Settings {
|
||||
EdgeAgentCheckinInterval: number;
|
||||
export interface FormValues {
|
||||
EnableEdgeComputeFeatures: boolean;
|
||||
TrustOnFirstConnect: boolean;
|
||||
EnforceEdgeID: boolean;
|
||||
EdgePortainerUrl: string;
|
||||
EdgeAgentCheckinInterval: number;
|
||||
}
|
||||
|
Loading…
Reference in new issue