diff --git a/pkg/webui/console/containers/gateway-onboarding-form/gateway-provisioning-form/gateway-claim-form-section/index.js b/pkg/webui/console/containers/gateway-onboarding-form/gateway-provisioning-form/gateway-claim-form-section/index.js index d74b312b67..bc1723e9c9 100644 --- a/pkg/webui/console/containers/gateway-onboarding-form/gateway-provisioning-form/gateway-claim-form-section/index.js +++ b/pkg/webui/console/containers/gateway-onboarding-form/gateway-provisioning-form/gateway-claim-form-section/index.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import React, { useCallback, useEffect } from 'react' +import React, { useEffect } from 'react' import { defineMessages } from 'react-intl' import { useFormikContext } from 'formik' @@ -24,10 +24,6 @@ import Notification from '@ttn-lw/components/notification' import SubmitBar from '@ttn-lw/components/submit-bar' import FormSubmit from '@ttn-lw/components/form/submit' import SubmitButton from '@ttn-lw/components/submit-button' -import Link from '@ttn-lw/components/link' -import Tabs from '@ttn-lw/components/tabs' - -import Message from '@ttn-lw/lib/components/message' import { GsFrequencyPlansSelect as FrequencyPlansSelect } from '@console/containers/freq-plans-select' @@ -37,12 +33,10 @@ import tooltipIds from '@ttn-lw/lib/constants/tooltip-ids' import getHostFromUrl from '@ttn-lw/lib/host-from-url' const { enabled: gsEnabled, base_url: gsBaseURL } = selectGsConfig() -const smUrl = 'https://accounts.thethingsindustries.com' const m = defineMessages({ claimWarning: - 'We detected a Managed gateway. To claim this gateway with a subscription, use the owner token printed on the gateway, or add it to your Gateway Fleet using your fleet owner token.', - fleet: 'Fleet', + 'We detected that your gateway is a Managed Gateway. To claim this gateway, please use the owner token printed on the inside of the mounting lid or scan the QR code to claim instantly.', }) const initialValues = { @@ -55,38 +49,10 @@ const initialValues = { target_gateway_server_address: gsEnabled ? getHostFromUrl(gsBaseURL) : '', } -const ownerTokenTypes = [ - { name: 'gateway', title: sharedMessages.gateway }, - { name: 'fleet', title: m.fleet }, -] - const GatewayClaimFormSection = () => { - const { values, addToFieldRegistry, removeFromFieldRegistry, setValues } = useFormikContext() + const { values, addToFieldRegistry, removeFromFieldRegistry } = useFormikContext() const isManaged = values._inputMethod === 'managed' - const isFleet = values._isFleet - - const [activeOwnerTokenType, setActiveOwnerTokenType] = React.useState( - isFleet ? 'fleet' : 'gateway', - ) - - const onOwnerTokenTypeChange = useCallback( - value => { - setActiveOwnerTokenType(value) - setValues(values => ({ - ...values, - authenticated_identifiers: { - ...values.authenticated_identifiers, - authentication_code: - value === 'fleet' && values._fleet_owner_token - ? btoa(values._fleet_owner_token) - : value === 'gateway' && values._gtw_owner_token - ? btoa(values._gtw_owner_token) - : '', - }, - })) - }, - [setValues], - ) + const withQRdata = values._withQRdata // Register hidden fields so they don't get cleaned. useEffect(() => { @@ -98,76 +64,28 @@ const GatewayClaimFormSection = () => { return ( <> {isManaged && ( - <> - - ( - - {val} - - ), - }} - className="mb-0" - /> - - - + {txt}, + }} + className="mb-0" /> - {activeOwnerTokenType === 'fleet' && ( - ( - - {val} - - ), - }} - className="mb-cs-xs c-text-neutral-light" - component="div" - /> - )} - + )} ( - - {val} - - ), - }} encode={btoa} decode={atob} + disabled={withQRdata} sensitive - data-1p-ignore - data-lpignore autoFocus /> schema.concat(registerValidationSchema), diff --git a/pkg/webui/console/containers/gateway-onboarding-form/index.js b/pkg/webui/console/containers/gateway-onboarding-form/index.js index e9a70918a2..68b10662bd 100644 --- a/pkg/webui/console/containers/gateway-onboarding-form/index.js +++ b/pkg/webui/console/containers/gateway-onboarding-form/index.js @@ -150,12 +150,13 @@ const GatewayOnboardingForm = props => { ...message, values: { link: content => ( - {content} - + ), }, } diff --git a/pkg/webui/console/containers/gateway-onboarding-form/qr-scan-section/fleets-scan.js b/pkg/webui/console/containers/gateway-onboarding-form/qr-scan-section/fleets-scan.js deleted file mode 100644 index 024cc2bcff..0000000000 --- a/pkg/webui/console/containers/gateway-onboarding-form/qr-scan-section/fleets-scan.js +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright © 2025 The Things Network Foundation, The Things Industries B.V. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import React, { useCallback } from 'react' -import { defineMessages } from 'react-intl' - -import { IconPlus } from '@ttn-lw/components/icon' -import Link from '@ttn-lw/components/link' -import Button from '@ttn-lw/components/button' -import Input from '@ttn-lw/components/input' - -import Message from '@ttn-lw/lib/components/message' - -import sharedMessages from '@ttn-lw/lib/shared-messages' -import PropTypes from '@ttn-lw/lib/prop-types' - -const smUrl = 'https://accounts.thethingsindustries.com' - -const m = defineMessages({ - addFleet: 'Add to Fleet', - fleetToken: 'Fleet owner token', - addToFleetTooltip: - 'You are registering a Managed gateway. If you want to add it to an existing fleet, click here.', -}) - -const FleetsScan = ({ qrData, setQrData }) => { - const [isAddToFleet, setIsAddToFleet] = React.useState(false) - const [fleetOwnerToken, setFleetOwnerToken] = React.useState('') - - const handleAddToFleet = useCallback(() => { - setIsAddToFleet(true) - }, []) - - const handleRemoveFleet = useCallback(() => { - setIsAddToFleet(false) - setFleetOwnerToken('') - setQrData(prevQrData => ({ - ...prevQrData, - gateway: { ...prevQrData.gateway, _fleet_owner_token: undefined }, - })) - }, [setQrData]) - - const handleFleetTokenChange = useCallback( - value => { - setFleetOwnerToken(value) - setQrData(prevQrData => ({ - ...prevQrData, - gateway: { ...prevQrData.gateway, _fleet_owner_token: value }, - })) - }, - [setQrData], - ) - - return qrData?.gateway?.is_managed ? ( - <> - {isAddToFleet ? ( -
-
- -
- ( - - {val} - - ), - }} - className="mb-cs-xs mt-cs-xxs c-text-neutral-light fs-s" - component="div" - /> - - ( - - {val} - - ), - }} - className="mt-cs-xs c-text-neutral-light fs-s" - component="div" - /> -
- ) : ( -