diff --git a/app/edge/EdgeDevices/EdgeDevicesView/index.ts b/app/edge/EdgeDevices/EdgeDevicesView/index.ts deleted file mode 100644 index 4151ed27c..000000000 --- a/app/edge/EdgeDevices/EdgeDevicesView/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { EdgeDevicesView } from './EdgeDevicesView'; diff --git a/app/edge/__module.js b/app/edge/__module.js index 62a6d4557..49ceb3ce5 100644 --- a/app/edge/__module.js +++ b/app/edge/__module.js @@ -1,17 +1,11 @@ import angular from 'angular'; -import { withCurrentUser } from '@/react-tools/withCurrentUser'; -import { r2a } from '@/react-tools/react2angular'; -import { withReactQuery } from '@/react-tools/withReactQuery'; -import { withUIRouter } from '@/react-tools/withUIRouter'; import edgeStackModule from './views/edge-stacks'; -import { componentsModule } from './components'; -import { WaitingRoomView } from './EdgeDevices/WaitingRoomView'; import { reactModule } from './react'; angular - .module('portainer.edge', [edgeStackModule, componentsModule, reactModule]) - .component('waitingRoomView', r2a(withUIRouter(withReactQuery(withCurrentUser(WaitingRoomView))), [])) + .module('portainer.edge', [edgeStackModule, reactModule]) + .config(function config($stateRegistryProvider) { const edge = { name: 'edge', diff --git a/app/edge/components/EdgeCheckInIntervalField.tsx b/app/edge/components/EdgeCheckInIntervalField.tsx deleted file mode 100644 index f01f8ba60..000000000 --- a/app/edge/components/EdgeCheckInIntervalField.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { useEffect, useState } from 'react'; - -import { r2a } from '@/react-tools/react2angular'; -import { useSettings } from '@/react/portainer/settings/queries'; -import { withReactQuery } from '@/react-tools/withReactQuery'; - -import { FormControl, Size } from '@@/form-components/FormControl'; -import { Select } from '@@/form-components/Input'; - -interface Props { - value: number; - onChange(value: number): void; - isDefaultHidden?: boolean; - label?: string; - tooltip?: string; - readonly?: boolean; - size?: Size; -} - -export const checkinIntervalOptions = [ - { label: 'Use default interval', value: 0 }, - { - label: '5 seconds', - value: 5, - }, - { - label: '10 seconds', - value: 10, - }, - { - label: '30 seconds', - value: 30, - }, - { label: '5 minutes', value: 300 }, - { label: '1 hour', value: 3600 }, - { label: '1 day', value: 86400 }, -]; - -export function EdgeCheckinIntervalField({ - value, - readonly, - onChange, - isDefaultHidden = false, - label = 'Poll frequency', - tooltip = 'Interval used by this Edge agent to check in with the Portainer instance. Affects Edge environment management and Edge compute features.', - size = 'small', -}: Props) { - const options = useOptions(isDefaultHidden); - - return ( - - { - onChange(parseInt(e.currentTarget.value, 10)); - }} - options={options} - disabled={readonly} - /> - - ); -} - -export const EdgeCheckinIntervalFieldAngular = r2a( - withReactQuery(EdgeCheckinIntervalField), - [ - 'value', - 'onChange', - 'isDefaultHidden', - 'tooltip', - 'label', - 'readonly', - 'size', - ] -); - -function useOptions(isDefaultHidden: boolean) { - const [options, setOptions] = useState(checkinIntervalOptions); - - const settingsQuery = useSettings( - (settings) => settings.EdgeAgentCheckinInterval - ); - - useEffect(() => { - if (isDefaultHidden) { - setOptions(checkinIntervalOptions.filter((option) => option.value !== 0)); - } - - if (!isDefaultHidden && typeof settingsQuery.data !== 'undefined') { - setOptions((options) => { - let label = `${settingsQuery.data} seconds`; - const option = options.find((o) => o.value === settingsQuery.data); - if (option) { - label = option.label; - } - - return [ - { - value: 0, - label: `Use default interval (${label})`, - }, - ...options.slice(1), - ]; - }); - } - }, [settingsQuery.data, setOptions, isDefaultHidden]); - - return options; -} diff --git a/app/edge/components/index.ts b/app/edge/components/index.ts deleted file mode 100644 index 8e2376c6d..000000000 --- a/app/edge/components/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import angular from 'angular'; - -import { r2a } from '@/react-tools/react2angular'; -import { EdgeScriptForm } from '@/react/edge/components/EdgeScriptForm'; -import { withReactQuery } from '@/react-tools/withReactQuery'; - -import { EdgeCheckinIntervalFieldAngular } from './EdgeCheckInIntervalField'; - -export const componentsModule = angular - .module('app.edge.components', []) - .component( - 'edgeScriptForm', - r2a(withReactQuery(EdgeScriptForm), [ - 'edgeInfo', - 'commands', - 'isNomadTokenVisible', - ]) - ) - .component('edgeCheckinIntervalField', EdgeCheckinIntervalFieldAngular).name; diff --git a/app/edge/react/components/index.ts b/app/edge/react/components/index.ts index 27c210103..4e8ad5d49 100644 --- a/app/edge/react/components/index.ts +++ b/app/edge/react/components/index.ts @@ -1,11 +1,46 @@ import angular from 'angular'; -import { EdgeGroupsSelector } from '@/react/edge/components/EdgeGroupsSelector'; +import { EdgeGroupsSelector } from '@/react/edge/edge-stacks/components/EdgeGroupsSelector'; import { r2a } from '@/react-tools/react2angular'; +import { withReactQuery } from '@/react-tools/withReactQuery'; +import { EdgeCheckinIntervalField } from '@/react/edge/components/EdgeCheckInIntervalField'; +import { EdgeScriptForm } from '@/react/edge/components/EdgeScriptForm'; +import { EdgeAsyncIntervalsForm } from '@/react/edge/components/EdgeAsyncIntervalsForm'; export const componentsModule = angular .module('portainer.edge.react.components', []) .component( 'edgeGroupsSelector', r2a(EdgeGroupsSelector, ['items', 'onChange', 'value']) + ) + .component( + 'edgeScriptForm', + r2a(withReactQuery(EdgeScriptForm), [ + 'edgeInfo', + 'commands', + 'isNomadTokenVisible', + 'hideAsyncMode', + ]) + ) + .component( + 'edgeCheckinIntervalField', + r2a(withReactQuery(EdgeCheckinIntervalField), [ + 'value', + 'onChange', + 'isDefaultHidden', + 'tooltip', + 'label', + 'readonly', + 'size', + ]) + ) + .component( + 'edgeAsyncIntervalsForm', + r2a(withReactQuery(EdgeAsyncIntervalsForm), [ + 'values', + 'onChange', + 'isDefaultHidden', + 'readonly', + 'fieldSettings', + ]) ).name; diff --git a/app/edge/react/views/index.ts b/app/edge/react/views/index.ts index 2a0f22c21..c7175f189 100644 --- a/app/edge/react/views/index.ts +++ b/app/edge/react/views/index.ts @@ -1,14 +1,19 @@ import angular from 'angular'; -import { EdgeDevicesView } from '@/edge/EdgeDevices/EdgeDevicesView'; -import { withCurrentUser } from '@/react-tools/withCurrentUser'; import { r2a } from '@/react-tools/react2angular'; +import { ListView } from '@/react/edge/edge-devices/ListView'; +import { withCurrentUser } from '@/react-tools/withCurrentUser'; import { withReactQuery } from '@/react-tools/withReactQuery'; import { withUIRouter } from '@/react-tools/withUIRouter'; +import { WaitingRoomView } from '@/react/edge/edge-devices/WaitingRoomView'; export const viewsModule = angular .module('portainer.edge.react.views', []) + .component( + 'waitingRoomView', + r2a(withUIRouter(withReactQuery(withCurrentUser(WaitingRoomView))), []) + ) .component( 'edgeDevicesView', - r2a(withUIRouter(withReactQuery(withCurrentUser(EdgeDevicesView))), []) + r2a(withUIRouter(withReactQuery(withCurrentUser(ListView))), []) ).name; diff --git a/app/react/edge/.keep b/app/react/edge/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/edge/components/EdgeAsyncIntervalsForm.tsx b/app/react/edge/components/EdgeAsyncIntervalsForm.tsx similarity index 94% rename from app/edge/components/EdgeAsyncIntervalsForm.tsx rename to app/react/edge/components/EdgeAsyncIntervalsForm.tsx index f36ccd9ec..a20ef8615 100644 --- a/app/edge/components/EdgeAsyncIntervalsForm.tsx +++ b/app/react/edge/components/EdgeAsyncIntervalsForm.tsx @@ -1,7 +1,5 @@ import { number, object, SchemaOf } from 'yup'; -import { r2a } from '@/react-tools/react2angular'; - import { FormControl } from '@@/form-components/FormControl'; import { Select } from '@@/form-components/Input'; @@ -153,11 +151,3 @@ export function edgeAsyncIntervalsValidation(): SchemaOf + { + onChange(parseInt(e.currentTarget.value, 10)); + }} + options={options} + disabled={readonly} + /> + + ); +} diff --git a/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.tsx b/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.tsx index d5d91c9db..f4c52e190 100644 --- a/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.tsx +++ b/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.tsx @@ -14,18 +14,21 @@ const edgePropertiesFormInitialValues: ScriptFormValues = { platform: 'k8s' as Platform, nomadToken: '', authEnabled: true, + tlsEnabled: false, }; interface Props { edgeInfo: EdgeInfo; commands: CommandTab[] | Partial>; isNomadTokenVisible?: boolean; + hideAsyncMode?: boolean; } export function EdgeScriptForm({ edgeInfo, commands, isNomadTokenVisible, + hideAsyncMode, }: Props) { const showOsSelector = !(commands instanceof Array); @@ -60,6 +63,7 @@ export function EdgeScriptForm({ onPlatformChange={(platform) => setFieldValue('platform', platform) } + hideAsyncMode={hideAsyncMode} /> > diff --git a/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.validation.tsx b/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.validation.tsx index 69be18263..b67158842 100644 --- a/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.validation.tsx +++ b/app/react/edge/components/EdgeScriptForm/EdgeScriptForm.validation.tsx @@ -6,6 +6,17 @@ export function validationSchema(isNomadTokenVisible?: boolean) { return object().shape({ allowSelfSignedCertificates: boolean(), envVars: string(), - ...(isNomadTokenVisible ? nomadTokenValidation() : {}), + ...nomadValidation(isNomadTokenVisible), }); } + +function nomadValidation(isNomadTokenVisible?: boolean) { + if (!isNomadTokenVisible) { + return {}; + } + + return { + tlsEnabled: boolean().default(false), + ...nomadTokenValidation(), + }; +} diff --git a/app/react/edge/components/EdgeScriptForm/EdgeScriptSettingsFieldset.tsx b/app/react/edge/components/EdgeScriptForm/EdgeScriptSettingsFieldset.tsx index aaf369029..ceee5c746 100644 --- a/app/react/edge/components/EdgeScriptForm/EdgeScriptSettingsFieldset.tsx +++ b/app/react/edge/components/EdgeScriptForm/EdgeScriptSettingsFieldset.tsx @@ -1,4 +1,4 @@ -import { Field, useFormikContext } from 'formik'; +import { useFormikContext, Field } from 'formik'; import { FormControl } from '@@/form-components/FormControl'; import { Input } from '@@/form-components/Input'; @@ -47,7 +47,22 @@ export function EdgeScriptSettingsFieldset({ > )} - {isNomadTokenVisible && } + {isNomadTokenVisible && ( + <> + + + + + setFieldValue('tlsEnabled', checked)} + /> + + + > + )} {}, }: Props) { const agentDetails = useAgentDetails(); @@ -38,10 +40,17 @@ export function ScriptTabs({ return null; } - const { agentSecret, agentVersion } = agentDetails; + const { agentSecret, agentVersion, useEdgeAsyncMode } = agentDetails; const options = commands.map((c) => { - const cmd = c.command(agentVersion, edgeKey, values, edgeId, agentSecret); + const cmd = c.command( + agentVersion, + edgeKey, + values, + !hideAsyncMode && useEdgeAsyncMode, + edgeId, + agentSecret + ); return { id: c.id, diff --git a/app/react/edge/components/EdgeScriptForm/scripts.ts b/app/react/edge/components/EdgeScriptForm/scripts.ts index 7a74693ef..159aca5dc 100644 --- a/app/react/edge/components/EdgeScriptForm/scripts.ts +++ b/app/react/edge/components/EdgeScriptForm/scripts.ts @@ -8,6 +8,7 @@ type CommandGenerator = ( agentVersion: string, edgeKey: string, properties: ScriptFormValues, + useAsyncMode: boolean, edgeId?: string, agentSecret?: string ) => string; @@ -34,6 +35,11 @@ export const commandsTabs: Record = { label: 'Docker Standalone', command: buildLinuxStandaloneCommand, }, + nomadLinux: { + id: 'nomad', + label: 'Nomad', + command: buildLinuxNomadCommand, + }, swarmWindows: { id: 'swarm', label: 'Docker Swarm', @@ -58,6 +64,7 @@ export function buildLinuxStandaloneCommand( agentVersion: string, edgeKey: string, properties: ScriptFormValues, + useAsyncMode: boolean, edgeId?: string, agentSecret?: string ) { @@ -69,7 +76,8 @@ export function buildLinuxStandaloneCommand( edgeKey, allowSelfSignedCertificates, !edgeIdGenerator ? edgeId : undefined, - agentSecret + agentSecret, + useAsyncMode ) ); @@ -92,6 +100,7 @@ export function buildWindowsStandaloneCommand( agentVersion: string, edgeKey: string, properties: ScriptFormValues, + useAsyncMode: boolean, edgeId?: string, agentSecret?: string ) { @@ -103,7 +112,8 @@ export function buildWindowsStandaloneCommand( edgeKey, allowSelfSignedCertificates, edgeIdGenerator ? '$Env:PORTAINER_EDGE_ID' : edgeId, - agentSecret + agentSecret, + useAsyncMode ) ); @@ -127,6 +137,7 @@ export function buildLinuxSwarmCommand( agentVersion: string, edgeKey: string, properties: ScriptFormValues, + useAsyncMode: boolean, edgeId?: string, agentSecret?: string ) { @@ -137,7 +148,8 @@ export function buildLinuxSwarmCommand( edgeKey, allowSelfSignedCertificates, !edgeIdGenerator ? edgeId : undefined, - agentSecret + agentSecret, + useAsyncMode ), 'AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent', ]); @@ -167,6 +179,7 @@ export function buildWindowsSwarmCommand( agentVersion: string, edgeKey: string, properties: ScriptFormValues, + useAsyncMode: boolean, edgeId?: string, agentSecret?: string ) { @@ -177,7 +190,8 @@ export function buildWindowsSwarmCommand( edgeKey, allowSelfSignedCertificates, edgeIdGenerator ? '$Env:PORTAINER_EDGE_ID' : edgeId, - agentSecret + agentSecret, + useAsyncMode ), 'AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent', ]); @@ -208,13 +222,17 @@ export function buildLinuxKubernetesCommand( agentVersion: string, edgeKey: string, properties: ScriptFormValues, + useAsyncMode: boolean, edgeId?: string, agentSecret?: string ) { const { allowSelfSignedCertificates, edgeIdGenerator, envVars } = properties; const agentShortVersion = getAgentShortVersion(agentVersion); - const envVarsTrimmed = envVars.trim(); + let envVarsTrimmed = envVars.trim(); + if (useAsyncMode) { + envVarsTrimmed += `EDGE_ASYNC=1`; + } const idEnvVar = edgeIdGenerator ? `PORTAINER_EDGE_ID=$(${edgeIdGenerator}) \n\n` : ''; @@ -224,11 +242,43 @@ export function buildLinuxKubernetesCommand( return `${idEnvVar}curl https://downloads.portainer.io/ee${agentShortVersion}/portainer-edge-agent-setup.sh | bash -s -- "${edgeIdVar}" "${edgeKey}" "${selfSigned}" "${agentSecret}" "${envVarsTrimmed}"`; } +export function buildLinuxNomadCommand( + agentVersion: string, + edgeKey: string, + properties: ScriptFormValues, + useAsyncMode: boolean, + edgeId?: string, + agentSecret?: string +) { + const { + allowSelfSignedCertificates, + edgeIdGenerator, + envVars, + nomadToken = '', + tlsEnabled, + } = properties; + + const agentShortVersion = getAgentShortVersion(agentVersion); + let envVarsTrimmed = envVars.trim(); + if (useAsyncMode) { + envVarsTrimmed += `EDGE_ASYNC=1`; + } + + const selfSigned = allowSelfSignedCertificates ? '1' : '0'; + const idEnvVar = edgeIdGenerator + ? `PORTAINER_EDGE_ID=$(${edgeIdGenerator}) \n\n` + : ''; + const edgeIdVar = !edgeIdGenerator && edgeId ? edgeId : '$PORTAINER_EDGE_ID'; + + return `${idEnvVar}curl https://downloads.portainer.io/ee${agentShortVersion}/portainer-edge-agent-nomad-setup.sh | bash -s -- "${nomadToken}" "${edgeIdVar}" "${edgeKey}" "${selfSigned}" "${envVarsTrimmed}" "${agentSecret}" "${tlsEnabled}"`; +} + function buildDefaultEnvVars( edgeKey: string, allowSelfSignedCerts: boolean, edgeId = '$PORTAINER_EDGE_ID', - agentSecret = '' + agentSecret = '', + useAsyncMode = false ) { return _.compact([ 'EDGE=1', @@ -236,5 +286,6 @@ function buildDefaultEnvVars( `EDGE_KEY=${edgeKey}`, `EDGE_INSECURE_POLL=${allowSelfSignedCerts ? 1 : 0}`, agentSecret ? `AGENT_SECRET=${agentSecret}` : ``, + useAsyncMode ? 'EDGE_ASYNC=1' : '', ]); } diff --git a/app/react/edge/components/EdgeScriptForm/types.ts b/app/react/edge/components/EdgeScriptForm/types.ts index 1f2e6801e..2d6817922 100644 --- a/app/react/edge/components/EdgeScriptForm/types.ts +++ b/app/react/edge/components/EdgeScriptForm/types.ts @@ -4,6 +4,7 @@ export type OS = 'win' | 'linux'; export interface ScriptFormValues { nomadToken: string; authEnabled: boolean; + tlsEnabled: boolean; allowSelfSignedCertificates: boolean; envVars: string; diff --git a/app/edge/components/useIntervalOptions.ts b/app/react/edge/components/useIntervalOptions.ts similarity index 100% rename from app/edge/components/useIntervalOptions.ts rename to app/react/edge/components/useIntervalOptions.ts diff --git a/app/react/edge/edge-devices/.keep b/app/react/edge/edge-devices/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/react/edge/edge-devices/ListView/.keep b/app/react/edge/edge-devices/ListView/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/AMTDevicesDatatable.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/AMTDevicesDatatable.tsx similarity index 93% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/AMTDevicesDatatable.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/AMTDevicesDatatable.tsx index 1dda53530..b8b930f45 100644 --- a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/AMTDevicesDatatable.tsx +++ b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/AMTDevicesDatatable.tsx @@ -1,14 +1,14 @@ import { usePagination, useTable } from 'react-table'; import { Device } from '@/portainer/hostmanagement/open-amt/model'; -import { useAMTDevices } from '@/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/useAMTDevices'; -import { RowProvider } from '@/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/RowContext'; import { EnvironmentId } from '@/react/portainer/environments/types'; import PortainerError from '@/portainer/error'; import { InnerDatatable } from '@@/datatables/InnerDatatable'; import { Table, TableContainer, TableHeaderRow, TableRow } from '@@/datatables'; +import { useAMTDevices } from './useAMTDevices'; +import { RowProvider } from './columns/RowContext'; import { useColumns } from './columns'; export interface AMTDevicesTableProps { diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/RowContext.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/RowContext.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/RowContext.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/RowContext.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/actions.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/actions.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/actions.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/actions.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/hostname.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/hostname.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/hostname.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/hostname.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/index.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/index.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/index.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/index.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/power-state.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/power-state.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/power-state.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/power-state.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/status.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/status.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/columns/status.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/columns/status.tsx diff --git a/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/index.ts b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/index.ts new file mode 100644 index 000000000..55d7b82db --- /dev/null +++ b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/index.ts @@ -0,0 +1 @@ +export { AMTDevicesDatatable } from './AMTDevicesDatatable'; diff --git a/app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/useAMTDevices.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/useAMTDevices.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/useAMTDevices.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/AMTDevicesDatatable/useAMTDevices.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatable.module.css b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatable.module.css similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatable.module.css rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatable.module.css diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx similarity index 98% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx index f74678db3..689e8ecae 100644 --- a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx +++ b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx @@ -3,7 +3,6 @@ import { useRowSelectColumn } from '@lineup-lite/hooks'; import _ from 'lodash'; import { Environment } from '@/react/portainer/environments/types'; -import { AMTDevicesDatatable } from '@/edge/EdgeDevices/EdgeDevicesView/AMTDevicesDatatable/AMTDevicesDatatable'; import { EnvironmentGroup } from '@/react/portainer/environments/environment-groups/types'; import { PaginationControls } from '@@/PaginationControls'; @@ -26,6 +25,7 @@ import { TableFooter } from '@@/datatables/TableFooter'; import { SelectedRowsCount } from '@@/datatables/SelectedRowsCount'; import { TextTip } from '@@/Tip/TextTip'; +import { AMTDevicesDatatable } from './AMTDevicesDatatable'; import { EdgeDevicesDatatableActions } from './EdgeDevicesDatatableActions'; import { EdgeDevicesDatatableSettings } from './EdgeDevicesDatatableSettings'; import { RowProvider } from './columns/RowContext'; diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatableActions.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatableActions.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatableActions.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatableActions.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatableContainer.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatableContainer.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatableContainer.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatableContainer.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatableSettings.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatableSettings.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/EdgeDevicesDatatableSettings.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/EdgeDevicesDatatableSettings.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/RowContext.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/RowContext.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/RowContext.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/RowContext.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/actions.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/actions.tsx similarity index 72% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/actions.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/actions.tsx index 1fd236324..01eaf1c74 100644 --- a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/actions.tsx +++ b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/actions.tsx @@ -5,7 +5,7 @@ import { useRouter, useSref } from '@uirouter/react'; import { Environment } from '@/react/portainer/environments/types'; import { snapshotEndpoint } from '@/react/portainer/environments/environment.service'; import * as notifications from '@/portainer/services/notifications'; -import { getRoute } from '@/react/portainer/environments/utils'; +import { getDashboardRoute } from '@/react/portainer/environments/utils'; import { ActionsMenu } from '@@/datatables/ActionsMenu'; @@ -27,19 +27,33 @@ export function ActionsCell({ }: CellProps) { const router = useRouter(); - const environmentRoute = getRoute(environment); + const environmentRoute = getDashboardRoute(environment); const browseLinkProps = useSref(environmentRoute, { id: environment.Id, endpointId: environment.Id, }); + const snapshotLinkProps = useSref('edge.browse.dashboard', { + environmentId: environment.Id, + }); + const showRefreshSnapshot = false; // remove and show MenuItem when feature is available return ( - - Browse - + {environment.Edge.AsyncMode ? ( + + Browse Snapshot + + ) : ( + + Browse + + )} {showRefreshSnapshot && ( handleRefreshSnapshotClick()}> Refresh Snapshot diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/group.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/group.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/group.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/group.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/heartbeat.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/heartbeat.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/heartbeat.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/heartbeat.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/index.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/index.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/index.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/index.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/name.tsx b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/name.tsx similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/columns/name.tsx rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/columns/name.tsx diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/types.ts b/app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/types.ts similarity index 100% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesDatatable/types.ts rename to app/react/edge/edge-devices/ListView/EdgeDevicesDatatable/types.ts diff --git a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesView.tsx b/app/react/edge/edge-devices/ListView/ListView.tsx similarity index 97% rename from app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesView.tsx rename to app/react/edge/edge-devices/ListView/ListView.tsx index 8a71da7b2..722a010d7 100644 --- a/app/edge/EdgeDevices/EdgeDevicesView/EdgeDevicesView.tsx +++ b/app/react/edge/edge-devices/ListView/ListView.tsx @@ -8,7 +8,7 @@ import { ViewLoading } from '@@/ViewLoading'; import { EdgeDevicesDatatableContainer } from './EdgeDevicesDatatable/EdgeDevicesDatatableContainer'; -export function EdgeDevicesView() { +export function ListView() { const [loadingMessage, setLoadingMessage] = useState(''); const settingsQuery = useSettings(); diff --git a/app/react/edge/edge-devices/ListView/index.ts b/app/react/edge/edge-devices/ListView/index.ts new file mode 100644 index 000000000..dd06dfd19 --- /dev/null +++ b/app/react/edge/edge-devices/ListView/index.ts @@ -0,0 +1 @@ +export { ListView } from './ListView'; diff --git a/app/react/edge/edge-devices/WaitingRoomView/.keep b/app/react/edge/edge-devices/WaitingRoomView/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/edge/EdgeDevices/WaitingRoomView/Datatable/Datatable.tsx b/app/react/edge/edge-devices/WaitingRoomView/Datatable/Datatable.tsx similarity index 100% rename from app/edge/EdgeDevices/WaitingRoomView/Datatable/Datatable.tsx rename to app/react/edge/edge-devices/WaitingRoomView/Datatable/Datatable.tsx diff --git a/app/edge/EdgeDevices/WaitingRoomView/Datatable/types.ts b/app/react/edge/edge-devices/WaitingRoomView/Datatable/types.ts similarity index 100% rename from app/edge/EdgeDevices/WaitingRoomView/Datatable/types.ts rename to app/react/edge/edge-devices/WaitingRoomView/Datatable/types.ts diff --git a/app/edge/EdgeDevices/WaitingRoomView/WaitingRoomView.tsx b/app/react/edge/edge-devices/WaitingRoomView/WaitingRoomView.tsx similarity index 100% rename from app/edge/EdgeDevices/WaitingRoomView/WaitingRoomView.tsx rename to app/react/edge/edge-devices/WaitingRoomView/WaitingRoomView.tsx diff --git a/app/edge/EdgeDevices/WaitingRoomView/index.ts b/app/react/edge/edge-devices/WaitingRoomView/index.ts similarity index 100% rename from app/edge/EdgeDevices/WaitingRoomView/index.ts rename to app/react/edge/edge-devices/WaitingRoomView/index.ts diff --git a/app/edge/EdgeDevices/WaitingRoomView/queries.ts b/app/react/edge/edge-devices/WaitingRoomView/queries.ts similarity index 100% rename from app/edge/EdgeDevices/WaitingRoomView/queries.ts rename to app/react/edge/edge-devices/WaitingRoomView/queries.ts diff --git a/app/react/edge/components/EdgeGroupsSelector.tsx b/app/react/edge/edge-stacks/components/EdgeGroupsSelector.tsx similarity index 92% rename from app/react/edge/components/EdgeGroupsSelector.tsx rename to app/react/edge/edge-stacks/components/EdgeGroupsSelector.tsx index 9e7a47820..5f1147822 100644 --- a/app/react/edge/components/EdgeGroupsSelector.tsx +++ b/app/react/edge/edge-stacks/components/EdgeGroupsSelector.tsx @@ -1,8 +1,8 @@ import _ from 'lodash'; -import { Select } from '@@/form-components/ReactSelect'; +import { EdgeGroup } from '@/react/edge/edge-groups/types'; -import { EdgeGroup } from '../edge-groups/types'; +import { Select } from '@@/form-components/ReactSelect'; type SingleValue = EdgeGroup['Id']; diff --git a/app/react/portainer/environments/queries/useAgentDetails.ts b/app/react/portainer/environments/queries/useAgentDetails.ts index 98f03a2eb..bdcd95d0f 100644 --- a/app/react/portainer/environments/queries/useAgentDetails.ts +++ b/app/react/portainer/environments/queries/useAgentDetails.ts @@ -2,7 +2,7 @@ import { useStatus } from '@/portainer/services/api/status.service'; import { useSettings } from '@/react/portainer/settings/queries'; export function useAgentDetails() { - const settingsQuery = useSettings((settings) => settings.AgentSecret); + const settingsQuery = useSettings(); const versionQuery = useStatus((status) => status.Version); @@ -11,7 +11,10 @@ export function useAgentDetails() { } const agentVersion = versionQuery.data; - const agentSecret = settingsQuery.data; - return { agentVersion, agentSecret }; + return { + agentVersion, + agentSecret: settingsQuery.data.AgentSecret, + useEdgeAsyncMode: settingsQuery.data.Edge.AsyncMode, + }; } diff --git a/app/react/portainer/environments/utils/index.ts b/app/react/portainer/environments/utils/index.ts index d1513aa50..c0eaf5bff 100644 --- a/app/react/portainer/environments/utils/index.ts +++ b/app/react/portainer/environments/utils/index.ts @@ -55,7 +55,7 @@ export function isUnassociatedEdgeEnvironment(env: Environment) { return isEdgeEnvironment(env.Type) && !env.EdgeID; } -export function getRoute(environment: Environment) { +export function getDashboardRoute(environment: Environment) { if (isEdgeEnvironment(environment.Type) && !environment.EdgeID) { return 'portainer.endpoints.endpoint'; } diff --git a/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/EdgeAgentTab/EdgeAgentForm/EdgeAgentForm.tsx b/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/EdgeAgentTab/EdgeAgentForm/EdgeAgentForm.tsx index fd3e686ff..396cc9b3d 100644 --- a/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/EdgeAgentTab/EdgeAgentForm/EdgeAgentForm.tsx +++ b/app/react/portainer/environments/wizard/EnvironmentsCreationView/shared/EdgeAgentTab/EdgeAgentForm/EdgeAgentForm.tsx @@ -3,7 +3,7 @@ import { Formik, Form } from 'formik'; import { Environment } from '@/react/portainer/environments/types'; import { useCreateEdgeAgentEnvironmentMutation } from '@/react/portainer/environments/queries/useCreateEnvironmentMutation'; import { baseHref } from '@/portainer/helpers/pathHelper'; -import { EdgeCheckinIntervalField } from '@/edge/components/EdgeCheckInIntervalField'; +import { EdgeCheckinIntervalField } from '@/react/edge/components/EdgeCheckInIntervalField'; import { useCreateEdgeDeviceParam } from '@/react/portainer/environments/wizard/hooks/useCreateEdgeDeviceParam'; import { FormSection } from '@@/form-components/FormSection'; diff --git a/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/DeploymentSyncOptions.tsx b/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/DeploymentSyncOptions.tsx index ac7e959f2..127d8422b 100644 --- a/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/DeploymentSyncOptions.tsx +++ b/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/DeploymentSyncOptions.tsx @@ -1,8 +1,8 @@ import { Form, Formik } from 'formik'; import { useReducer } from 'react'; -import { EdgeCheckinIntervalField } from '@/edge/components/EdgeCheckInIntervalField'; -import { EdgeAsyncIntervalsForm } from '@/edge/components/EdgeAsyncIntervalsForm'; +import { EdgeCheckinIntervalField } from '@/react/edge/components/EdgeCheckInIntervalField'; +import { EdgeAsyncIntervalsForm } from '@/react/edge/components/EdgeAsyncIntervalsForm'; import { notifySuccess } from '@/portainer/services/notifications'; import { FormControl } from '@@/form-components/FormControl'; diff --git a/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/validation.ts b/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/validation.ts index 02b0c3a86..d5d863659 100644 --- a/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/validation.ts +++ b/app/react/portainer/settings/EdgeComputeView/DeploymentSyncOptions/validation.ts @@ -1,6 +1,6 @@ import { boolean, number, object, SchemaOf } from 'yup'; -import { options as asyncIntervalOptions } from '@/edge/components/EdgeAsyncIntervalsForm'; +import { options as asyncIntervalOptions } from '@/react/edge/components/EdgeAsyncIntervalsForm'; import { FormValues } from './types'; diff --git a/app/react/portainer/settings/EdgeComputeView/EdgeComputeSettings/EdgeComputeSettings.tsx b/app/react/portainer/settings/EdgeComputeView/EdgeComputeSettings/EdgeComputeSettings.tsx index b021f73c6..afbb71c28 100644 --- a/app/react/portainer/settings/EdgeComputeView/EdgeComputeSettings/EdgeComputeSettings.tsx +++ b/app/react/portainer/settings/EdgeComputeView/EdgeComputeSettings/EdgeComputeSettings.tsx @@ -1,6 +1,6 @@ import { Formik, Form } from 'formik'; -import { EdgeCheckinIntervalField } from '@/edge/components/EdgeCheckInIntervalField'; +import { EdgeCheckinIntervalField } from '@/react/edge/components/EdgeCheckInIntervalField'; import { Switch } from '@@/form-components/SwitchField/Switch'; import { FormControl } from '@@/form-components/FormControl';