mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
refactor(edge): move edge deploy script to react [EE-2689] (#6747)
This commit is contained in:
parent
328ce2f995
commit
85a7b7e0fc
38 changed files with 1079 additions and 342 deletions
60
app/edge/components/EdgeScriptForm/EdgeScriptForm.tsx
Normal file
60
app/edge/components/EdgeScriptForm/EdgeScriptForm.tsx
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { useState } from 'react';
|
||||
|
||||
import { useStatus } from '@/portainer/services/api/status.service';
|
||||
import { r2a } from '@/react-tools/react2angular';
|
||||
import { useSettings } from '@/portainer/settings/settings.service';
|
||||
|
||||
import { EdgePropertiesForm } from './EdgePropertiesForm';
|
||||
import { Scripts } from './Scripts';
|
||||
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',
|
||||
platform: 'swarm',
|
||||
});
|
||||
|
||||
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}
|
||||
/>
|
||||
|
||||
<Scripts
|
||||
values={edgeProperties}
|
||||
agentVersion={agentVersion}
|
||||
edgeKey={edgeKey}
|
||||
onPlatformChange={(platform) =>
|
||||
setEdgeProperties({ ...edgeProperties, platform })
|
||||
}
|
||||
edgeId={edgeId}
|
||||
agentSecret={agentSecret}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const EdgeScriptFormAngular = r2a(EdgeScriptForm, ['edgeKey', 'edgeId']);
|
Loading…
Add table
Add a link
Reference in a new issue