2022-04-14 10:14:23 +00:00
|
|
|
import { useState } from 'react';
|
|
|
|
|
|
|
|
import { useStatus } from '@/portainer/services/api/status.service';
|
|
|
|
import { r2a } from '@/react-tools/react2angular';
|
2022-05-23 07:57:22 +00:00
|
|
|
import { useSettings } from '@/portainer/settings/queries';
|
2022-04-14 10:14:23 +00:00
|
|
|
|
|
|
|
import { EdgePropertiesForm } from './EdgePropertiesForm';
|
2022-04-28 21:44:34 +00:00
|
|
|
import { ScriptTabs } from './ScriptTabs';
|
2022-04-14 10:14:23 +00:00
|
|
|
import { EdgeProperties } from './types';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
edgeKey: string;
|
|
|
|
edgeId?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function EdgeScriptForm({ edgeKey, edgeId }: Props) {
|
|
|
|
const [edgeProperties, setEdgeProperties] = useState<EdgeProperties>({
|
|
|
|
allowSelfSignedCertificates: true,
|
|
|
|
envVars: '',
|
|
|
|
edgeIdGenerator: '',
|
|
|
|
os: 'linux',
|
2022-04-17 03:04:04 +00:00
|
|
|
platform: 'k8s',
|
2022-04-14 10:14:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const settingsQuery = useSettings((settings) => settings.AgentSecret);
|
|
|
|
|
|
|
|
const versionQuery = useStatus((status) => status.Version);
|
|
|
|
|
|
|
|
if (!versionQuery.data) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const agentVersion = versionQuery.data;
|
|
|
|
const agentSecret = settingsQuery.data;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<EdgePropertiesForm
|
|
|
|
setFieldValue={(key, value) =>
|
|
|
|
setEdgeProperties({ ...edgeProperties, [key]: value })
|
|
|
|
}
|
|
|
|
values={edgeProperties}
|
|
|
|
hideIdGetter={edgeId !== undefined}
|
|
|
|
/>
|
|
|
|
|
2022-04-28 21:44:34 +00:00
|
|
|
<ScriptTabs
|
2022-04-14 10:14:23 +00:00
|
|
|
values={edgeProperties}
|
|
|
|
agentVersion={agentVersion}
|
|
|
|
edgeKey={edgeKey}
|
|
|
|
onPlatformChange={(platform) =>
|
|
|
|
setEdgeProperties({ ...edgeProperties, platform })
|
|
|
|
}
|
|
|
|
edgeId={edgeId}
|
|
|
|
agentSecret={agentSecret}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const EdgeScriptFormAngular = r2a(EdgeScriptForm, ['edgeKey', 'edgeId']);
|