From 85c31301fe98e6c0ec2df6421c1ab008368234fe Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:25:08 -0700 Subject: [PATCH 1/9] feat(api): add account deletion mutations and owned-devices query --- frontend/src/services/graphQL.ts | 12 ++++++++++++ frontend/src/services/graphQLDevice.ts | 18 ++++++++++++++++++ frontend/src/services/graphQLMutation.ts | 15 ++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/frontend/src/services/graphQL.ts b/frontend/src/services/graphQL.ts index f782f31f4..575733724 100644 --- a/frontend/src/services/graphQL.ts +++ b/frontend/src/services/graphQL.ts @@ -21,6 +21,18 @@ export async function graphQLPartialRequest(query: String, variables: ILookup = {}): Promise { + const response = await post({ query, variables }) + if (response === 'ERROR') return { ok: false } + const errors = graphQLGetErrors(response, true) + if (!errors) return { ok: true } + const { message, extensions } = errors[0] as Error & { extensions?: { code?: string; args?: unknown } } + const args = extensions?.args + return { ok: false, code: extensions?.code, message: Array.isArray(args) ? args.join(' ') : message } +} + export function graphQLGetErrors( response: AxiosResponse, silent?: boolean, diff --git a/frontend/src/services/graphQLDevice.ts b/frontend/src/services/graphQLDevice.ts index cbf94433e..6cb4aaf57 100644 --- a/frontend/src/services/graphQLDevice.ts +++ b/frontend/src/services/graphQLDevice.ts @@ -312,6 +312,24 @@ export async function graphQLFetchDeviceCount({ size, tag, owner, accountId }: g ) } +export async function graphQLFetchOwnedDevices(accountId: string, thisId?: string) { + return await graphQLBasicRequest( + ` query OwnedDevices($accountId: String, $size: Int${thisId ? ', $thisId: [String!]!' : ''}) { + login { + id + account(id: $accountId) { + devices(owner: true, size: $size) { + total + items { id name state platform } + } + } + ${thisId ? 'device(id: $thisId) { id owner { id } }' : ''} + } + }`, + { accountId, size: 100, thisId: thisId ? [thisId] : undefined } + ) +} + export function graphQLDeviceAdaptor({ gqlDevices, accountId, diff --git a/frontend/src/services/graphQLMutation.ts b/frontend/src/services/graphQLMutation.ts index 23f645ae2..9436a281d 100644 --- a/frontend/src/services/graphQLMutation.ts +++ b/frontend/src/services/graphQLMutation.ts @@ -1,5 +1,5 @@ import { addConnectionProps } from '../models/networks' -import { graphQLBasicRequest } from './graphQL' +import { graphQLBasicRequest, graphQLInlineRequest } from './graphQL' export async function graphQLSetAttributes(attributes: ILookup, serviceId?: String) { return await graphQLBasicRequest( @@ -748,6 +748,19 @@ export async function graphQLAdminUpdateEmail(from: string, to: string) { ) } +export async function graphQLRequestAccountDeletion() { + return await graphQLInlineRequest(` mutation { requestAccountDeletion }`) +} + +export async function graphQLDeleteAccount(code: string) { + return await graphQLInlineRequest( + ` mutation DeleteAccount($code: String!) { + deleteAccount(code: $code) + }`, + { code } + ) +} + export async function graphQLAdminDeleteUser(id: string, force: boolean = false) { return await graphQLBasicRequest( ` mutation AdminDeleteUser($id: String!, $force: Boolean) { From f00e6c694dbe8baa690bd1812b44586a2744d4e1 Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:25:08 -0700 Subject: [PATCH 2/9] feat(backend): unregister this device and wait for the agent to confirm --- frontend/src/models/backend.test.ts | 52 +++++++++++++++++++++++++++++ frontend/src/models/backend.ts | 15 ++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 frontend/src/models/backend.test.ts diff --git a/frontend/src/models/backend.test.ts b/frontend/src/models/backend.test.ts new file mode 100644 index 000000000..772b40c83 --- /dev/null +++ b/frontend/src/models/backend.test.ts @@ -0,0 +1,52 @@ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' + +const { emit } = vi.hoisted(() => ({ emit: vi.fn() })) +vi.mock('../services/Controller', () => ({ emit })) +vi.mock('../services/browser', () => ({ default: {}, setLocalStorage: vi.fn(), getOs: vi.fn() })) +vi.mock('../i18n', () => ({ default: { t: (k: string) => k } })) + +import backend from './backend' + +const state = { backend: { thisId: 'THIS' }, ui: {} } + +describe('backend.unregisterThisDevice', () => { + let dispatch: any + let effects: any + + beforeEach(() => { + emit.mockReset().mockReturnValue(true) + dispatch = { ui: { set: vi.fn() }, backend: { set: vi.fn() }, devices: {} } + effects = (backend as any).effects(dispatch) + }) + afterEach(() => vi.useRealTimers()) + + it('resolves true once the agent reports this device gone', async () => { + const unregistering = effects.unregisterThisDevice(undefined, state) + expect(emit).toHaveBeenCalledWith('registration', 'DELETE') + await effects.targetDeviceUpdated('', state) + await expect(unregistering).resolves.toBe(true) + }) + + it('resolves false when the device is still registered afterwards', async () => { + const unregistering = effects.unregisterThisDevice(undefined, state) + await effects.targetDeviceUpdated('THIS', state) + await expect(unregistering).resolves.toBe(false) + }) + + it('resolves false when the local backend is not connected', async () => { + emit.mockReturnValue(false) + await expect(effects.unregisterThisDevice(undefined, state)).resolves.toBe(false) + }) + + it('resolves false when the agent never answers', async () => { + vi.useFakeTimers() + const unregistering = effects.unregisterThisDevice(undefined, state) + await vi.advanceTimersByTimeAsync(60 * 1000) + await expect(unregistering).resolves.toBe(false) + }) + + it('has nothing to do without a registered device', async () => { + await expect(effects.unregisterThisDevice(undefined, { backend: { thisId: '' } })).resolves.toBe(true) + expect(emit).not.toHaveBeenCalled() + }) +}) diff --git a/frontend/src/models/backend.ts b/frontend/src/models/backend.ts index cbb5243e5..72d995515 100644 --- a/frontend/src/models/backend.ts +++ b/frontend/src/models/backend.ts @@ -2,10 +2,13 @@ import browser, { setLocalStorage, getOs } from '../services/browser' import { createModel } from '@rematch/core' import { RootModel } from '.' import { emit } from '../services/Controller' -import sleep from '../helpers/sleep' +import sleep, { withTimeout } from '../helpers/sleep' import i18n from '../i18n' export const NOTICE_VERSION_ID = 'notice-version' +const UNREGISTER_TIMEOUT = 60 * 1000 + +let onTargetDeviceUpdated: ((id: string) => void) | undefined export type IBackendState = { initialized: boolean @@ -91,9 +94,19 @@ export default createModel()({ }) return result }, + async unregisterThisDevice(_: void, state) { + const { thisId } = state.backend + if (!thisId) return true + const updated = new Promise(resolve => (onTargetDeviceUpdated = id => resolve(!id))) + dispatch.ui.set({ silent: thisId }) + const unregistered = emit('registration', 'DELETE') && (await withTimeout(updated, UNREGISTER_TIMEOUT)) + onTargetDeviceUpdated = undefined + return unregistered === true + }, async targetDeviceUpdated(newId: string, state) { const { ui, backend, devices } = dispatch const { thisId } = state.backend + onTargetDeviceUpdated?.(newId) if (newId !== thisId) { // registered From fa72b4a2d662f48c2cbbdc1d6d50ba0663c0662a Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:25:08 -0700 Subject: [PATCH 3/9] feat(profile): self-service account deletion with device removal guidance --- .../components/DeleteAccountDialog.test.tsx | 208 +++++++++ .../src/components/DeleteAccountDialog.tsx | 426 ++++++++++++++++++ .../src/components/DeleteAccountSection.tsx | 236 ++++------ frontend/src/components/OwnedDevicesList.tsx | 53 +++ .../src/components/RemoveRemoteitDialog.tsx | 84 ++++ frontend/src/models/ui.ts | 2 - frontend/src/pages/ProfilePage.tsx | 9 +- 7 files changed, 854 insertions(+), 164 deletions(-) create mode 100644 frontend/src/components/DeleteAccountDialog.test.tsx create mode 100644 frontend/src/components/DeleteAccountDialog.tsx create mode 100644 frontend/src/components/OwnedDevicesList.tsx create mode 100644 frontend/src/components/RemoveRemoteitDialog.tsx diff --git a/frontend/src/components/DeleteAccountDialog.test.tsx b/frontend/src/components/DeleteAccountDialog.test.tsx new file mode 100644 index 000000000..15c2244ec --- /dev/null +++ b/frontend/src/components/DeleteAccountDialog.test.tsx @@ -0,0 +1,208 @@ +import React, { act } from 'react' +import { createRoot, Root } from 'react-dom/client' +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' + +const api = vi.hoisted(() => ({ graphQLRequestAccountDeletion: vi.fn(), graphQLDeleteAccount: vi.fn() })) +const dispatch = vi.hoisted(() => ({ + backend: { unregisterThisDevice: vi.fn() }, + feedback: { set: vi.fn(), sendFeedback: vi.fn() }, + auth: { signOut: vi.fn() }, +})) +vi.mock('../services/graphQLMutation', () => api) +vi.mock('../store', () => ({})) +vi.mock('../helpers/sleep', () => ({ default: () => Promise.resolve() })) +vi.mock('./TargetPlatform', () => ({ TargetPlatform: () => null })) +vi.mock('react-redux', () => ({ + useDispatch: () => dispatch, + useSelector: (select: (state: any) => any) => + select({ user: { id: 'ME', email: 'me@example.com', created: new Date(0) }, connections: { all: [] } }), +})) +vi.mock('react-i18next', () => ({ + initReactI18next: { type: '3rdParty', init: () => {} }, + useTranslation: () => ({ + t: (_: string, fallback: string | Record, values?: Record) => { + const options = typeof fallback === 'string' ? values : fallback + const text = typeof fallback === 'string' ? fallback : fallback.defaultValue + return text.replace(/{{(\w+)}}/g, (_m: string, name: string) => String(options?.[name] ?? '')) + }, + }), +})) + +import { ThemeProvider } from '@mui/material' +import { createTheme } from '@mui/material/styles' +import { jssTheme } from '../styling/theme' +import { DeleteAccountDialog } from './DeleteAccountDialog' +import { OwnedDevices } from './OwnedDevicesList' + +Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }) + +const theme = createTheme(jssTheme(false)) +const THIS_ID = 'THIS' +const owned = (thisDeviceOwned: boolean): OwnedDevices => ({ + total: 3, + thisDeviceOwned, + devices: [ + { id: 'OFF', name: 'Offline NAS', state: 'inactive', platform: 0 }, + { id: THIS_ID, name: 'This laptop', state: 'active', platform: 0 }, + { id: 'ON', name: 'Online Pi', state: 'active', platform: 0 }, + ], +}) + +let root: Root +let container: HTMLDivElement + +const flush = () => act(async () => {}) +const dialog = () => document.querySelector('[role=dialog]') as HTMLElement +const button = (label: string) => { + const found = [...dialog().querySelectorAll('button')].find(b => b.textContent === label) + if (!found) throw new Error(`no "${label}" in: ${dialog().textContent}`) + return found +} +const click = async (label: string) => { + await act(async () => button(label).click()) + await flush() +} +const typeCode = async (code: string) => { + const input = dialog().querySelector('input[autocomplete=one-time-code]') as HTMLInputElement + await act(async () => { + Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, code) + input.dispatchEvent(new Event('input', { bubbles: true })) + }) +} +const render = async (devices = owned(true), thisId = THIS_ID) => { + await act(async () => + root.render( + + + + ) + ) + await flush() +} +const toConfirm = async () => { + await act(async () => (dialog().querySelector('input[type=checkbox]') as HTMLInputElement).click()) + await click('Continue') + await click('Continue') + await click('Email me a code') +} + +beforeEach(() => { + Object.values(api).forEach(fn => fn.mockReset()) + dispatch.backend.unregisterThisDevice.mockReset() + dispatch.feedback.set.mockReset() + dispatch.feedback.sendFeedback.mockReset() + dispatch.auth.signOut.mockReset() + api.graphQLRequestAccountDeletion.mockResolvedValue({ ok: true }) + container = document.createElement('div') + document.body.appendChild(container) + root = createRoot(container) +}) +afterEach(() => { + act(() => root.unmount()) + container.remove() +}) + +describe('DeleteAccountDialog', () => { + it('holds Continue until the person accepts that Remote.It stays on their other devices', async () => { + await render() + const names = [...dialog().querySelectorAll('li')].map(item => item.textContent) + expect(names).toEqual(['Online PiOnline', 'Offline NASOffline']) + expect(dialog().textContent).toContain('You own 2 devices') + expect(button('Continue').disabled).toBe(true) + await act(async () => (dialog().querySelector('input[type=checkbox]') as HTMLInputElement).click()) + expect(button('Continue').disabled).toBe(false) + }) + + it('unregisters this device before the account is deleted, then signs out without a survey ticket', async () => { + dispatch.backend.unregisterThisDevice.mockResolvedValue(true) + api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) + await render() + await toConfirm() + await typeCode('abc234') + await click('Delete account permanently') + + expect(api.graphQLDeleteAccount).toHaveBeenCalledWith('ABC234') + expect(dispatch.backend.unregisterThisDevice.mock.invocationCallOrder[0]).toBeLessThan( + api.graphQLDeleteAccount.mock.invocationCallOrder[0] + ) + expect(dispatch.feedback.set).not.toHaveBeenCalled() + expect(dispatch.auth.signOut).toHaveBeenCalled() + expect(dialog().textContent).toContain('Your account has been deleted') + }) + + it('never deletes the account when this device could not be unregistered', async () => { + dispatch.backend.unregisterThisDevice.mockResolvedValue(false) + await render() + await toConfirm() + await typeCode('ABC234') + await click('Delete account permanently') + + expect(api.graphQLDeleteAccount).not.toHaveBeenCalled() + expect(dialog().textContent).toContain("This device couldn't be unregistered") + expect(button('Delete account permanently').disabled).toBe(false) + }) + + it('leaves a device registered to someone else alone', async () => { + api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) + await render(owned(false)) + await toConfirm() + await typeCode('ABC234') + await click('Delete account permanently') + + expect(dispatch.backend.unregisterThisDevice).not.toHaveBeenCalled() + expect(api.graphQLDeleteAccount).toHaveBeenCalled() + }) + + it('asks for a new code after the fifth wrong one', async () => { + api.graphQLDeleteAccount.mockResolvedValue({ ok: false, code: 'NOT_AUTHORIZED', message: 'Not Authorized' }) + await render(owned(false)) + await toConfirm() + for (let attempt = 1; attempt <= 4; attempt++) { + await typeCode('ABC234') + await click('Delete account permanently') + expect(dialog().textContent).toContain('That code is incorrect or has expired.') + } + await typeCode('ABC234') + await click('Delete account permanently') + + expect(api.graphQLDeleteAccount).toHaveBeenCalledTimes(5) + expect(dialog().textContent).toContain('Too many incorrect codes') + expect(button('Email me a code')).toBeTruthy() + }) + + it('shows a refusal in place and needs a new code, since the server spent the old one', async () => { + api.graphQLDeleteAccount.mockResolvedValue({ + ok: false, + code: 'INVALID_ARGUMENT', + message: 'your subscription is still active — cancel it first', + }) + await render(owned(false)) + await toConfirm() + await typeCode('ABC234') + await click('Delete account permanently') + + expect(dialog().textContent).toContain('Your subscription is still active — cancel it first') + expect(button('Email me a code')).toBeTruthy() + expect(dispatch.auth.signOut).not.toHaveBeenCalled() + }) + + it('sends the survey only when the person filled it in', async () => { + api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) + await render(owned(false)) + await act(async () => (dialog().querySelector('input[type=checkbox]') as HTMLInputElement).click()) + await click('Continue') + await act(async () => (dialog().querySelectorAll('input[type=checkbox]')[0] as HTMLInputElement).click()) + await click('Continue') + await click('Email me a code') + await typeCode('ABC234') + await click('Delete account permanently') + + expect(dispatch.feedback.set).toHaveBeenCalledWith( + expect.objectContaining({ + subject: 'Account deleted: me@example.com', + data: expect.objectContaining({ reasons: ['My device isn’t supported'] }), + }) + ) + expect(dispatch.feedback.sendFeedback).toHaveBeenCalled() + }) +}) diff --git a/frontend/src/components/DeleteAccountDialog.tsx b/frontend/src/components/DeleteAccountDialog.tsx new file mode 100644 index 000000000..7101d0933 --- /dev/null +++ b/frontend/src/components/DeleteAccountDialog.tsx @@ -0,0 +1,426 @@ +import React, { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { useDispatch, useSelector } from 'react-redux' +import { + Box, + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + List, + ListItem, + ListItemIcon, + ListItemText, + TextField, + Typography, +} from '@mui/material' +import { Dispatch, State } from '../store' +import { graphQLDeleteAccount, graphQLRequestAccountDeletion } from '../services/graphQLMutation' +import { GraphQLInlineResult } from '../services/graphQL' +import { OwnedDevices, OwnedDevicesList, otherOwnedDevices } from './OwnedDevicesList' +import { ListItemCheckbox } from './ListItemCheckbox' +import { Notice } from './Notice' +import { Icon } from './Icon' +import { spacing } from '../styling' +import sleep from '../helpers/sleep' + +const CODE_LENGTH = 6 +const MAX_ATTEMPTS = 5 +const SIGN_OUT_DELAY = 3000 + +type Step = 'devices' | 'feedback' | 'confirm' | 'done' +type Busy = 'sending' | 'unregistering' | 'deleting' + +type Props = { + open: boolean + owned?: OwnedDevices + thisId?: string + onShowInstructions: () => void + onClose: () => void +} + +export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onShowInstructions, onClose }) => { + const { t } = useTranslation() + const dispatch = useDispatch() + const user = useSelector((state: State) => state.user) + const connections = useSelector((state: State) => state.connections.all) + const [step, setStep] = useState('devices') + const [acknowledged, setAcknowledged] = useState(false) + const [reasons, setReasons] = useState([]) + const [body, setBody] = useState('') + const [contact, setContact] = useState(true) + const [codeSent, setCodeSent] = useState(false) + const [code, setCode] = useState('') + const [failures, setFailures] = useState(0) + const [busy, setBusy] = useState() + const [error, setError] = useState() + + const unregisterThisDevice = !!(owned?.thisDeviceOwned && thisId) + const others = owned && otherOwnedDevices(owned, thisId) + const locked = !!busy || step === 'done' + + const REASONS = [ + t('deleteAccountSection.reasonUnsupportedDevice', 'My device isn’t supported'), + t('deleteAccountSection.reasonInstallDifficult', 'Installation was too difficult'), + t('deleteAccountSection.reasonConnectionQuality', 'Connection quality or performance issues'), + t('deleteAccountSection.reasonCouldntGetOnline', 'Couldn’t get my device online'), + t('deleteAccountSection.reasonCouldntConnect', 'Couldn’t connect'), + t('deleteAccountSection.reasonCost', 'Cost of service'), + t('deleteAccountSection.reasonAnotherAccount', 'Have another account'), + t('deleteAccountSection.reasonTooHard', 'Too hard to use'), + t('deleteAccountSection.reasonNotExpected', 'Not what I thought it was'), + t('deleteAccountSection.reasonNotUsing', 'Not using it anymore'), + t('deleteAccountSection.reasonUsingSomethingElse', 'Using something else'), + ] + + useEffect(() => { + if (!open) return + setStep('devices') + setAcknowledged(false) + setCodeSent(false) + setCode('') + setFailures(0) + setError(undefined) + }, [open]) + + const refusal = (result: GraphQLInlineResult) => + result.message + ? result.message.charAt(0).toUpperCase() + result.message.slice(1) + : t('deleteAccountDialog.genericError', 'Something went wrong. Please try again.') + + const goTo = (next: Step) => { + setError(undefined) + setStep(next) + } + + const toggleReason = (reason: string) => + setReasons(reasons.includes(reason) ? reasons.filter(r => r !== reason) : [...reasons, reason]) + + const sendCode = async () => { + setError(undefined) + setBusy('sending') + const result = await graphQLRequestAccountDeletion() + setBusy(undefined) + if (!result.ok) return setError(refusal(result)) + setCodeSent(true) + setCode('') + setFailures(0) + } + + const sendFeedback = async () => { + if (!reasons.length && !body.trim()) return + dispatch.feedback.set({ + subject: `Account deleted: ${user.email}`, + body, + data: { + email: user.email, + userId: user.id, + reasons, + contactMe: contact ? 'Yes' : 'No', + createdDate: user.created?.toLocaleString(navigator.language, { + month: 'short', + day: 'numeric', + year: 'numeric', + }), + lastConnections: connections.slice(0, 5), + }, + snackbar: t('deleteAccountDialog.doneTitle', 'Your account has been deleted'), + }) + await dispatch.feedback.sendFeedback() + } + + const deleteAccount = async () => { + setError(undefined) + + if (unregisterThisDevice) { + setBusy('unregistering') + if (!(await dispatch.backend.unregisterThisDevice())) { + setBusy(undefined) + return setError( + t( + 'deleteAccountDialog.unregisterFailed', + "This device couldn't be unregistered, so your account was not deleted. Try again, or unregister this device from its device page first." + ) + ) + } + } + + setBusy('deleting') + const result = await graphQLDeleteAccount(code) + setBusy(undefined) + + if (!result.ok) { + const attempts = result.code === 'NOT_AUTHORIZED' ? failures + 1 : MAX_ATTEMPTS + setFailures(attempts) + setCode('') + if (attempts < MAX_ATTEMPTS) + return setError(t('deleteAccountDialog.invalidCode', 'That code is incorrect or has expired.')) + setCodeSent(false) + return setError( + result.code === 'NOT_AUTHORIZED' + ? t('deleteAccountDialog.tooManyAttempts', 'Too many incorrect codes. Request a new code to try again.') + : refusal(result) + ) + } + + setStep('done') + await sendFeedback() + await sleep(SIGN_OUT_DELAY) + dispatch.auth.signOut() + } + + const busyLabel = { + sending: t('deleteAccountDialog.sending', 'Sending…'), + unregistering: t('deleteAccountDialog.unregistering', 'Unregistering this device…'), + deleting: t('deleteAccountDialog.deleting', 'Deleting…'), + } + + const consequences = [ + { + icon: 'hdd', + text: t('deleteAccountDialog.consequenceDevices', 'The devices you own are removed from your account'), + }, + { + icon: 'industry-alt', + text: t('deleteAccountDialog.consequenceOrganization', 'Your organization and its roles are deleted'), + }, + { + icon: 'user-friends', + text: t( + 'deleteAccountDialog.consequenceShares', + 'Devices shared with you and your memberships in other organizations are removed' + ), + }, + { icon: 'sign-out', text: t('deleteAccountDialog.consequenceSignIn', 'Your sign-in and access keys stop working') }, + ] + + return ( + + {step === 'devices' && ( + <> + + {t('deleteAccountDialog.devicesTitle', 'Remote.It will keep running on your devices')} + + + + {t( + 'deleteAccountDialog.devicesBody', + "Deleting your account removes your devices from it, but it doesn't uninstall Remote.It. The software keeps running on every device it's installed on until you remove it." + )} + + {owned && others && others.devices.length > 0 && ( + + + {t('deleteAccountDialog.devicesOwned', { + count: others.total, + defaultValue: 'You own {{count}} devices', + })} + + + + )} + {unregisterThisDevice && ( + + {t('deleteAccountDialog.thisDevice', 'This device will be unregistered when your account is deleted.')} + + )} + + + + + + + + + + + )} + + {step === 'feedback' && ( + <> + + + 🥺 + + {t('deleteAccountDialog.feedbackTitle', 'Why are you leaving?')} + + {t('deleteAccountSection.confirmSorry', 'We are sorry to see you go!')} +
+ {t( + 'deleteAccountDialog.feedbackOptional', + "Optional — telling us why it didn't work out helps us improve." + )} +
+
+ + + {REASONS.map(reason => ( + toggleReason(reason)} + /> + ))} + + setBody(e.target.value)} + /> + + + + + + + + + )} + + {step === 'confirm' && ( + <> + {t('deleteAccountDialog.confirmTitle', 'Delete your account')} + + + {consequences.map(({ icon, text }) => ( + + + + + + + ))} + + + {t('deleteAccountDialog.permanent', "This happens immediately and can't be undone.")} + + {codeSent ? ( + <> + + {t('deleteAccountDialog.codeSent', { + email: user.email, + defaultValue: 'Enter the code we sent to {{email}}. It expires in 10 minutes.', + })} + + + setCode( + e.target.value + .replace(/[^A-Za-z0-9]/g, '') + .toUpperCase() + .slice(0, CODE_LENGTH) + ) + } + onKeyDown={e => e.key === 'Enter' && code.length === CODE_LENGTH && !busy && deleteAccount()} + inputProps={{ + maxLength: CODE_LENGTH, + autoComplete: 'one-time-code', + style: { textAlign: 'center', fontSize: '1.5rem', letterSpacing: '0.5rem' }, + }} + /> + + + ) : ( + + {t('deleteAccountDialog.codeIntro', { + email: user.email, + defaultValue: "To confirm, we'll email a code to {{email}}.", + })} + + )} + {error && ( + + {error} + + )} + + + + + {codeSent ? ( + + ) : ( + + )} + + + )} + + {step === 'done' && ( + + + + + {t('deleteAccountDialog.doneTitle', 'Your account has been deleted')} + + + {t('deleteAccountDialog.doneBody', 'Thank you for using Remote.It. Signing you out…')} + + + + )} +
+ ) +} diff --git a/frontend/src/components/DeleteAccountSection.tsx b/frontend/src/components/DeleteAccountSection.tsx index 0b6b5e349..13106d66f 100644 --- a/frontend/src/components/DeleteAccountSection.tsx +++ b/frontend/src/components/DeleteAccountSection.tsx @@ -1,171 +1,97 @@ -import React from 'react' -import { State } from '../store' +import React, { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { Typography, Box, Button, TextField, List } from '@mui/material' import { useTranslation } from 'react-i18next' -import { ListItemCheckbox } from '../components/ListItemCheckbox' -import { useDispatch } from 'react-redux' -import { Dispatch } from '../store' -import { Gutters } from '../components/Gutters' -import { Confirm } from '../components/Confirm' -import { Notice } from '../components/Notice' -import { spacing } from '../styling' +import { Typography, Button, Stack } from '@mui/material' +import { State } from '../store' +import { isPersonal } from '../models/plans' +import { getUserId } from '../selectors/state' +import { graphQLFetchOwnedDevices } from '../services/graphQLDevice' +import { RemoveRemoteitDialog } from './RemoveRemoteitDialog' +import { DeleteAccountDialog } from './DeleteAccountDialog' +import { OwnedDevices } from './OwnedDevicesList' +import { Gutters } from './Gutters' +import { Notice } from './Notice' +import { Link } from './Link' + +function useOwnedDevices(userId: string, thisId?: string) { + const [owned, setOwned] = useState() -interface DeleteAccountSectionProps { - user?: IUser - paidPlan?: boolean - deleteAccount?: boolean + useEffect(() => { + if (!userId) return + let current = true + graphQLFetchOwnedDevices(userId, thisId).then(result => { + if (!current || result === 'ERROR') return + const login = result.data?.data?.login + const devices = login?.account?.devices + setOwned({ + total: devices?.total || 0, + devices: devices?.items || [], + thisDeviceOwned: !!login?.device?.some((device: { owner?: { id: string } }) => device.owner?.id === userId), + }) + }) + return () => { + current = false + } + }, [userId, thisId]) + + return owned } -export const DeleteAccountSection: React.FC = ({ - user, - paidPlan = false, - deleteAccount, -}) => { - const connections = useSelector((state: State) => state.connections.all).slice(0, 5) - const [confirm, setConfirm] = React.useState(false) - const [contact, setContact] = React.useState(true) - const [reasons, setReasons] = React.useState([]) - const [body, setBody] = React.useState('') - const dispatch = useDispatch() +export const DeleteAccountSection: React.FC = () => { const { t } = useTranslation() + const userId = useSelector(getUserId) + const thisId = useSelector((state: State) => state.backend.thisId) + const paidPlan = useSelector((state: State) => !isPersonal(state)) + const members = useSelector( + (state: State) => state.organization.accounts[userId]?.members.filter(m => m.user.id !== userId).length || 0 + ) + const owned = useOwnedDevices(userId, thisId) + const [dialog, setDialog] = useState<'remove' | 'delete'>() + const close = () => setDialog(undefined) - const REASONS = [ - t('deleteAccountSection.reasonUnsupportedDevice', 'My device isn’t supported'), - t('deleteAccountSection.reasonInstallDifficult', 'Installation was too difficult'), - t('deleteAccountSection.reasonConnectionQuality', 'Connection quality or performance issues'), - t('deleteAccountSection.reasonCouldntGetOnline', 'Couldn’t get my device online'), - t('deleteAccountSection.reasonCouldntConnect', 'Couldn’t connect'), - t('deleteAccountSection.reasonCost', 'Cost of service'), - t('deleteAccountSection.reasonAnotherAccount', 'Have another account'), - t('deleteAccountSection.reasonTooHard', 'Too hard to use'), - t('deleteAccountSection.reasonNotExpected', 'Not what I thought it was'), - t('deleteAccountSection.reasonNotUsing', 'Not using it anymore'), - t('deleteAccountSection.reasonUsingSomethingElse', 'Using something else'), - ] - - const handleDelete = () => setConfirm(true) - const handleReason = (reason: string) => { - if (reasons.includes(reason)) setReasons(reasons.filter(r => r !== reason)) - else setReasons([...reasons, reason]) - } - const handleConfirm = () => { - dispatch.feedback.set({ - subject: `Account deletion request for ${user?.email}`, - body, - data: { - email: user?.email, - userId: user?.id, - reasons, - contactMe: contact ? 'Yes' : 'No', - createdDate: user?.created?.toLocaleString(navigator.language, { - month: 'short', - day: 'numeric', - year: 'numeric', - }), - lastConnections: connections, - }, - snackbar: t('deleteAccountSection.snackbar', 'Your account delete request has been sent.'), - }) - dispatch.feedback.sendFeedback() - dispatch.ui.set({ deleteAccount: true }) - setConfirm(false) - } return ( - {paidPlan ? ( + {paidPlan && ( {t('deleteAccountSection.paidPlanNotice', 'You have a paid subscription plan.')}{' '} - {t('deleteAccountSection.paidPlanDowngrade', 'Please downgrade to Personal to request an account deletion.')} + + {t('deleteAccountSection.paidPlanCancel', 'Cancel it before deleting your account.')} + + + )} + {members > 0 && ( + + {t('deleteAccountSection.membersNotice', { + count: members, + defaultValue: 'Your organization has {{count}} other members.', + })}{' '} + + {t('deleteAccountSection.membersRemove', 'Transfer ownership or remove them before deleting your account.')} + - ) : ( - <> - - {t( - 'deleteAccountSection.description', - 'If you no longer want/need your Remote.It account, you can request an account deletion. Once your delete request is processed, all your account information is removed permanently.' - )} - - - - setConfirm(false)} - title={ - <> - - {/* Pleading Emoji */} - 🥺 - - {t('deleteAccountSection.confirmTitle', 'Why do you want to delete your account?')} - - {t('deleteAccountSection.confirmSorry', 'We are sorry to see you go!')} -
- {t('deleteAccountSection.confirmHelp', "Please help us improve by telling us why it didn't work out.")} -
- - } - action={t('common.delete', 'Delete')} - disabled={body.length < 2 && reasons.length < 1} - > - - {REASONS.map((reason, i) => ( - { - handleReason(reason) - }} - /> - ))} - - setBody(e.target.value)} - /> - setContact(checked)} - /> - - {t( - 'deleteAccountSection.permanentWarning', - 'I understand that this is permanent and that accounts and related devices can not be recovered.' - )} - -
-
- - {t('deleteAccountSection.turnaround', 'Deletion requests take 3 to 5 business days to complete.')} - - )} + + {t( + 'deleteAccountSection.description', + "Deleting your account is immediate and permanent. It doesn't uninstall Remote.It from your devices, so remove it from each device first." + )} + + + + + + + setDialog('remove')} + onClose={close} + />
) } diff --git a/frontend/src/components/OwnedDevicesList.tsx b/frontend/src/components/OwnedDevicesList.tsx new file mode 100644 index 000000000..e6e783cda --- /dev/null +++ b/frontend/src/components/OwnedDevicesList.tsx @@ -0,0 +1,53 @@ +import React from 'react' +import { useTranslation } from 'react-i18next' +import { List, ListItem, ListItemIcon, ListItemText, Typography } from '@mui/material' +import { TargetPlatform } from './TargetPlatform' +import { ColorChip } from './ColorChip' + +const SHOWN = 10 + +export type OwnedDevice = { id: string; name: string; state: string; platform: number } + +export type OwnedDevices = { total: number; devices: OwnedDevice[]; thisDeviceOwned: boolean } + +export function otherOwnedDevices(owned: OwnedDevices, thisId?: string) { + const isThis = (device: OwnedDevice) => owned.thisDeviceOwned && device.id === thisId + const devices = owned.devices + .filter(device => !isThis(device)) + .sort((a, b) => Number(b.state === 'active') - Number(a.state === 'active')) + .slice(0, SHOWN) + const total = owned.total - (owned.thisDeviceOwned ? 1 : 0) + return { devices, total, more: total - devices.length } +} + +export const OwnedDevicesList: React.FC<{ owned: OwnedDevices; thisId?: string }> = ({ owned, thisId }) => { + const { t } = useTranslation() + const { devices, more } = otherOwnedDevices(owned, thisId) + + if (!devices.length) return null + + return ( + <> + + {devices.map(device => ( + + + + + + {device.state === 'active' ? ( + + ) : ( + + )} + + ))} + + {more > 0 && ( + + {t('ownedDevicesList.more', { count: more, defaultValue: 'and {{count}} more' })} + + )} + + ) +} diff --git a/frontend/src/components/RemoveRemoteitDialog.tsx b/frontend/src/components/RemoveRemoteitDialog.tsx new file mode 100644 index 000000000..b236f2761 --- /dev/null +++ b/frontend/src/components/RemoveRemoteitDialog.tsx @@ -0,0 +1,84 @@ +import React from 'react' +import { useTranslation } from 'react-i18next' +import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from '@mui/material' +import { OwnedDevices, OwnedDevicesList, otherOwnedDevices } from './OwnedDevicesList' +import { CopyCodeBlock } from './CopyCodeBlock' +import { Notice } from './Notice' +import { Link } from './Link' + +const UNINSTALL_SUPPORT_URL = 'https://support.remote.it/hc/en-us/articles/360054866351' + +type Props = { + open: boolean + owned?: OwnedDevices + thisId?: string + onClose: () => void +} + +export const RemoveRemoteitDialog: React.FC = ({ open, owned, thisId, onClose }) => { + const { t } = useTranslation() + const others = owned && otherOwnedDevices(owned, thisId) + + return ( + + {t('removeRemoteitDialog.title', 'Remove Remote.It from your devices')} + + + {t( + 'removeRemoteitDialog.intro', + "Deleting your account doesn't uninstall Remote.It. Remove it from each device you own before you delete your account." + )} + + + {t( + 'removeRemoteitDialog.localAccess', + 'Uninstall from the device itself or over your local network. Removing Remote.It through a Remote.It connection ends that connection right away.' + )} + + + + + + + {t('removeRemoteitDialog.desktopMacLinux', 'Desktop app on macOS or Linux')} + {' — '} + {t('removeRemoteitDialog.desktopMacLinuxSteps', 'Open Settings, then Advanced, and select Uninstall.')} + + + {t('removeRemoteitDialog.desktopWindows', 'Desktop app on Windows')} + {' — '} + {t('removeRemoteitDialog.desktopWindowsSteps', 'Uninstall Remote.It from Windows Settings, under Apps.')} + + + + {t('removeRemoteitDialog.otherDevices', 'Instructions for other devices')} + + + {owned?.thisDeviceOwned && thisId && ( + + {t( + 'removeRemoteitDialog.thisDevice', + 'This device is unregistered automatically when you delete your account.' + )} + + )} + {owned && others && others.devices.length > 0 && ( + <> + + {t('removeRemoteitDialog.yourDevices', { count: others.total, defaultValue: 'Your devices ({{count}})' })} + + + + )} + + + + + + ) +} diff --git a/frontend/src/models/ui.ts b/frontend/src/models/ui.ts index 69210f5cf..07f8b9ee7 100644 --- a/frontend/src/models/ui.ts +++ b/frontend/src/models/ui.ts @@ -61,7 +61,6 @@ export type UIState = { fetching: boolean destroying: boolean transferring: boolean - deleteAccount: boolean routingLock?: IRouteType routingMessage?: string sidebarMenu: boolean @@ -149,7 +148,6 @@ export const defaultState: UIState = { fetching: false, destroying: false, transferring: false, - deleteAccount: false, routingLock: undefined, routingMessage: undefined, sidebarMenu: false, diff --git a/frontend/src/pages/ProfilePage.tsx b/frontend/src/pages/ProfilePage.tsx index 411f8dcfa..ca171bf24 100644 --- a/frontend/src/pages/ProfilePage.tsx +++ b/frontend/src/pages/ProfilePage.tsx @@ -2,7 +2,6 @@ import React from 'react' import { LANGUAGES } from '../constants' import { SUPPORTED_LANGUAGES } from '../i18n' import { Dispatch, State } from '../store' -import { isPersonal } from '../models/plans' import { Typography, List } from '@mui/material' import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' @@ -19,11 +18,7 @@ import { Link } from '../components/Link' import { spacing } from '../styling' export const ProfilePage: React.FC = () => { - const { paidPlan, user, deleteAccount } = useSelector((state: State) => ({ - user: state.user, - paidPlan: !isPersonal(state), - deleteAccount: state.ui.deleteAccount, - })) + const user = useSelector((state: State) => state.user) const dispatch = useDispatch() const { t } = useTranslation() @@ -87,7 +82,7 @@ export const ProfilePage: React.FC = () => { /> {t('settings.accountDeletion', 'Account deletion')} - + ) } From e1879deb9b1c6e8c7556e33fc6dc181073b6f36c Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:25:08 -0700 Subject: [PATCH 4/9] feat(i18n): account deletion copy in en, ja, de and es --- frontend/src/i18n/locales/de/app.json | 66 ++++++++++++++++++++++--- frontend/src/i18n/locales/en/app.json | 64 +++++++++++++++++++++--- frontend/src/i18n/locales/es/app.json | 70 ++++++++++++++++++++++++--- frontend/src/i18n/locales/ja/app.json | 62 +++++++++++++++++++++--- 4 files changed, 231 insertions(+), 31 deletions(-) diff --git a/frontend/src/i18n/locales/de/app.json b/frontend/src/i18n/locales/de/app.json index 9e75057fc..3cd7c8659 100644 --- a/frontend/src/i18n/locales/de/app.json +++ b/frontend/src/i18n/locales/de/app.json @@ -450,13 +450,14 @@ "common": { "actionCannotBeUndone": "Diese Aktion kann nicht rückgängig gemacht werden.", "areYouSure": "Sind Sie sicher?", + "back": "Zurück", "cancel": "Abbrechen", "cannotBeUndone": "Diese Aktion kann nicht rückgängig gemacht werden.", "clear": "Löschen", "close": "Schließen", "confirm": "Bestätigen", "confirmingEllipsis": "Wird bestätigt...", - "continue": "", + "continue": "Weiter", "delete": "Löschen", "disable": "Deaktivieren", "done": "Fertig", @@ -679,17 +680,48 @@ "title": "Zugriffsschlüssel löschen", "warning": "Diese Aktion ist endgültig und kann nicht rückgängig gemacht werden." }, + "deleteAccountDialog": { + "acknowledge": "Mir ist bewusst, dass Remote.It auf meinen Geräten installiert bleibt und weiterläuft und durch das Löschen meines Kontos nicht entfernt wird.", + "codeIntro": "Zur Bestätigung senden wir einen Code per E-Mail an {{email}}.", + "codePlaceholder": "Code", + "codeSent": "Geben Sie den Code ein, den wir an {{email}} gesendet haben. Er ist 10 Minuten gültig.", + "confirmTitle": "Konto löschen", + "consequenceDevices": "Ihre Geräte werden aus Ihrem Konto entfernt", + "consequenceOrganization": "Ihre Organisation und ihre Rollen werden gelöscht", + "consequenceShares": "Für Sie freigegebene Geräte und Ihre Mitgliedschaften in anderen Organisationen werden entfernt", + "consequenceSignIn": "Ihre Anmeldung und Ihre Zugriffsschlüssel funktionieren nicht mehr", + "deleteButton": "Konto endgültig löschen", + "deleting": "Wird gelöscht…", + "devicesBody": "Beim Löschen Ihres Kontos werden Ihre Geräte daraus entfernt, Remote.It wird aber nicht deinstalliert. Die Software läuft auf jedem Gerät weiter, auf dem sie installiert ist, bis Sie sie entfernen.", + "devicesOwned_one": "Sie besitzen {{count}} Gerät", + "devicesOwned_other": "Sie besitzen {{count}} Geräte", + "devicesTitle": "Remote.It läuft auf Ihren Geräten weiter", + "doneBody": "Danke, dass Sie Remote.It genutzt haben. Sie werden abgemeldet…", + "doneTitle": "Ihr Konto wurde gelöscht", + "feedbackOptional": "Optional – wenn Sie uns sagen, warum es nicht gepasst hat, hilft uns das, besser zu werden.", + "feedbackTitle": "Warum verlassen Sie uns?", + "genericError": "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.", + "invalidCode": "Dieser Code ist falsch oder abgelaufen.", + "permanent": "Das geschieht sofort und kann nicht rückgängig gemacht werden.", + "resendCode": "Neuen Code senden", + "sendCode": "Code per E-Mail senden", + "sending": "Wird gesendet…", + "thisDevice": "Die Registrierung dieses Geräts wird aufgehoben, wenn Ihr Konto gelöscht wird.", + "tooManyAttempts": "Zu viele falsche Codes. Fordern Sie einen neuen Code an, um es erneut zu versuchen.", + "unregisterFailed": "Die Registrierung dieses Geräts konnte nicht aufgehoben werden, daher wurde Ihr Konto nicht gelöscht. Versuchen Sie es erneut oder heben Sie die Registrierung zuerst auf der Seite des Geräts auf.", + "unregistering": "Registrierung dieses Geräts wird aufgehoben…" + }, "deleteAccountSection": { - "confirmHelp": "Bitte helfen Sie uns, uns zu verbessern, indem Sie uns mitteilen, warum es nicht funktioniert hat.", "confirmSorry": "Schade, dass Sie uns verlassen!", - "confirmTitle": "Warum möchten Sie Ihr Konto löschen?", "contactMeLabel": "Ich bin damit einverstanden, dass mich jemand bezüglich meines Feedbacks kontaktiert.", "deleteButton": "Mein Konto löschen", - "description": "Wenn Sie Ihr Remote.It-Konto nicht mehr benötigen, können Sie eine Kontolöschung beantragen. Sobald Ihre Löschanfrage bearbeitet wurde, werden alle Ihre Kontoinformationen dauerhaft entfernt.", + "description": "Das Löschen Ihres Kontos erfolgt sofort und endgültig. Remote.It wird dabei nicht von Ihren Geräten deinstalliert – entfernen Sie es daher zuerst von jedem Gerät.", + "membersNotice_one": "Ihre Organisation hat {{count}} weiteres Mitglied.", + "membersNotice_other": "Ihre Organisation hat {{count}} weitere Mitglieder.", + "membersRemove": "Übertragen Sie die Inhaberschaft oder entfernen Sie die Mitglieder, bevor Sie Ihr Konto löschen.", "otherReasonLabel": "Anderer Grund", - "paidPlanDowngrade": "Bitte stufen Sie auf Personal herab, um eine Kontolöschung zu beantragen.", + "paidPlanCancel": "Kündigen Sie es, bevor Sie Ihr Konto löschen.", "paidPlanNotice": "Sie haben ein kostenpflichtiges Abonnement.", - "permanentWarning": "Ich verstehe, dass dies endgültig ist und Konten sowie zugehörige Geräte nicht wiederhergestellt werden können.", "reasonAnotherAccount": "Habe ein anderes Konto", "reasonConnectionQuality": "Probleme mit der Verbindungsqualität oder Leistung", "reasonCost": "Kosten des Dienstes", @@ -701,8 +733,7 @@ "reasonTooHard": "Zu schwer zu bedienen", "reasonUnsupportedDevice": "Mein Gerät wird nicht unterstützt", "reasonUsingSomethingElse": "Nutze etwas anderes", - "snackbar": "Ihre Anfrage zur Kontolöschung wurde gesendet.", - "turnaround": "Löschanfragen benötigen 3 bis 5 Werktage zur Bearbeitung." + "removeButton": "So entfernen Sie Remote.It" }, "deleteDevice": { "deletingDevices": "Geräte werden gelöscht.", @@ -1588,6 +1619,10 @@ "removeMembersWarning": "Dadurch werden alle Ihre Mitglieder und ihr Zugriff auf Ihre Geräte entfernt.", "settings": "Einstellungen" }, + "ownedDevicesList": { + "more_one": "und {{count}} weiteres", + "more_other": "und {{count}} weitere" + }, "partnerStatsDetailPanel": { "activated": "Aktiviert", "activeLast30Days": "Aktiv (letzte 30 Tage)", @@ -1843,6 +1878,21 @@ "guideTitle": "Gerät hinzufügen", "managePermissionRequired": "Sie benötigen die Berechtigung „Verwalten“, um ein Gerät zu dieser Organisation hinzuzufügen." }, + "removeRemoteitDialog": { + "debian": "Raspberry Pi, Ubuntu und andere Debian-basierte Linux-Systeme", + "desktopMacLinux": "Desktop-App unter macOS oder Linux", + "desktopMacLinuxSteps": "Öffnen Sie die Einstellungen, dann „Erweitert“, und wählen Sie „Deinstallieren“.", + "desktopWindows": "Desktop-App unter Windows", + "desktopWindowsSteps": "Deinstallieren Sie Remote.It in den Windows-Einstellungen unter „Apps“.", + "intro": "Beim Löschen Ihres Kontos wird Remote.It nicht deinstalliert. Entfernen Sie es von jedem Ihrer Geräte, bevor Sie Ihr Konto löschen.", + "localAccess": "Deinstallieren Sie direkt am Gerät oder über Ihr lokales Netzwerk. Wenn Sie Remote.It über eine Remote.It-Verbindung entfernen, wird diese Verbindung sofort getrennt.", + "openwrt": "OpenWrt", + "otherDevices": "Anleitungen für andere Geräte", + "thisDevice": "Die Registrierung dieses Geräts wird automatisch aufgehoben, wenn Sie Ihr Konto löschen.", + "title": "Remote.It von Ihren Geräten entfernen", + "yourDevices_one": "Ihre Geräte ({{count}})", + "yourDevices_other": "Ihre Geräte ({{count}})" + }, "rentANodeForm": { "addDns": "Öffentliche DNS-Adresse hinzufügen", "addIpv6": "Öffentliche IPv6-Adresse hinzufügen", diff --git a/frontend/src/i18n/locales/en/app.json b/frontend/src/i18n/locales/en/app.json index 91f89ea72..707fab785 100644 --- a/frontend/src/i18n/locales/en/app.json +++ b/frontend/src/i18n/locales/en/app.json @@ -450,6 +450,7 @@ "common": { "actionCannotBeUndone": "This action cannot be undone.", "areYouSure": "Are you sure?", + "back": "Back", "cancel": "Cancel", "cannotBeUndone": "This action cannot be undone.", "clear": "Clear", @@ -679,17 +680,48 @@ "title": "Delete Access Key", "warning": "This action is permanent and cannot be undone." }, + "deleteAccountDialog": { + "acknowledge": "I understand that Remote.It stays installed and running on my devices, and deleting my account won't remove it.", + "codeIntro": "To confirm, we'll email a code to {{email}}.", + "codePlaceholder": "Code", + "codeSent": "Enter the code we sent to {{email}}. It expires in 10 minutes.", + "confirmTitle": "Delete your account", + "consequenceDevices": "The devices you own are removed from your account", + "consequenceOrganization": "Your organization and its roles are deleted", + "consequenceShares": "Devices shared with you and your memberships in other organizations are removed", + "consequenceSignIn": "Your sign-in and access keys stop working", + "deleteButton": "Delete account permanently", + "deleting": "Deleting…", + "devicesBody": "Deleting your account removes your devices from it, but it doesn't uninstall Remote.It. The software keeps running on every device it's installed on until you remove it.", + "devicesOwned_one": "You own {{count}} device", + "devicesOwned_other": "You own {{count}} devices", + "devicesTitle": "Remote.It will keep running on your devices", + "doneBody": "Thank you for using Remote.It. Signing you out…", + "doneTitle": "Your account has been deleted", + "feedbackOptional": "Optional — telling us why it didn't work out helps us improve.", + "feedbackTitle": "Why are you leaving?", + "genericError": "Something went wrong. Please try again.", + "invalidCode": "That code is incorrect or has expired.", + "permanent": "This happens immediately and can't be undone.", + "resendCode": "Send a new code", + "sendCode": "Email me a code", + "sending": "Sending…", + "thisDevice": "This device will be unregistered when your account is deleted.", + "tooManyAttempts": "Too many incorrect codes. Request a new code to try again.", + "unregisterFailed": "This device couldn't be unregistered, so your account was not deleted. Try again, or unregister this device from its device page first.", + "unregistering": "Unregistering this device…" + }, "deleteAccountSection": { - "confirmHelp": "Please help us improve by telling us why it didn't work out.", "confirmSorry": "We are sorry to see you go!", - "confirmTitle": "Why do you want to delete your account?", "contactMeLabel": "I'm open to having someone contact me about my feedback.", "deleteButton": "Delete my account", - "description": "If you no longer want/need your Remote.It account, you can request an account deletion. Once your delete request is processed, all your account information is removed permanently.", + "description": "Deleting your account is immediate and permanent. It doesn't uninstall Remote.It from your devices, so remove it from each device first.", + "membersNotice_one": "Your organization has {{count}} other member.", + "membersNotice_other": "Your organization has {{count}} other members.", + "membersRemove": "Transfer ownership or remove them before deleting your account.", "otherReasonLabel": "Other Reason", - "paidPlanDowngrade": "Please downgrade to Personal to request an account deletion.", + "paidPlanCancel": "Cancel it before deleting your account.", "paidPlanNotice": "You have a paid subscription plan.", - "permanentWarning": "I understand that this is permanent and that accounts and related devices can not be recovered.", "reasonAnotherAccount": "Have another account", "reasonConnectionQuality": "Connection quality or performance issues", "reasonCost": "Cost of service", @@ -701,8 +733,7 @@ "reasonTooHard": "Too hard to use", "reasonUnsupportedDevice": "My device isn’t supported", "reasonUsingSomethingElse": "Using something else", - "snackbar": "Your account delete request has been sent.", - "turnaround": "Deletion requests take 3 to 5 business days to complete." + "removeButton": "How to remove Remote.It" }, "deleteDevice": { "deletingDevices": "deleting devices.", @@ -1588,6 +1619,10 @@ "removeMembersWarning": "This will remove all your members and their access to your devices.", "settings": "Settings" }, + "ownedDevicesList": { + "more_one": "and {{count}} more", + "more_other": "and {{count}} more" + }, "partnerStatsDetailPanel": { "activated": "Activated", "activeLast30Days": "Active (Last 30 Days)", @@ -1843,6 +1878,21 @@ "guideTitle": "Add a device", "managePermissionRequired": "Manage permission required to add a device to this organization." }, + "removeRemoteitDialog": { + "debian": "Raspberry Pi, Ubuntu and other Debian Linux", + "desktopMacLinux": "Desktop app on macOS or Linux", + "desktopMacLinuxSteps": "Open Settings, then Advanced, and select Uninstall.", + "desktopWindows": "Desktop app on Windows", + "desktopWindowsSteps": "Uninstall Remote.It from Windows Settings, under Apps.", + "intro": "Deleting your account doesn't uninstall Remote.It. Remove it from each device you own before you delete your account.", + "localAccess": "Uninstall from the device itself or over your local network. Removing Remote.It through a Remote.It connection ends that connection right away.", + "openwrt": "OpenWrt", + "otherDevices": "Instructions for other devices", + "thisDevice": "This device is unregistered automatically when you delete your account.", + "title": "Remove Remote.It from your devices", + "yourDevices_one": "Your devices ({{count}})", + "yourDevices_other": "Your devices ({{count}})" + }, "rentANodeForm": { "addDns": "Add a public DNS address", "addIpv6": "Add a public IPv6 address", diff --git a/frontend/src/i18n/locales/es/app.json b/frontend/src/i18n/locales/es/app.json index d43e042b1..2310c651f 100644 --- a/frontend/src/i18n/locales/es/app.json +++ b/frontend/src/i18n/locales/es/app.json @@ -454,13 +454,14 @@ "common": { "actionCannotBeUndone": "Esta acción no se puede deshacer.", "areYouSure": "¿Estás seguro?", + "back": "Atrás", "cancel": "Cancelar", "cannotBeUndone": "Esta acción no se puede deshacer.", "clear": "Borrar", "close": "Cerrar", "confirm": "Confirmar", "confirmingEllipsis": "Confirmando...", - "continue": "", + "continue": "Continuar", "delete": "Eliminar", "disable": "Deshabilitar", "done": "Listo", @@ -683,17 +684,50 @@ "title": "Eliminar clave de acceso", "warning": "Esta acción es permanente y no se puede deshacer." }, + "deleteAccountDialog": { + "acknowledge": "Entiendo que Remote.It seguirá instalado y en ejecución en mis dispositivos, y que eliminar mi cuenta no lo desinstala.", + "codeIntro": "Para confirmar, enviaremos un código por correo a {{email}}.", + "codePlaceholder": "Código", + "codeSent": "Introduce el código que enviamos a {{email}}. Caduca en 10 minutos.", + "confirmTitle": "Eliminar tu cuenta", + "consequenceDevices": "Los dispositivos de tu propiedad se quitan de tu cuenta", + "consequenceOrganization": "Tu organización y sus roles se eliminan", + "consequenceShares": "Se quitan los dispositivos compartidos contigo y tus membresías en otras organizaciones", + "consequenceSignIn": "Tu inicio de sesión y tus claves de acceso dejan de funcionar", + "deleteButton": "Eliminar la cuenta definitivamente", + "deleting": "Eliminando…", + "devicesBody": "Al eliminar tu cuenta, tus dispositivos se quitan de ella, pero Remote.It no se desinstala. El software sigue funcionando en cada dispositivo donde está instalado hasta que lo quites.", + "devicesOwned_one": "Tienes {{count}} dispositivo", + "devicesOwned_many": "Tienes {{count}} dispositivos", + "devicesOwned_other": "Tienes {{count}} dispositivos", + "devicesTitle": "Remote.It seguirá funcionando en tus dispositivos", + "doneBody": "Gracias por usar Remote.It. Cerrando sesión…", + "doneTitle": "Tu cuenta se ha eliminado", + "feedbackOptional": "Opcional: contarnos por qué no funcionó nos ayuda a mejorar.", + "feedbackTitle": "¿Por qué te vas?", + "genericError": "Algo salió mal. Inténtalo de nuevo.", + "invalidCode": "El código es incorrecto o ha caducado.", + "permanent": "Esto ocurre de inmediato y no se puede deshacer.", + "resendCode": "Enviar un código nuevo", + "sendCode": "Enviarme un código", + "sending": "Enviando…", + "thisDevice": "Se anulará el registro de este dispositivo cuando se elimine tu cuenta.", + "tooManyAttempts": "Demasiados códigos incorrectos. Solicita un código nuevo para volver a intentarlo.", + "unregisterFailed": "No se pudo anular el registro de este dispositivo, así que tu cuenta no se eliminó. Inténtalo de nuevo o anula primero el registro desde la página del dispositivo.", + "unregistering": "Anulando el registro de este dispositivo…" + }, "deleteAccountSection": { - "confirmHelp": "Ayúdanos a mejorar contándonos por qué no funcionó.", "confirmSorry": "¡Lamentamos que te vayas!", - "confirmTitle": "¿Por qué quieres eliminar tu cuenta?", "contactMeLabel": "Acepto que alguien se ponga en contacto conmigo sobre mis comentarios.", "deleteButton": "Eliminar mi cuenta", - "description": "Si ya no quieres o necesitas tu cuenta de Remote.It, puedes solicitar su eliminación. Una vez procesada la solicitud, toda la información de tu cuenta se eliminará de forma permanente.", + "description": "Eliminar tu cuenta es inmediato y permanente. No desinstala Remote.It de tus dispositivos, así que quítalo primero de cada uno.", + "membersNotice_one": "Tu organización tiene {{count}} miembro más.", + "membersNotice_many": "Tu organización tiene {{count}} miembros más.", + "membersNotice_other": "Tu organización tiene {{count}} miembros más.", + "membersRemove": "Transfiere la propiedad o quítalos antes de eliminar tu cuenta.", "otherReasonLabel": "Otro motivo", - "paidPlanDowngrade": "Cambia a un plan Personal para poder solicitar la eliminación de tu cuenta.", + "paidPlanCancel": "Cancélalo antes de eliminar tu cuenta.", "paidPlanNotice": "Tienes un plan de suscripción pago.", - "permanentWarning": "Entiendo que esto es permanente y que las cuentas y los dispositivos relacionados no se pueden recuperar.", "reasonAnotherAccount": "Tengo otra cuenta", "reasonConnectionQuality": "Problemas de calidad de conexión o rendimiento", "reasonCost": "Costo del servicio", @@ -705,8 +739,7 @@ "reasonTooHard": "Es demasiado difícil de usar", "reasonUnsupportedDevice": "Mi dispositivo no es compatible", "reasonUsingSomethingElse": "Uso otra cosa", - "snackbar": "Se envió tu solicitud de eliminación de cuenta.", - "turnaround": "Las solicitudes de eliminación tardan de 3 a 5 días hábiles en completarse." + "removeButton": "Cómo quitar Remote.It" }, "deleteDevice": { "deletingDevices": "eliminando dispositivos.", @@ -1603,6 +1636,11 @@ "removeMembersWarning": "Esto eliminará a todos tus miembros y su acceso a tus dispositivos.", "settings": "Configuración" }, + "ownedDevicesList": { + "more_one": "y {{count}} más", + "more_many": "y {{count}} más", + "more_other": "y {{count}} más" + }, "partnerStatsDetailPanel": { "activated": "Activado", "activeLast30Days": "Activo (últimos 30 días)", @@ -1866,6 +1904,22 @@ "guideTitle": "Añadir un dispositivo", "managePermissionRequired": "Debes tener el permiso \"Gestionar\" para añadir un dispositivo a esta organización." }, + "removeRemoteitDialog": { + "debian": "Raspberry Pi, Ubuntu y otros Linux basados en Debian", + "desktopMacLinux": "App de escritorio en macOS o Linux", + "desktopMacLinuxSteps": "Abre Configuración, luego Avanzado, y selecciona Desinstalar.", + "desktopWindows": "App de escritorio en Windows", + "desktopWindowsSteps": "Desinstala Remote.It desde la Configuración de Windows, en Aplicaciones.", + "intro": "Eliminar tu cuenta no desinstala Remote.It. Quítalo de cada dispositivo que tengas antes de eliminar tu cuenta.", + "localAccess": "Desinstálalo desde el propio dispositivo o a través de tu red local. Si quitas Remote.It mediante una conexión de Remote.It, esa conexión se corta de inmediato.", + "openwrt": "OpenWrt", + "otherDevices": "Instrucciones para otros dispositivos", + "thisDevice": "El registro de este dispositivo se anula automáticamente cuando eliminas tu cuenta.", + "title": "Quitar Remote.It de tus dispositivos", + "yourDevices_one": "Tus dispositivos ({{count}})", + "yourDevices_many": "Tus dispositivos ({{count}})", + "yourDevices_other": "Tus dispositivos ({{count}})" + }, "rentANodeForm": { "addDns": "Añadir una dirección DNS pública", "addIpv6": "Añadir una dirección IPv6 pública", diff --git a/frontend/src/i18n/locales/ja/app.json b/frontend/src/i18n/locales/ja/app.json index 08f28f7d1..89362c18d 100644 --- a/frontend/src/i18n/locales/ja/app.json +++ b/frontend/src/i18n/locales/ja/app.json @@ -446,13 +446,14 @@ "common": { "actionCannotBeUndone": "この操作は元に戻せません。", "areYouSure": "本当によろしいですか?", + "back": "戻る", "cancel": "キャンセル", "cannotBeUndone": "この操作は元に戻せません。", "clear": "クリア", "close": "閉じる", "confirm": "確認", "confirmingEllipsis": "確認中...", - "continue": "", + "continue": "続行", "delete": "削除", "disable": "無効にする", "done": "完了", @@ -675,17 +676,46 @@ "title": "アクセスキーを削除", "warning": "この操作は取り消せず、元に戻せません。" }, + "deleteAccountDialog": { + "acknowledge": "Remote.It はデバイスにインストールされたまま動作し続け、アカウントを削除しても削除されないことを理解しました。", + "codeIntro": "確認のため、{{email}} にコードをメールでお送りします。", + "codePlaceholder": "コード", + "codeSent": "{{email}} に送信したコードを入力してください。有効期限は10分です。", + "confirmTitle": "アカウントを削除", + "consequenceDevices": "所有しているデバイスがアカウントから削除されます", + "consequenceOrganization": "組織とそのロールが削除されます", + "consequenceShares": "共有されているデバイスと、他の組織のメンバーシップが削除されます", + "consequenceSignIn": "サインインとアクセスキーが使えなくなります", + "deleteButton": "アカウントを完全に削除", + "deleting": "削除中…", + "devicesBody": "アカウントを削除するとデバイスはアカウントから外れますが、Remote.It はアンインストールされません。ソフトウェアは、削除するまでインストールされているすべてのデバイスで動作し続けます。", + "devicesOwned_other": "所有しているデバイス: {{count}}台", + "devicesTitle": "Remote.It はデバイス上で動作し続けます", + "doneBody": "Remote.It をご利用いただきありがとうございました。サインアウトしています…", + "doneTitle": "アカウントを削除しました", + "feedbackOptional": "任意 — うまくいかなかった理由を教えていただけると、改善に役立ちます。", + "feedbackTitle": "退会の理由を教えてください", + "genericError": "問題が発生しました。もう一度お試しください。", + "invalidCode": "コードが正しくないか、有効期限が切れています。", + "permanent": "この操作はすぐに実行され、元に戻せません。", + "resendCode": "新しいコードを送信", + "sendCode": "コードをメールで受け取る", + "sending": "送信中…", + "thisDevice": "アカウントを削除すると、このデバイスの登録は解除されます。", + "tooManyAttempts": "誤ったコードの入力が多すぎます。新しいコードをリクエストしてやり直してください。", + "unregisterFailed": "このデバイスの登録を解除できなかったため、アカウントは削除されていません。もう一度お試しいただくか、先にデバイスのページからこのデバイスの登録を解除してください。", + "unregistering": "このデバイスの登録を解除中…" + }, "deleteAccountSection": { - "confirmHelp": "うまくいかなかった理由を教えていただき、改善にご協力ください。", "confirmSorry": "退会されるとのこと、残念です。", - "confirmTitle": "アカウントを削除する理由は何ですか?", "contactMeLabel": "フィードバックについて連絡を受けても構いません。", "deleteButton": "アカウントを削除する", - "description": "Remote.It アカウントが不要になった場合は、アカウントの削除をリクエストできます。削除リクエストが処理されると、アカウント情報はすべて完全に削除されます。", + "description": "アカウントの削除はすぐに実行され、元に戻せません。デバイスから Remote.It はアンインストールされないため、先に各デバイスから削除してください。", + "membersNotice_other": "組織には他に {{count}} 人のメンバーがいます。", + "membersRemove": "アカウントを削除する前に、所有権を移転するかメンバーを削除してください。", "otherReasonLabel": "その他の理由", - "paidPlanDowngrade": "アカウントの削除をリクエストするには、Personalプランにダウングレードしてください。", + "paidPlanCancel": "アカウントを削除する前に解約してください。", "paidPlanNotice": "有料サブスクリプションプランをご利用中です。", - "permanentWarning": "これは永久的な操作であり、アカウントおよび関連するデバイスは復元できないことを理解しています。", "reasonAnotherAccount": "別のアカウントを持っている", "reasonConnectionQuality": "接続品質またはパフォーマンスの問題", "reasonCost": "サービスの費用", @@ -697,8 +727,7 @@ "reasonTooHard": "使いにくい", "reasonUnsupportedDevice": "自分のデバイスがサポートされていない", "reasonUsingSomethingElse": "別のものを使用している", - "snackbar": "アカウント削除のリクエストを送信しました。", - "turnaround": "削除リクエストの完了には3〜5営業日かかります。" + "removeButton": "Remote.It の削除方法" }, "deleteDevice": { "deletingDevices": "デバイスを削除しています。", @@ -1573,6 +1602,9 @@ "removeMembersWarning": "これにより、すべてのメンバーとデバイスへのアクセス権が削除されます。", "settings": "設定" }, + "ownedDevicesList": { + "more_other": "他 {{count}} 台" + }, "partnerStatsDetailPanel": { "activated": "有効化済み", "activeLast30Days": "アクティブ (過去30日間)", @@ -1820,6 +1852,20 @@ "guideTitle": "デバイスを追加", "managePermissionRequired": "この組織にデバイスを追加するには「管理」権限が必要です。" }, + "removeRemoteitDialog": { + "debian": "Raspberry Pi、Ubuntu、その他の Debian 系 Linux", + "desktopMacLinux": "macOS または Linux のデスクトップアプリ", + "desktopMacLinuxSteps": "設定を開き、「詳細設定」から「アンインストール」を選択します。", + "desktopWindows": "Windows のデスクトップアプリ", + "desktopWindowsSteps": "Windows の設定の「アプリ」から Remote.It をアンインストールします。", + "intro": "アカウントを削除しても Remote.It はアンインストールされません。アカウントを削除する前に、所有している各デバイスから削除してください。", + "localAccess": "デバイス本体またはローカルネットワーク経由でアンインストールしてください。Remote.It の接続を使って Remote.It を削除すると、その接続はすぐに切断されます。", + "openwrt": "OpenWrt", + "otherDevices": "その他のデバイスの手順", + "thisDevice": "このデバイスは、アカウントを削除すると自動的に登録解除されます。", + "title": "デバイスから Remote.It を削除する", + "yourDevices_other": "所有デバイス ({{count}})" + }, "rentANodeForm": { "addDns": "公開DNSアドレスを追加", "addIpv6": "公開IPv6アドレスを追加", From 2bc87df817e209face7cebdbe3e5605ae1efebee Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:36:00 -0700 Subject: [PATCH 5/9] refactor(profile): simplify account deletion dialogs and fetch devices on demand --- .../components/DeleteAccountDialog.test.tsx | 110 ++++++++------ .../src/components/DeleteAccountDialog.tsx | 138 ++++++++---------- .../src/components/DeleteAccountSection.tsx | 63 +++----- frontend/src/components/OwnedDevicesList.tsx | 72 ++++----- .../src/components/RemoveRemoteitDialog.tsx | 121 ++++++++------- frontend/src/hooks/useOwnedDevices.ts | 38 +++++ frontend/src/i18n/locales/de/app.json | 5 +- frontend/src/i18n/locales/en/app.json | 5 +- frontend/src/i18n/locales/es/app.json | 5 +- frontend/src/i18n/locales/ja/app.json | 5 +- frontend/src/services/graphQL.ts | 5 +- frontend/src/services/graphQLDevice.ts | 6 +- 12 files changed, 289 insertions(+), 284 deletions(-) create mode 100644 frontend/src/hooks/useOwnedDevices.ts diff --git a/frontend/src/components/DeleteAccountDialog.test.tsx b/frontend/src/components/DeleteAccountDialog.test.tsx index 15c2244ec..28e9e219b 100644 --- a/frontend/src/components/DeleteAccountDialog.test.tsx +++ b/frontend/src/components/DeleteAccountDialog.test.tsx @@ -10,13 +10,19 @@ const dispatch = vi.hoisted(() => ({ })) vi.mock('../services/graphQLMutation', () => api) vi.mock('../store', () => ({})) -vi.mock('../helpers/sleep', () => ({ default: () => Promise.resolve() })) -vi.mock('./TargetPlatform', () => ({ TargetPlatform: () => null })) -vi.mock('react-redux', () => ({ - useDispatch: () => dispatch, - useSelector: (select: (state: any) => any) => - select({ user: { id: 'ME', email: 'me@example.com', created: new Date(0) }, connections: { all: [] } }), +vi.mock('../helpers/sleep', () => ({ + default: () => Promise.resolve(), + withTimeout: (promise: Promise) => promise, })) +vi.mock('./TargetPlatform', () => ({ TargetPlatform: () => null })) +vi.mock('react-redux', () => { + const state = { user: { id: 'ME', email: 'me@example.com', created: new Date(0) }, connections: { all: [] } } + return { + useDispatch: () => dispatch, + useStore: () => ({ getState: () => state }), + useSelector: (select: (state: any) => any) => select(state), + } +}) vi.mock('react-i18next', () => ({ initReactI18next: { type: '3rdParty', init: () => {} }, useTranslation: () => ({ @@ -32,19 +38,17 @@ import { ThemeProvider } from '@mui/material' import { createTheme } from '@mui/material/styles' import { jssTheme } from '../styling/theme' import { DeleteAccountDialog } from './DeleteAccountDialog' -import { OwnedDevices } from './OwnedDevicesList' +import { OwnedDevices } from '../hooks/useOwnedDevices' Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }) const theme = createTheme(jssTheme(false)) -const THIS_ID = 'THIS' const owned = (thisDeviceOwned: boolean): OwnedDevices => ({ - total: 3, + total: 2, thisDeviceOwned, devices: [ - { id: 'OFF', name: 'Offline NAS', state: 'inactive', platform: 0 }, - { id: THIS_ID, name: 'This laptop', state: 'active', platform: 0 }, { id: 'ON', name: 'Online Pi', state: 'active', platform: 0 }, + { id: 'OFF', name: 'Offline NAS', state: 'inactive', platform: 0 }, ], }) @@ -62,6 +66,8 @@ const click = async (label: string) => { await act(async () => button(label).click()) await flush() } +const check = (index = 0) => + act(async () => (dialog().querySelectorAll('input[type=checkbox]')[index] as HTMLInputElement).click()) const typeCode = async (code: string) => { const input = dialog().querySelector('input[autocomplete=one-time-code]') as HTMLInputElement await act(async () => { @@ -69,29 +75,31 @@ const typeCode = async (code: string) => { input.dispatchEvent(new Event('input', { bubbles: true })) }) } -const render = async (devices = owned(true), thisId = THIS_ID) => { +const render = async (devices = owned(true)) => { await act(async () => root.render( - + ) ) await flush() } -const toConfirm = async () => { - await act(async () => (dialog().querySelector('input[type=checkbox]') as HTMLInputElement).click()) +const toFeedback = async () => { + await check() await click('Continue') +} +const toConfirm = async () => { await click('Continue') await click('Email me a code') } +const submit = async (code = 'ABC234') => { + await typeCode(code) + await click('Delete account permanently') +} beforeEach(() => { - Object.values(api).forEach(fn => fn.mockReset()) - dispatch.backend.unregisterThisDevice.mockReset() - dispatch.feedback.set.mockReset() - dispatch.feedback.sendFeedback.mockReset() - dispatch.auth.signOut.mockReset() + vi.resetAllMocks() api.graphQLRequestAccountDeletion.mockResolvedValue({ ok: true }) container = document.createElement('div') document.body.appendChild(container) @@ -103,13 +111,16 @@ afterEach(() => { }) describe('DeleteAccountDialog', () => { - it('holds Continue until the person accepts that Remote.It stays on their other devices', async () => { + it('holds Continue until the person accepts that Remote.It stays on their devices', async () => { await render() - const names = [...dialog().querySelectorAll('li')].map(item => item.textContent) - expect(names).toEqual(['Online PiOnline', 'Offline NASOffline']) + expect([...dialog().querySelectorAll('li')].map(item => item.textContent)).toEqual([ + 'Online PiOnline', + 'Offline NASOffline', + ]) expect(dialog().textContent).toContain('You own 2 devices') + expect(dialog().textContent).toContain('This device is unregistered automatically') expect(button('Continue').disabled).toBe(true) - await act(async () => (dialog().querySelector('input[type=checkbox]') as HTMLInputElement).click()) + await check() expect(button('Continue').disabled).toBe(false) }) @@ -117,9 +128,9 @@ describe('DeleteAccountDialog', () => { dispatch.backend.unregisterThisDevice.mockResolvedValue(true) api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) await render() + await toFeedback() await toConfirm() - await typeCode('abc234') - await click('Delete account permanently') + await submit('abc234') expect(api.graphQLDeleteAccount).toHaveBeenCalledWith('ABC234') expect(dispatch.backend.unregisterThisDevice.mock.invocationCallOrder[0]).toBeLessThan( @@ -133,9 +144,9 @@ describe('DeleteAccountDialog', () => { it('never deletes the account when this device could not be unregistered', async () => { dispatch.backend.unregisterThisDevice.mockResolvedValue(false) await render() + await toFeedback() await toConfirm() - await typeCode('ABC234') - await click('Delete account permanently') + await submit() expect(api.graphQLDeleteAccount).not.toHaveBeenCalled() expect(dialog().textContent).toContain("This device couldn't be unregistered") @@ -145,9 +156,9 @@ describe('DeleteAccountDialog', () => { it('leaves a device registered to someone else alone', async () => { api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) await render(owned(false)) + await toFeedback() await toConfirm() - await typeCode('ABC234') - await click('Delete account permanently') + await submit() expect(dispatch.backend.unregisterThisDevice).not.toHaveBeenCalled() expect(api.graphQLDeleteAccount).toHaveBeenCalled() @@ -156,14 +167,13 @@ describe('DeleteAccountDialog', () => { it('asks for a new code after the fifth wrong one', async () => { api.graphQLDeleteAccount.mockResolvedValue({ ok: false, code: 'NOT_AUTHORIZED', message: 'Not Authorized' }) await render(owned(false)) + await toFeedback() await toConfirm() for (let attempt = 1; attempt <= 4; attempt++) { - await typeCode('ABC234') - await click('Delete account permanently') + await submit() expect(dialog().textContent).toContain('That code is incorrect or has expired.') } - await typeCode('ABC234') - await click('Delete account permanently') + await submit() expect(api.graphQLDeleteAccount).toHaveBeenCalledTimes(5) expect(dialog().textContent).toContain('Too many incorrect codes') @@ -174,28 +184,40 @@ describe('DeleteAccountDialog', () => { api.graphQLDeleteAccount.mockResolvedValue({ ok: false, code: 'INVALID_ARGUMENT', - message: 'your subscription is still active — cancel it first', + message: 'Invalid Arguments: your subscription is still active — cancel it first', + args: ['your subscription is still active — cancel it first'], }) await render(owned(false)) + await toFeedback() await toConfirm() - await typeCode('ABC234') - await click('Delete account permanently') + await submit() expect(dialog().textContent).toContain('Your subscription is still active — cancel it first') + expect(dialog().textContent).not.toContain('Invalid Arguments') expect(button('Email me a code')).toBeTruthy() expect(dispatch.auth.signOut).not.toHaveBeenCalled() }) + it('keeps the code after a network failure, so the person can retry it', async () => { + api.graphQLDeleteAccount.mockResolvedValueOnce({ ok: false }).mockResolvedValueOnce({ ok: true }) + await render(owned(false)) + await toFeedback() + await toConfirm() + await submit() + + expect(dialog().textContent).toContain('Something went wrong. Please try again.') + await click('Delete account permanently') + expect(api.graphQLDeleteAccount).toHaveBeenLastCalledWith('ABC234') + expect(dispatch.auth.signOut).toHaveBeenCalled() + }) + it('sends the survey only when the person filled it in', async () => { api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) await render(owned(false)) - await act(async () => (dialog().querySelector('input[type=checkbox]') as HTMLInputElement).click()) - await click('Continue') - await act(async () => (dialog().querySelectorAll('input[type=checkbox]')[0] as HTMLInputElement).click()) - await click('Continue') - await click('Email me a code') - await typeCode('ABC234') - await click('Delete account permanently') + await toFeedback() + await check() + await toConfirm() + await submit() expect(dispatch.feedback.set).toHaveBeenCalledWith( expect.objectContaining({ diff --git a/frontend/src/components/DeleteAccountDialog.tsx b/frontend/src/components/DeleteAccountDialog.tsx index 7101d0933..9db41bf26 100644 --- a/frontend/src/components/DeleteAccountDialog.tsx +++ b/frontend/src/components/DeleteAccountDialog.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useState } from 'react' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import { useDispatch, useSelector } from 'react-redux' +import { useDispatch, useSelector, useStore } from 'react-redux' import { Box, Button, @@ -18,16 +18,18 @@ import { import { Dispatch, State } from '../store' import { graphQLDeleteAccount, graphQLRequestAccountDeletion } from '../services/graphQLMutation' import { GraphQLInlineResult } from '../services/graphQL' -import { OwnedDevices, OwnedDevicesList, otherOwnedDevices } from './OwnedDevicesList' +import { OwnedDevices } from '../hooks/useOwnedDevices' +import { OwnedDevicesList } from './OwnedDevicesList' import { ListItemCheckbox } from './ListItemCheckbox' import { Notice } from './Notice' import { Icon } from './Icon' import { spacing } from '../styling' -import sleep from '../helpers/sleep' +import sleep, { withTimeout } from '../helpers/sleep' const CODE_LENGTH = 6 const MAX_ATTEMPTS = 5 const SIGN_OUT_DELAY = 3000 +const FEEDBACK_TIMEOUT = 10000 type Step = 'devices' | 'feedback' | 'confirm' | 'done' type Busy = 'sending' | 'unregistering' | 'deleting' @@ -35,16 +37,15 @@ type Busy = 'sending' | 'unregistering' | 'deleting' type Props = { open: boolean owned?: OwnedDevices - thisId?: string onShowInstructions: () => void onClose: () => void } -export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onShowInstructions, onClose }) => { +export const DeleteAccountDialog: React.FC = ({ open, owned, onShowInstructions, onClose }) => { const { t } = useTranslation() const dispatch = useDispatch() + const store = useStore() const user = useSelector((state: State) => state.user) - const connections = useSelector((state: State) => state.connections.all) const [step, setStep] = useState('devices') const [acknowledged, setAcknowledged] = useState(false) const [reasons, setReasons] = useState([]) @@ -56,9 +57,8 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh const [busy, setBusy] = useState() const [error, setError] = useState() - const unregisterThisDevice = !!(owned?.thisDeviceOwned && thisId) - const others = owned && otherOwnedDevices(owned, thisId) const locked = !!busy || step === 'done' + const ready = !busy && (!codeSent || code.length === CODE_LENGTH) const REASONS = [ t('deleteAccountSection.reasonUnsupportedDevice', 'My device isn’t supported'), @@ -74,20 +74,12 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh t('deleteAccountSection.reasonUsingSomethingElse', 'Using something else'), ] - useEffect(() => { - if (!open) return - setStep('devices') - setAcknowledged(false) - setCodeSent(false) - setCode('') - setFailures(0) - setError(undefined) - }, [open]) - - const refusal = (result: GraphQLInlineResult) => - result.message - ? result.message.charAt(0).toUpperCase() + result.message.slice(1) + const refusal = ({ message, args }: GraphQLInlineResult) => { + const reason = Array.isArray(args) ? args.join(' ') : message + return reason + ? reason.charAt(0).toUpperCase() + reason.slice(1) : t('deleteAccountDialog.genericError', 'Something went wrong. Please try again.') + } const goTo = (next: Step) => { setError(undefined) @@ -123,7 +115,7 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh day: 'numeric', year: 'numeric', }), - lastConnections: connections.slice(0, 5), + lastConnections: store.getState().connections.all.slice(0, 5), }, snackbar: t('deleteAccountDialog.doneTitle', 'Your account has been deleted'), }) @@ -133,7 +125,7 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh const deleteAccount = async () => { setError(undefined) - if (unregisterThisDevice) { + if (owned?.thisDeviceOwned) { setBusy('unregistering') if (!(await dispatch.backend.unregisterThisDevice())) { setBusy(undefined) @@ -150,23 +142,25 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh const result = await graphQLDeleteAccount(code) setBusy(undefined) - if (!result.ok) { - const attempts = result.code === 'NOT_AUTHORIZED' ? failures + 1 : MAX_ATTEMPTS + if (result.code === 'NOT_AUTHORIZED') { + const attempts = failures + 1 setFailures(attempts) setCode('') if (attempts < MAX_ATTEMPTS) return setError(t('deleteAccountDialog.invalidCode', 'That code is incorrect or has expired.')) setCodeSent(false) return setError( - result.code === 'NOT_AUTHORIZED' - ? t('deleteAccountDialog.tooManyAttempts', 'Too many incorrect codes. Request a new code to try again.') - : refusal(result) + t('deleteAccountDialog.tooManyAttempts', 'Too many incorrect codes. Request a new code to try again.') ) } + if (!result.ok) { + if (result.code) setCodeSent(false) + return setError(refusal(result)) + } + setStep('done') - await sendFeedback() - await sleep(SIGN_OUT_DELAY) + await Promise.all([withTimeout(sendFeedback(), FEEDBACK_TIMEOUT), sleep(SIGN_OUT_DELAY)]) dispatch.auth.signOut() } @@ -195,6 +189,16 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh { icon: 'sign-out', text: t('deleteAccountDialog.consequenceSignIn', 'Your sign-in and access keys stop working') }, ] + const actions = (left: React.ReactNode, primary: React.ReactNode) => ( + + {left} + + {primary} + + ) + return ( {step === 'devices' && ( @@ -209,21 +213,13 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh "Deleting your account removes your devices from it, but it doesn't uninstall Remote.It. The software keeps running on every device it's installed on until you remove it." )} - {owned && others && others.devices.length > 0 && ( - - - {t('deleteAccountDialog.devicesOwned', { - count: others.total, - defaultValue: 'You own {{count}} devices', - })} - - - - )} - {unregisterThisDevice && ( - - {t('deleteAccountDialog.thisDevice', 'This device will be unregistered when your account is deleted.')} - + {owned && ( + + t('deleteAccountDialog.devicesOwned', { count, defaultValue: 'You own {{count}} devices' }) + } + /> )} = ({ open, owned, thisId, onSh /> - - - + , - + )} )} @@ -307,15 +302,12 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh onClick={setContact} /> - - - + {actions( + , - + )} )} @@ -358,7 +350,7 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh .slice(0, CODE_LENGTH) ) } - onKeyDown={e => e.key === 'Enter' && code.length === CODE_LENGTH && !busy && deleteAccount()} + onKeyDown={e => e.key === 'Enter' && ready && deleteAccount()} inputProps={{ maxLength: CODE_LENGTH, autoComplete: 'one-time-code', @@ -383,28 +375,18 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, thisId, onSh )} - - , + - - {codeSent ? ( - - ) : ( - - )} - + )} )} diff --git a/frontend/src/components/DeleteAccountSection.tsx b/frontend/src/components/DeleteAccountSection.tsx index 13106d66f..0cb8fe727 100644 --- a/frontend/src/components/DeleteAccountSection.tsx +++ b/frontend/src/components/DeleteAccountSection.tsx @@ -1,52 +1,33 @@ -import React, { useEffect, useState } from 'react' +import React, { useState } from 'react' import { useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' import { Typography, Button, Stack } from '@mui/material' import { State } from '../store' -import { isPersonal } from '../models/plans' -import { getUserId } from '../selectors/state' -import { graphQLFetchOwnedDevices } from '../services/graphQLDevice' +import { PERSONAL_PLAN_ID } from '../models/plans' +import { getOwnOrganization } from '../models/organization' +import { selectRemoteitLicense } from '../selectors/organizations' +import { useOwnedDevices } from '../hooks/useOwnedDevices' import { RemoveRemoteitDialog } from './RemoveRemoteitDialog' import { DeleteAccountDialog } from './DeleteAccountDialog' -import { OwnedDevices } from './OwnedDevicesList' import { Gutters } from './Gutters' import { Notice } from './Notice' import { Link } from './Link' -function useOwnedDevices(userId: string, thisId?: string) { - const [owned, setOwned] = useState() - - useEffect(() => { - if (!userId) return - let current = true - graphQLFetchOwnedDevices(userId, thisId).then(result => { - if (!current || result === 'ERROR') return - const login = result.data?.data?.login - const devices = login?.account?.devices - setOwned({ - total: devices?.total || 0, - devices: devices?.items || [], - thisDeviceOwned: !!login?.device?.some((device: { owner?: { id: string } }) => device.owner?.id === userId), - }) - }) - return () => { - current = false - } - }, [userId, thisId]) - - return owned -} - export const DeleteAccountSection: React.FC = () => { const { t } = useTranslation() - const userId = useSelector(getUserId) - const thisId = useSelector((state: State) => state.backend.thisId) - const paidPlan = useSelector((state: State) => !isPersonal(state)) - const members = useSelector( - (state: State) => state.organization.accounts[userId]?.members.filter(m => m.user.id !== userId).length || 0 - ) - const owned = useOwnedDevices(userId, thisId) + const userId = useSelector((state: State) => state.user.id) + const license = useSelector((state: State) => selectRemoteitLicense(state, state.user.id)) + const members = useSelector((state: State) => getOwnOrganization(state).members) const [dialog, setDialog] = useState<'remove' | 'delete'>() + const [opened, setOpened] = useState(0) + const owned = useOwnedDevices(!!dialog) + const paidPlan = !!license && license.plan.id !== PERSONAL_PLAN_ID + const otherMembers = members.filter(member => member.user.id !== userId).length + + const openDelete = () => { + setOpened(opened + 1) + setDialog('delete') + } const close = () => setDialog(undefined) return ( @@ -59,10 +40,10 @@ export const DeleteAccountSection: React.FC = () => { )} - {members > 0 && ( + {otherMembers > 0 && ( {t('deleteAccountSection.membersNotice', { - count: members, + count: otherMembers, defaultValue: 'Your organization has {{count}} other members.', })}{' '} @@ -80,15 +61,15 @@ export const DeleteAccountSection: React.FC = () => { - - + setDialog('remove')} onClose={close} /> diff --git a/frontend/src/components/OwnedDevicesList.tsx b/frontend/src/components/OwnedDevicesList.tsx index e6e783cda..a1d44312a 100644 --- a/frontend/src/components/OwnedDevicesList.tsx +++ b/frontend/src/components/OwnedDevicesList.tsx @@ -1,52 +1,44 @@ import React from 'react' import { useTranslation } from 'react-i18next' -import { List, ListItem, ListItemIcon, ListItemText, Typography } from '@mui/material' +import { Box, List, ListItem, ListItemIcon, ListItemText, Typography } from '@mui/material' +import { OwnedDevices } from '../hooks/useOwnedDevices' import { TargetPlatform } from './TargetPlatform' -import { ColorChip } from './ColorChip' +import { StatusChip } from './StatusChip' +import { Notice } from './Notice' -const SHOWN = 10 +type Props = { owned: OwnedDevices; title: (count: number) => string } -export type OwnedDevice = { id: string; name: string; state: string; platform: number } - -export type OwnedDevices = { total: number; devices: OwnedDevice[]; thisDeviceOwned: boolean } - -export function otherOwnedDevices(owned: OwnedDevices, thisId?: string) { - const isThis = (device: OwnedDevice) => owned.thisDeviceOwned && device.id === thisId - const devices = owned.devices - .filter(device => !isThis(device)) - .sort((a, b) => Number(b.state === 'active') - Number(a.state === 'active')) - .slice(0, SHOWN) - const total = owned.total - (owned.thisDeviceOwned ? 1 : 0) - return { devices, total, more: total - devices.length } -} - -export const OwnedDevicesList: React.FC<{ owned: OwnedDevices; thisId?: string }> = ({ owned, thisId }) => { +export const OwnedDevicesList: React.FC = ({ owned, title }) => { const { t } = useTranslation() - const { devices, more } = otherOwnedDevices(owned, thisId) - - if (!devices.length) return null + const more = owned.total - owned.devices.length return ( <> - - {devices.map(device => ( - - - - - - {device.state === 'active' ? ( - - ) : ( - - )} - - ))} - - {more > 0 && ( - - {t('ownedDevicesList.more', { count: more, defaultValue: 'and {{count}} more' })} - + {owned.devices.length > 0 && ( + + {title(owned.total)} + + {owned.devices.map(device => ( + + + + + + + + ))} + + {more > 0 && ( + + {t('ownedDevicesList.more', { count: more, defaultValue: 'and {{count}} more' })} + + )} + + )} + {owned.thisDeviceOwned && ( + + {t('ownedDevicesList.thisDevice', 'This device is unregistered automatically when you delete your account.')} + )} ) diff --git a/frontend/src/components/RemoveRemoteitDialog.tsx b/frontend/src/components/RemoveRemoteitDialog.tsx index b236f2761..426b6aa9f 100644 --- a/frontend/src/components/RemoveRemoteitDialog.tsx +++ b/frontend/src/components/RemoveRemoteitDialog.tsx @@ -1,8 +1,10 @@ import React from 'react' import { useTranslation } from 'react-i18next' -import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from '@mui/material' -import { OwnedDevices, OwnedDevicesList, otherOwnedDevices } from './OwnedDevicesList' +import { Stack, Typography } from '@mui/material' +import { OwnedDevices } from '../hooks/useOwnedDevices' +import { OwnedDevicesList } from './OwnedDevicesList' import { CopyCodeBlock } from './CopyCodeBlock' +import { Confirm } from './Confirm' import { Notice } from './Notice' import { Link } from './Link' @@ -11,74 +13,67 @@ const UNINSTALL_SUPPORT_URL = 'https://support.remote.it/hc/en-us/articles/36005 type Props = { open: boolean owned?: OwnedDevices - thisId?: string onClose: () => void } -export const RemoveRemoteitDialog: React.FC = ({ open, owned, thisId, onClose }) => { +export const RemoveRemoteitDialog: React.FC = ({ open, owned, onClose }) => { const { t } = useTranslation() - const others = owned && otherOwnedDevices(owned, thisId) + const desktopApps = [ + { + label: t('removeRemoteitDialog.desktopMacLinux', 'Desktop app on macOS or Linux'), + steps: t('removeRemoteitDialog.desktopMacLinuxSteps', 'Open Settings, then Advanced, and select Uninstall.'), + }, + { + label: t('removeRemoteitDialog.desktopWindows', 'Desktop app on Windows'), + steps: t('removeRemoteitDialog.desktopWindowsSteps', 'Uninstall Remote.It from Windows Settings, under Apps.'), + }, + ] return ( - - {t('removeRemoteitDialog.title', 'Remove Remote.It from your devices')} - - - {t( - 'removeRemoteitDialog.intro', - "Deleting your account doesn't uninstall Remote.It. Remove it from each device you own before you delete your account." - )} - - - {t( - 'removeRemoteitDialog.localAccess', - 'Uninstall from the device itself or over your local network. Removing Remote.It through a Remote.It connection ends that connection right away.' - )} - - - - - - - {t('removeRemoteitDialog.desktopMacLinux', 'Desktop app on macOS or Linux')} - {' — '} - {t('removeRemoteitDialog.desktopMacLinuxSteps', 'Open Settings, then Advanced, and select Uninstall.')} - - - {t('removeRemoteitDialog.desktopWindows', 'Desktop app on Windows')} - {' — '} - {t('removeRemoteitDialog.desktopWindowsSteps', 'Uninstall Remote.It from Windows Settings, under Apps.')} - - - - {t('removeRemoteitDialog.otherDevices', 'Instructions for other devices')} - - - {owned?.thisDeviceOwned && thisId && ( - - {t( - 'removeRemoteitDialog.thisDevice', - 'This device is unregistered automatically when you delete your account.' - )} - + + + {t( + 'removeRemoteitDialog.intro', + "Deleting your account doesn't uninstall Remote.It. Remove it from each device you own before you delete your account." )} - {owned && others && others.devices.length > 0 && ( - <> - - {t('removeRemoteitDialog.yourDevices', { count: others.total, defaultValue: 'Your devices ({{count}})' })} - - - + + + {t( + 'removeRemoteitDialog.localAccess', + 'Uninstall from the device itself or over your local network. Removing Remote.It through a Remote.It connection ends that connection right away.' )} - - - - - + + + + + + {desktopApps.map(({ label, steps }) => ( + + {label} + {' — '} + {steps} + + ))} + + + {t('removeRemoteitDialog.otherDevices', 'Instructions for other devices')} + + + {owned && ( + t('removeRemoteitDialog.yourDevices', { count, defaultValue: 'Your devices ({{count}})' })} + /> + )} + ) } diff --git a/frontend/src/hooks/useOwnedDevices.ts b/frontend/src/hooks/useOwnedDevices.ts new file mode 100644 index 000000000..d3c146107 --- /dev/null +++ b/frontend/src/hooks/useOwnedDevices.ts @@ -0,0 +1,38 @@ +import { useEffect, useState } from 'react' +import { useSelector } from 'react-redux' +import { State } from '../store' +import { getUserId } from '../selectors/state' +import { graphQLFetchOwnedDevices } from '../services/graphQLDevice' + +const SHOWN = 10 + +export type OwnedDevice = { id: string; name: string; state: string; platform: number } + +export type OwnedDevices = { devices: OwnedDevice[]; total: number; thisDeviceOwned: boolean } + +export function useOwnedDevices(enabled: boolean) { + const userId = useSelector(getUserId) + const thisId = useSelector((state: State) => state.backend.thisId) + const [owned, setOwned] = useState() + + useEffect(() => { + if (!enabled || !userId || owned) return + let current = true + graphQLFetchOwnedDevices(userId, SHOWN + 1, thisId).then(result => { + if (!current || result === 'ERROR') return + const login = result.data?.data?.login + const items: OwnedDevice[] = login?.account?.devices?.items || [] + const thisDeviceOwned = !!login?.device?.some((device: { owner?: { id: string } }) => device.owner?.id === userId) + setOwned({ + devices: items.filter(device => device.id !== thisId).slice(0, SHOWN), + total: (login?.account?.devices?.total || 0) - (thisDeviceOwned ? 1 : 0), + thisDeviceOwned, + }) + }) + return () => { + current = false + } + }, [enabled, userId]) + + return owned +} diff --git a/frontend/src/i18n/locales/de/app.json b/frontend/src/i18n/locales/de/app.json index 3cd7c8659..3daaff035 100644 --- a/frontend/src/i18n/locales/de/app.json +++ b/frontend/src/i18n/locales/de/app.json @@ -706,7 +706,6 @@ "resendCode": "Neuen Code senden", "sendCode": "Code per E-Mail senden", "sending": "Wird gesendet…", - "thisDevice": "Die Registrierung dieses Geräts wird aufgehoben, wenn Ihr Konto gelöscht wird.", "tooManyAttempts": "Zu viele falsche Codes. Fordern Sie einen neuen Code an, um es erneut zu versuchen.", "unregisterFailed": "Die Registrierung dieses Geräts konnte nicht aufgehoben werden, daher wurde Ihr Konto nicht gelöscht. Versuchen Sie es erneut oder heben Sie die Registrierung zuerst auf der Seite des Geräts auf.", "unregistering": "Registrierung dieses Geräts wird aufgehoben…" @@ -1621,7 +1620,8 @@ }, "ownedDevicesList": { "more_one": "und {{count}} weiteres", - "more_other": "und {{count}} weitere" + "more_other": "und {{count}} weitere", + "thisDevice": "Die Registrierung dieses Geräts wird automatisch aufgehoben, wenn Sie Ihr Konto löschen." }, "partnerStatsDetailPanel": { "activated": "Aktiviert", @@ -1888,7 +1888,6 @@ "localAccess": "Deinstallieren Sie direkt am Gerät oder über Ihr lokales Netzwerk. Wenn Sie Remote.It über eine Remote.It-Verbindung entfernen, wird diese Verbindung sofort getrennt.", "openwrt": "OpenWrt", "otherDevices": "Anleitungen für andere Geräte", - "thisDevice": "Die Registrierung dieses Geräts wird automatisch aufgehoben, wenn Sie Ihr Konto löschen.", "title": "Remote.It von Ihren Geräten entfernen", "yourDevices_one": "Ihre Geräte ({{count}})", "yourDevices_other": "Ihre Geräte ({{count}})" diff --git a/frontend/src/i18n/locales/en/app.json b/frontend/src/i18n/locales/en/app.json index 707fab785..dfa6d44f0 100644 --- a/frontend/src/i18n/locales/en/app.json +++ b/frontend/src/i18n/locales/en/app.json @@ -706,7 +706,6 @@ "resendCode": "Send a new code", "sendCode": "Email me a code", "sending": "Sending…", - "thisDevice": "This device will be unregistered when your account is deleted.", "tooManyAttempts": "Too many incorrect codes. Request a new code to try again.", "unregisterFailed": "This device couldn't be unregistered, so your account was not deleted. Try again, or unregister this device from its device page first.", "unregistering": "Unregistering this device…" @@ -1621,7 +1620,8 @@ }, "ownedDevicesList": { "more_one": "and {{count}} more", - "more_other": "and {{count}} more" + "more_other": "and {{count}} more", + "thisDevice": "This device is unregistered automatically when you delete your account." }, "partnerStatsDetailPanel": { "activated": "Activated", @@ -1888,7 +1888,6 @@ "localAccess": "Uninstall from the device itself or over your local network. Removing Remote.It through a Remote.It connection ends that connection right away.", "openwrt": "OpenWrt", "otherDevices": "Instructions for other devices", - "thisDevice": "This device is unregistered automatically when you delete your account.", "title": "Remove Remote.It from your devices", "yourDevices_one": "Your devices ({{count}})", "yourDevices_other": "Your devices ({{count}})" diff --git a/frontend/src/i18n/locales/es/app.json b/frontend/src/i18n/locales/es/app.json index 2310c651f..74852e83b 100644 --- a/frontend/src/i18n/locales/es/app.json +++ b/frontend/src/i18n/locales/es/app.json @@ -711,7 +711,6 @@ "resendCode": "Enviar un código nuevo", "sendCode": "Enviarme un código", "sending": "Enviando…", - "thisDevice": "Se anulará el registro de este dispositivo cuando se elimine tu cuenta.", "tooManyAttempts": "Demasiados códigos incorrectos. Solicita un código nuevo para volver a intentarlo.", "unregisterFailed": "No se pudo anular el registro de este dispositivo, así que tu cuenta no se eliminó. Inténtalo de nuevo o anula primero el registro desde la página del dispositivo.", "unregistering": "Anulando el registro de este dispositivo…" @@ -1639,7 +1638,8 @@ "ownedDevicesList": { "more_one": "y {{count}} más", "more_many": "y {{count}} más", - "more_other": "y {{count}} más" + "more_other": "y {{count}} más", + "thisDevice": "El registro de este dispositivo se anula automáticamente cuando eliminas tu cuenta." }, "partnerStatsDetailPanel": { "activated": "Activado", @@ -1914,7 +1914,6 @@ "localAccess": "Desinstálalo desde el propio dispositivo o a través de tu red local. Si quitas Remote.It mediante una conexión de Remote.It, esa conexión se corta de inmediato.", "openwrt": "OpenWrt", "otherDevices": "Instrucciones para otros dispositivos", - "thisDevice": "El registro de este dispositivo se anula automáticamente cuando eliminas tu cuenta.", "title": "Quitar Remote.It de tus dispositivos", "yourDevices_one": "Tus dispositivos ({{count}})", "yourDevices_many": "Tus dispositivos ({{count}})", diff --git a/frontend/src/i18n/locales/ja/app.json b/frontend/src/i18n/locales/ja/app.json index 89362c18d..78d4f1f17 100644 --- a/frontend/src/i18n/locales/ja/app.json +++ b/frontend/src/i18n/locales/ja/app.json @@ -701,7 +701,6 @@ "resendCode": "新しいコードを送信", "sendCode": "コードをメールで受け取る", "sending": "送信中…", - "thisDevice": "アカウントを削除すると、このデバイスの登録は解除されます。", "tooManyAttempts": "誤ったコードの入力が多すぎます。新しいコードをリクエストしてやり直してください。", "unregisterFailed": "このデバイスの登録を解除できなかったため、アカウントは削除されていません。もう一度お試しいただくか、先にデバイスのページからこのデバイスの登録を解除してください。", "unregistering": "このデバイスの登録を解除中…" @@ -1603,7 +1602,8 @@ "settings": "設定" }, "ownedDevicesList": { - "more_other": "他 {{count}} 台" + "more_other": "他 {{count}} 台", + "thisDevice": "このデバイスは、アカウントを削除すると自動的に登録解除されます。" }, "partnerStatsDetailPanel": { "activated": "有効化済み", @@ -1862,7 +1862,6 @@ "localAccess": "デバイス本体またはローカルネットワーク経由でアンインストールしてください。Remote.It の接続を使って Remote.It を削除すると、その接続はすぐに切断されます。", "openwrt": "OpenWrt", "otherDevices": "その他のデバイスの手順", - "thisDevice": "このデバイスは、アカウントを削除すると自動的に登録解除されます。", "title": "デバイスから Remote.It を削除する", "yourDevices_other": "所有デバイス ({{count}})" }, diff --git a/frontend/src/services/graphQL.ts b/frontend/src/services/graphQL.ts index 575733724..b863b1970 100644 --- a/frontend/src/services/graphQL.ts +++ b/frontend/src/services/graphQL.ts @@ -21,7 +21,7 @@ export async function graphQLPartialRequest(query: String, variables: ILookup = {}): Promise { const response = await post({ query, variables }) @@ -29,8 +29,7 @@ export async function graphQLInlineRequest(query: String, variables: ILookup Date: Fri, 2 Oct 2026 11:41:26 -0700 Subject: [PATCH 6/9] fix(profile): wait for owned devices before deleting, and correct uninstall and org copy --- .../components/DeleteAccountDialog.test.tsx | 31 +++++++++++++- .../src/components/DeleteAccountDialog.tsx | 30 ++++++++++++-- .../src/components/DeleteAccountSection.tsx | 19 +++++++-- .../src/components/RemoveRemoteitDialog.tsx | 5 ++- frontend/src/hooks/useOwnedDevices.test.ts | 41 +++++++++++++++++++ frontend/src/hooks/useOwnedDevices.ts | 30 ++++++++------ frontend/src/i18n/locales/de/app.json | 5 ++- frontend/src/i18n/locales/en/app.json | 5 ++- frontend/src/i18n/locales/es/app.json | 5 ++- frontend/src/i18n/locales/ja/app.json | 5 ++- 10 files changed, 149 insertions(+), 27 deletions(-) create mode 100644 frontend/src/hooks/useOwnedDevices.test.ts diff --git a/frontend/src/components/DeleteAccountDialog.test.tsx b/frontend/src/components/DeleteAccountDialog.test.tsx index 28e9e219b..3e57b16f8 100644 --- a/frontend/src/components/DeleteAccountDialog.test.tsx +++ b/frontend/src/components/DeleteAccountDialog.test.tsx @@ -75,11 +75,17 @@ const typeCode = async (code: string) => { input.dispatchEvent(new Event('input', { bubbles: true })) }) } -const render = async (devices = owned(true)) => { +const render = async (devices: OwnedDevices | null = owned(true), props: object = {}) => { await act(async () => root.render( - + ) ) @@ -124,6 +130,27 @@ describe('DeleteAccountDialog', () => { expect(button('Continue').disabled).toBe(false) }) + it('holds Continue until the devices are known, so this device is never skipped', async () => { + await render(null) + await check() + expect(dialog().textContent).toContain('Loading your devices…') + expect(button('Continue').disabled).toBe(true) + + await render(null, { devicesFailed: true }) + expect(dialog().textContent).toContain("Your devices couldn't be loaded") + expect(button('Continue').disabled).toBe(true) + }) + + it('mentions the organization only to someone who has one', async () => { + await render(owned(false)) + await toFeedback() + await click('Continue') + expect(dialog().textContent).not.toContain('Your organization and its roles are deleted') + + await render(owned(false), { hasOrganization: true }) + expect(dialog().textContent).toContain('Your organization and its roles are deleted') + }) + it('unregisters this device before the account is deleted, then signs out without a survey ticket', async () => { dispatch.backend.unregisterThisDevice.mockResolvedValue(true) api.graphQLDeleteAccount.mockResolvedValue({ ok: true }) diff --git a/frontend/src/components/DeleteAccountDialog.tsx b/frontend/src/components/DeleteAccountDialog.tsx index 9db41bf26..95f7dd76a 100644 --- a/frontend/src/components/DeleteAccountDialog.tsx +++ b/frontend/src/components/DeleteAccountDialog.tsx @@ -37,11 +37,20 @@ type Busy = 'sending' | 'unregistering' | 'deleting' type Props = { open: boolean owned?: OwnedDevices + devicesFailed?: boolean + hasOrganization?: boolean onShowInstructions: () => void onClose: () => void } -export const DeleteAccountDialog: React.FC = ({ open, owned, onShowInstructions, onClose }) => { +export const DeleteAccountDialog: React.FC = ({ + open, + owned, + devicesFailed, + hasOrganization, + onShowInstructions, + onClose, +}) => { const { t } = useTranslation() const dispatch = useDispatch() const store = useStore() @@ -175,7 +184,7 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, onShowInstru icon: 'hdd', text: t('deleteAccountDialog.consequenceDevices', 'The devices you own are removed from your account'), }, - { + hasOrganization && { icon: 'industry-alt', text: t('deleteAccountDialog.consequenceOrganization', 'Your organization and its roles are deleted'), }, @@ -187,7 +196,7 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, onShowInstru ), }, { icon: 'sign-out', text: t('deleteAccountDialog.consequenceSignIn', 'Your sign-in and access keys stop working') }, - ] + ].filter(Boolean) as { icon: string; text: string }[] const actions = (left: React.ReactNode, primary: React.ReactNode) => ( @@ -213,6 +222,13 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, onShowInstru "Deleting your account removes your devices from it, but it doesn't uninstall Remote.It. The software keeps running on every device it's installed on until you remove it." )} + {!owned && ( + + {devicesFailed + ? t('deleteAccountDialog.devicesFailed', "Your devices couldn't be loaded. Close this and try again.") + : t('deleteAccountDialog.devicesLoading', 'Loading your devices…')} + + )} {owned && ( = ({ open, owned, onShowInstru , - )} @@ -352,6 +373,7 @@ export const DeleteAccountDialog: React.FC = ({ open, owned, onShowInstru } onKeyDown={e => e.key === 'Enter' && ready && deleteAccount()} inputProps={{ + 'aria-label': t('deleteAccountDialog.codeLabel', 'Confirmation code'), maxLength: CODE_LENGTH, autoComplete: 'one-time-code', style: { textAlign: 'center', fontSize: '1.5rem', letterSpacing: '0.5rem' }, diff --git a/frontend/src/components/DeleteAccountSection.tsx b/frontend/src/components/DeleteAccountSection.tsx index 0cb8fe727..a9febb41d 100644 --- a/frontend/src/components/DeleteAccountSection.tsx +++ b/frontend/src/components/DeleteAccountSection.tsx @@ -1,8 +1,9 @@ import React, { useState } from 'react' -import { useSelector } from 'react-redux' +import { useHistory } from 'react-router-dom' +import { useDispatch, useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' import { Typography, Button, Stack } from '@mui/material' -import { State } from '../store' +import { Dispatch, State } from '../store' import { PERSONAL_PLAN_ID } from '../models/plans' import { getOwnOrganization } from '../models/organization' import { selectRemoteitLicense } from '../selectors/organizations' @@ -15,12 +16,15 @@ import { Link } from './Link' export const DeleteAccountSection: React.FC = () => { const { t } = useTranslation() + const history = useHistory() + const dispatch = useDispatch() const userId = useSelector((state: State) => state.user.id) const license = useSelector((state: State) => selectRemoteitLicense(state, state.user.id)) const members = useSelector((state: State) => getOwnOrganization(state).members) + const hasOrganization = useSelector((state: State) => !!getOwnOrganization(state).id) const [dialog, setDialog] = useState<'remove' | 'delete'>() const [opened, setOpened] = useState(0) - const owned = useOwnedDevices(!!dialog) + const { owned, failed } = useOwnedDevices(!!dialog) const paidPlan = !!license && license.plan.id !== PERSONAL_PLAN_ID const otherMembers = members.filter(member => member.user.id !== userId).length @@ -29,6 +33,11 @@ export const DeleteAccountSection: React.FC = () => { setDialog('delete') } const close = () => setDialog(undefined) + const manageMembers = async (event: React.MouseEvent) => { + event.preventDefault() + await dispatch.accounts.select(userId) + history.push('/organization/members') + } return ( @@ -46,7 +55,7 @@ export const DeleteAccountSection: React.FC = () => { count: otherMembers, defaultValue: 'Your organization has {{count}} other members.', })}{' '} - + {t('deleteAccountSection.membersRemove', 'Transfer ownership or remove them before deleting your account.')} @@ -70,6 +79,8 @@ export const DeleteAccountSection: React.FC = () => { key={opened} open={dialog === 'delete'} owned={owned} + devicesFailed={failed} + hasOrganization={hasOrganization} onShowInstructions={() => setDialog('remove')} onClose={close} /> diff --git a/frontend/src/components/RemoveRemoteitDialog.tsx b/frontend/src/components/RemoveRemoteitDialog.tsx index 426b6aa9f..8ad1d6705 100644 --- a/frontend/src/components/RemoveRemoteitDialog.tsx +++ b/frontend/src/components/RemoveRemoteitDialog.tsx @@ -21,7 +21,10 @@ export const RemoveRemoteitDialog: React.FC = ({ open, owned, onClose }) const desktopApps = [ { label: t('removeRemoteitDialog.desktopMacLinux', 'Desktop app on macOS or Linux'), - steps: t('removeRemoteitDialog.desktopMacLinuxSteps', 'Open Settings, then Advanced, and select Uninstall.'), + steps: t( + 'removeRemoteitDialog.desktopMacLinuxSteps', + 'Open Settings, then Application, expand Advanced, and select Uninstall.' + ), }, { label: t('removeRemoteitDialog.desktopWindows', 'Desktop app on Windows'), diff --git a/frontend/src/hooks/useOwnedDevices.test.ts b/frontend/src/hooks/useOwnedDevices.test.ts new file mode 100644 index 000000000..c1d0f1887 --- /dev/null +++ b/frontend/src/hooks/useOwnedDevices.test.ts @@ -0,0 +1,41 @@ +import { describe, it, expect, vi } from 'vitest' + +vi.mock('../services/graphQLDevice', () => ({ graphQLFetchOwnedDevices: vi.fn() })) +vi.mock('../store', () => ({})) + +import { parseOwnedDevices, OWNED_DEVICES_SHOWN } from './useOwnedDevices' + +const device = (id: string, state = 'active') => ({ id, name: id, state, platform: 0 }) + +describe('parseOwnedDevices', () => { + it('takes this device out of the list and the count when the person owns it', () => { + const login = { + account: { devices: { total: 3, items: [device('A'), device('THIS'), device('B', 'inactive')] } }, + device: [{ id: 'THIS', owner: { id: 'ME' } }], + } + expect(parseOwnedDevices(login, 'ME', 'THIS')).toEqual({ + devices: [device('A'), device('B', 'inactive')], + total: 2, + thisDeviceOwned: true, + }) + }) + + it('leaves the count alone when this device belongs to someone else', () => { + const login = { + account: { devices: { total: 2, items: [device('A'), device('B')] } }, + device: [{ id: 'THIS', owner: { id: 'SOMEONE' } }], + } + expect(parseOwnedDevices(login, 'ME', 'THIS')).toMatchObject({ total: 2, thisDeviceOwned: false }) + }) + + it('shows at most the first page whether or not this device was in it', () => { + const items = Array.from({ length: OWNED_DEVICES_SHOWN + 1 }, (_, i) => device(`D${i}`)) + const parsed = parseOwnedDevices({ account: { devices: { total: 40, items } } }, 'ME') + expect(parsed.devices).toHaveLength(OWNED_DEVICES_SHOWN) + expect(parsed).toMatchObject({ total: 40, thisDeviceOwned: false }) + }) + + it('treats a missing response as no devices', () => { + expect(parseOwnedDevices(undefined, 'ME', 'THIS')).toEqual({ devices: [], total: 0, thisDeviceOwned: false }) + }) +}) diff --git a/frontend/src/hooks/useOwnedDevices.ts b/frontend/src/hooks/useOwnedDevices.ts index d3c146107..44a278c14 100644 --- a/frontend/src/hooks/useOwnedDevices.ts +++ b/frontend/src/hooks/useOwnedDevices.ts @@ -4,35 +4,41 @@ import { State } from '../store' import { getUserId } from '../selectors/state' import { graphQLFetchOwnedDevices } from '../services/graphQLDevice' -const SHOWN = 10 +export const OWNED_DEVICES_SHOWN = 10 export type OwnedDevice = { id: string; name: string; state: string; platform: number } export type OwnedDevices = { devices: OwnedDevice[]; total: number; thisDeviceOwned: boolean } +export function parseOwnedDevices(login: any, userId: string, thisId?: string): OwnedDevices { + const items: OwnedDevice[] = login?.account?.devices?.items || [] + const thisDeviceOwned = !!login?.device?.some((device: { owner?: { id: string } }) => device.owner?.id === userId) + return { + devices: items.filter(device => device.id !== thisId).slice(0, OWNED_DEVICES_SHOWN), + total: (login?.account?.devices?.total || 0) - (thisDeviceOwned ? 1 : 0), + thisDeviceOwned, + } +} + export function useOwnedDevices(enabled: boolean) { const userId = useSelector(getUserId) const thisId = useSelector((state: State) => state.backend.thisId) const [owned, setOwned] = useState() + const [failed, setFailed] = useState(false) useEffect(() => { if (!enabled || !userId || owned) return let current = true - graphQLFetchOwnedDevices(userId, SHOWN + 1, thisId).then(result => { - if (!current || result === 'ERROR') return - const login = result.data?.data?.login - const items: OwnedDevice[] = login?.account?.devices?.items || [] - const thisDeviceOwned = !!login?.device?.some((device: { owner?: { id: string } }) => device.owner?.id === userId) - setOwned({ - devices: items.filter(device => device.id !== thisId).slice(0, SHOWN), - total: (login?.account?.devices?.total || 0) - (thisDeviceOwned ? 1 : 0), - thisDeviceOwned, - }) + setFailed(false) + graphQLFetchOwnedDevices(userId, OWNED_DEVICES_SHOWN + 1, thisId).then(result => { + if (!current) return + if (result === 'ERROR') return setFailed(true) + setOwned(parseOwnedDevices(result.data?.data?.login, userId, thisId)) }) return () => { current = false } }, [enabled, userId]) - return owned + return { owned, failed } } diff --git a/frontend/src/i18n/locales/de/app.json b/frontend/src/i18n/locales/de/app.json index 3daaff035..c9adec885 100644 --- a/frontend/src/i18n/locales/de/app.json +++ b/frontend/src/i18n/locales/de/app.json @@ -683,6 +683,7 @@ "deleteAccountDialog": { "acknowledge": "Mir ist bewusst, dass Remote.It auf meinen Geräten installiert bleibt und weiterläuft und durch das Löschen meines Kontos nicht entfernt wird.", "codeIntro": "Zur Bestätigung senden wir einen Code per E-Mail an {{email}}.", + "codeLabel": "Bestätigungscode", "codePlaceholder": "Code", "codeSent": "Geben Sie den Code ein, den wir an {{email}} gesendet haben. Er ist 10 Minuten gültig.", "confirmTitle": "Konto löschen", @@ -693,6 +694,8 @@ "deleteButton": "Konto endgültig löschen", "deleting": "Wird gelöscht…", "devicesBody": "Beim Löschen Ihres Kontos werden Ihre Geräte daraus entfernt, Remote.It wird aber nicht deinstalliert. Die Software läuft auf jedem Gerät weiter, auf dem sie installiert ist, bis Sie sie entfernen.", + "devicesFailed": "Ihre Geräte konnten nicht geladen werden. Schließen Sie dieses Fenster und versuchen Sie es erneut.", + "devicesLoading": "Ihre Geräte werden geladen…", "devicesOwned_one": "Sie besitzen {{count}} Gerät", "devicesOwned_other": "Sie besitzen {{count}} Geräte", "devicesTitle": "Remote.It läuft auf Ihren Geräten weiter", @@ -1881,7 +1884,7 @@ "removeRemoteitDialog": { "debian": "Raspberry Pi, Ubuntu und andere Debian-basierte Linux-Systeme", "desktopMacLinux": "Desktop-App unter macOS oder Linux", - "desktopMacLinuxSteps": "Öffnen Sie die Einstellungen, dann „Erweitert“, und wählen Sie „Deinstallieren“.", + "desktopMacLinuxSteps": "Öffnen Sie die Einstellungen, dann „Anwendung“, klappen Sie „Erweitert“ auf und wählen Sie „Deinstallieren“.", "desktopWindows": "Desktop-App unter Windows", "desktopWindowsSteps": "Deinstallieren Sie Remote.It in den Windows-Einstellungen unter „Apps“.", "intro": "Beim Löschen Ihres Kontos wird Remote.It nicht deinstalliert. Entfernen Sie es von jedem Ihrer Geräte, bevor Sie Ihr Konto löschen.", diff --git a/frontend/src/i18n/locales/en/app.json b/frontend/src/i18n/locales/en/app.json index dfa6d44f0..0e97796b8 100644 --- a/frontend/src/i18n/locales/en/app.json +++ b/frontend/src/i18n/locales/en/app.json @@ -683,6 +683,7 @@ "deleteAccountDialog": { "acknowledge": "I understand that Remote.It stays installed and running on my devices, and deleting my account won't remove it.", "codeIntro": "To confirm, we'll email a code to {{email}}.", + "codeLabel": "Confirmation code", "codePlaceholder": "Code", "codeSent": "Enter the code we sent to {{email}}. It expires in 10 minutes.", "confirmTitle": "Delete your account", @@ -693,6 +694,8 @@ "deleteButton": "Delete account permanently", "deleting": "Deleting…", "devicesBody": "Deleting your account removes your devices from it, but it doesn't uninstall Remote.It. The software keeps running on every device it's installed on until you remove it.", + "devicesFailed": "Your devices couldn't be loaded. Close this and try again.", + "devicesLoading": "Loading your devices…", "devicesOwned_one": "You own {{count}} device", "devicesOwned_other": "You own {{count}} devices", "devicesTitle": "Remote.It will keep running on your devices", @@ -1881,7 +1884,7 @@ "removeRemoteitDialog": { "debian": "Raspberry Pi, Ubuntu and other Debian Linux", "desktopMacLinux": "Desktop app on macOS or Linux", - "desktopMacLinuxSteps": "Open Settings, then Advanced, and select Uninstall.", + "desktopMacLinuxSteps": "Open Settings, then Application, expand Advanced, and select Uninstall.", "desktopWindows": "Desktop app on Windows", "desktopWindowsSteps": "Uninstall Remote.It from Windows Settings, under Apps.", "intro": "Deleting your account doesn't uninstall Remote.It. Remove it from each device you own before you delete your account.", diff --git a/frontend/src/i18n/locales/es/app.json b/frontend/src/i18n/locales/es/app.json index 74852e83b..618d8aa74 100644 --- a/frontend/src/i18n/locales/es/app.json +++ b/frontend/src/i18n/locales/es/app.json @@ -687,6 +687,7 @@ "deleteAccountDialog": { "acknowledge": "Entiendo que Remote.It seguirá instalado y en ejecución en mis dispositivos, y que eliminar mi cuenta no lo desinstala.", "codeIntro": "Para confirmar, enviaremos un código por correo a {{email}}.", + "codeLabel": "Código de confirmación", "codePlaceholder": "Código", "codeSent": "Introduce el código que enviamos a {{email}}. Caduca en 10 minutos.", "confirmTitle": "Eliminar tu cuenta", @@ -697,6 +698,8 @@ "deleteButton": "Eliminar la cuenta definitivamente", "deleting": "Eliminando…", "devicesBody": "Al eliminar tu cuenta, tus dispositivos se quitan de ella, pero Remote.It no se desinstala. El software sigue funcionando en cada dispositivo donde está instalado hasta que lo quites.", + "devicesFailed": "No se pudieron cargar tus dispositivos. Cierra esto e inténtalo de nuevo.", + "devicesLoading": "Cargando tus dispositivos…", "devicesOwned_one": "Tienes {{count}} dispositivo", "devicesOwned_many": "Tienes {{count}} dispositivos", "devicesOwned_other": "Tienes {{count}} dispositivos", @@ -1907,7 +1910,7 @@ "removeRemoteitDialog": { "debian": "Raspberry Pi, Ubuntu y otros Linux basados en Debian", "desktopMacLinux": "App de escritorio en macOS o Linux", - "desktopMacLinuxSteps": "Abre Configuración, luego Avanzado, y selecciona Desinstalar.", + "desktopMacLinuxSteps": "Abre Configuración, luego Aplicación, despliega Avanzado y selecciona Desinstalar.", "desktopWindows": "App de escritorio en Windows", "desktopWindowsSteps": "Desinstala Remote.It desde la Configuración de Windows, en Aplicaciones.", "intro": "Eliminar tu cuenta no desinstala Remote.It. Quítalo de cada dispositivo que tengas antes de eliminar tu cuenta.", diff --git a/frontend/src/i18n/locales/ja/app.json b/frontend/src/i18n/locales/ja/app.json index 78d4f1f17..380e0d39e 100644 --- a/frontend/src/i18n/locales/ja/app.json +++ b/frontend/src/i18n/locales/ja/app.json @@ -679,6 +679,7 @@ "deleteAccountDialog": { "acknowledge": "Remote.It はデバイスにインストールされたまま動作し続け、アカウントを削除しても削除されないことを理解しました。", "codeIntro": "確認のため、{{email}} にコードをメールでお送りします。", + "codeLabel": "確認コード", "codePlaceholder": "コード", "codeSent": "{{email}} に送信したコードを入力してください。有効期限は10分です。", "confirmTitle": "アカウントを削除", @@ -689,6 +690,8 @@ "deleteButton": "アカウントを完全に削除", "deleting": "削除中…", "devicesBody": "アカウントを削除するとデバイスはアカウントから外れますが、Remote.It はアンインストールされません。ソフトウェアは、削除するまでインストールされているすべてのデバイスで動作し続けます。", + "devicesFailed": "デバイスを読み込めませんでした。閉じてからもう一度お試しください。", + "devicesLoading": "デバイスを読み込んでいます…", "devicesOwned_other": "所有しているデバイス: {{count}}台", "devicesTitle": "Remote.It はデバイス上で動作し続けます", "doneBody": "Remote.It をご利用いただきありがとうございました。サインアウトしています…", @@ -1855,7 +1858,7 @@ "removeRemoteitDialog": { "debian": "Raspberry Pi、Ubuntu、その他の Debian 系 Linux", "desktopMacLinux": "macOS または Linux のデスクトップアプリ", - "desktopMacLinuxSteps": "設定を開き、「詳細設定」から「アンインストール」を選択します。", + "desktopMacLinuxSteps": "設定を開き、「アプリケーション」の「詳細設定」を展開して「アンインストール」を選択します。", "desktopWindows": "Windows のデスクトップアプリ", "desktopWindowsSteps": "Windows の設定の「アプリ」から Remote.It をアンインストールします。", "intro": "アカウントを削除しても Remote.It はアンインストールされません。アカウントを削除する前に、所有している各デバイスから削除してください。", From 4861aef81b93651f77327cc52a1a84d6abf46b08 Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:49:46 -0700 Subject: [PATCH 7/9] fix(profile): refetch device ownership when this device's id changes --- frontend/src/hooks/useOwnedDevices.test.ts | 41 ---------- frontend/src/hooks/useOwnedDevices.test.tsx | 84 +++++++++++++++++++++ frontend/src/hooks/useOwnedDevices.ts | 10 ++- 3 files changed, 91 insertions(+), 44 deletions(-) delete mode 100644 frontend/src/hooks/useOwnedDevices.test.ts create mode 100644 frontend/src/hooks/useOwnedDevices.test.tsx diff --git a/frontend/src/hooks/useOwnedDevices.test.ts b/frontend/src/hooks/useOwnedDevices.test.ts deleted file mode 100644 index c1d0f1887..000000000 --- a/frontend/src/hooks/useOwnedDevices.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { describe, it, expect, vi } from 'vitest' - -vi.mock('../services/graphQLDevice', () => ({ graphQLFetchOwnedDevices: vi.fn() })) -vi.mock('../store', () => ({})) - -import { parseOwnedDevices, OWNED_DEVICES_SHOWN } from './useOwnedDevices' - -const device = (id: string, state = 'active') => ({ id, name: id, state, platform: 0 }) - -describe('parseOwnedDevices', () => { - it('takes this device out of the list and the count when the person owns it', () => { - const login = { - account: { devices: { total: 3, items: [device('A'), device('THIS'), device('B', 'inactive')] } }, - device: [{ id: 'THIS', owner: { id: 'ME' } }], - } - expect(parseOwnedDevices(login, 'ME', 'THIS')).toEqual({ - devices: [device('A'), device('B', 'inactive')], - total: 2, - thisDeviceOwned: true, - }) - }) - - it('leaves the count alone when this device belongs to someone else', () => { - const login = { - account: { devices: { total: 2, items: [device('A'), device('B')] } }, - device: [{ id: 'THIS', owner: { id: 'SOMEONE' } }], - } - expect(parseOwnedDevices(login, 'ME', 'THIS')).toMatchObject({ total: 2, thisDeviceOwned: false }) - }) - - it('shows at most the first page whether or not this device was in it', () => { - const items = Array.from({ length: OWNED_DEVICES_SHOWN + 1 }, (_, i) => device(`D${i}`)) - const parsed = parseOwnedDevices({ account: { devices: { total: 40, items } } }, 'ME') - expect(parsed.devices).toHaveLength(OWNED_DEVICES_SHOWN) - expect(parsed).toMatchObject({ total: 40, thisDeviceOwned: false }) - }) - - it('treats a missing response as no devices', () => { - expect(parseOwnedDevices(undefined, 'ME', 'THIS')).toEqual({ devices: [], total: 0, thisDeviceOwned: false }) - }) -}) diff --git a/frontend/src/hooks/useOwnedDevices.test.tsx b/frontend/src/hooks/useOwnedDevices.test.tsx new file mode 100644 index 000000000..757e52297 --- /dev/null +++ b/frontend/src/hooks/useOwnedDevices.test.tsx @@ -0,0 +1,84 @@ +import React, { act } from 'react' +import { createRoot } from 'react-dom/client' +import { describe, it, expect, vi } from 'vitest' + +const { graphQLFetchOwnedDevices, state } = vi.hoisted(() => ({ + graphQLFetchOwnedDevices: vi.fn(), + state: { auth: { user: { id: 'ME' } }, backend: { thisId: '' } }, +})) +vi.mock('../services/graphQLDevice', () => ({ graphQLFetchOwnedDevices })) +vi.mock('../store', () => ({})) +vi.mock('react-redux', () => ({ useSelector: (select: (s: any) => any) => select(state) })) + +import { parseOwnedDevices, useOwnedDevices, OWNED_DEVICES_SHOWN, OwnedDevices } from './useOwnedDevices' + +Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }) + +const device = (id: string, state = 'active') => ({ id, name: id, state, platform: 0 }) + +describe('parseOwnedDevices', () => { + it('takes this device out of the list and the count when the person owns it', () => { + const login = { + account: { devices: { total: 3, items: [device('A'), device('THIS'), device('B', 'inactive')] } }, + device: [{ id: 'THIS', owner: { id: 'ME' } }], + } + expect(parseOwnedDevices(login, 'ME', 'THIS')).toEqual({ + devices: [device('A'), device('B', 'inactive')], + total: 2, + thisDeviceOwned: true, + }) + }) + + it('leaves the count alone when this device belongs to someone else', () => { + const login = { + account: { devices: { total: 2, items: [device('A'), device('B')] } }, + device: [{ id: 'THIS', owner: { id: 'SOMEONE' } }], + } + expect(parseOwnedDevices(login, 'ME', 'THIS')).toMatchObject({ total: 2, thisDeviceOwned: false }) + }) + + it('shows at most the first page whether or not this device was in it', () => { + const items = Array.from({ length: OWNED_DEVICES_SHOWN + 1 }, (_, i) => device(`D${i}`)) + const parsed = parseOwnedDevices({ account: { devices: { total: 40, items } } }, 'ME') + expect(parsed.devices).toHaveLength(OWNED_DEVICES_SHOWN) + expect(parsed).toMatchObject({ total: 40, thisDeviceOwned: false }) + }) + + it('treats a missing response as no devices', () => { + expect(parseOwnedDevices(undefined, 'ME', 'THIS')).toEqual({ devices: [], total: 0, thisDeviceOwned: false }) + }) +}) + +describe('useOwnedDevices', () => { + it('refetches when this device turns up or changes, but not when it is unregistered', async () => { + const response = (thisId: string) => ({ + data: { + data: { + login: { account: { devices: { total: 1, items: [] } }, device: [{ id: thisId, owner: { id: 'ME' } }] }, + }, + }, + }) + graphQLFetchOwnedDevices.mockImplementation(async (_: string, __: number, thisId: string) => response(thisId)) + let latest: OwnedDevices | undefined + const Probe = () => { + latest = useOwnedDevices(true).owned + return null + } + const root = createRoot(document.createElement('div')) + const render = () => act(async () => root.render()) + + await render() + expect(graphQLFetchOwnedDevices).toHaveBeenLastCalledWith('ME', OWNED_DEVICES_SHOWN + 1, '') + + state.backend.thisId = 'THIS' + await render() + expect(graphQLFetchOwnedDevices).toHaveBeenLastCalledWith('ME', OWNED_DEVICES_SHOWN + 1, 'THIS') + expect(latest?.thisDeviceOwned).toBe(true) + + state.backend.thisId = '' + await render() + expect(graphQLFetchOwnedDevices).toHaveBeenCalledTimes(2) + expect(latest?.thisDeviceOwned).toBe(true) + act(() => root.unmount()) + }) +}) diff --git a/frontend/src/hooks/useOwnedDevices.ts b/frontend/src/hooks/useOwnedDevices.ts index 44a278c14..19b8c1599 100644 --- a/frontend/src/hooks/useOwnedDevices.ts +++ b/frontend/src/hooks/useOwnedDevices.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useSelector } from 'react-redux' import { State } from '../store' import { getUserId } from '../selectors/state' @@ -25,10 +25,14 @@ export function useOwnedDevices(enabled: boolean) { const thisId = useSelector((state: State) => state.backend.thisId) const [owned, setOwned] = useState() const [failed, setFailed] = useState(false) + const fetchedFor = useRef() useEffect(() => { - if (!enabled || !userId || owned) return + if (!enabled || !userId) return + if (owned && (!thisId || thisId === fetchedFor.current)) return let current = true + fetchedFor.current = thisId + setOwned(undefined) setFailed(false) graphQLFetchOwnedDevices(userId, OWNED_DEVICES_SHOWN + 1, thisId).then(result => { if (!current) return @@ -38,7 +42,7 @@ export function useOwnedDevices(enabled: boolean) { return () => { current = false } - }, [enabled, userId]) + }, [enabled, userId, thisId]) return { owned, failed } } From 6b4496fe1bcf470ae9daa7a20b875e0008c96107 Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Fri, 2 Oct 2026 11:57:04 -0700 Subject: [PATCH 8/9] fix(profile): refetch device ownership each time a deletion dialog opens --- frontend/src/hooks/useOwnedDevices.test.tsx | 12 ++++++++++-- frontend/src/hooks/useOwnedDevices.ts | 9 +++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/hooks/useOwnedDevices.test.tsx b/frontend/src/hooks/useOwnedDevices.test.tsx index 757e52297..457073bc0 100644 --- a/frontend/src/hooks/useOwnedDevices.test.tsx +++ b/frontend/src/hooks/useOwnedDevices.test.tsx @@ -50,7 +50,7 @@ describe('parseOwnedDevices', () => { }) describe('useOwnedDevices', () => { - it('refetches when this device turns up or changes, but not when it is unregistered', async () => { + it('refetches on each open and when this device turns up or changes, but not when it is unregistered', async () => { const response = (thisId: string) => ({ data: { data: { @@ -60,8 +60,9 @@ describe('useOwnedDevices', () => { }) graphQLFetchOwnedDevices.mockImplementation(async (_: string, __: number, thisId: string) => response(thisId)) let latest: OwnedDevices | undefined + let open = true const Probe = () => { - latest = useOwnedDevices(true).owned + latest = useOwnedDevices(open).owned return null } const root = createRoot(document.createElement('div')) @@ -79,6 +80,13 @@ describe('useOwnedDevices', () => { await render() expect(graphQLFetchOwnedDevices).toHaveBeenCalledTimes(2) expect(latest?.thisDeviceOwned).toBe(true) + + open = false + await render() + expect(latest?.thisDeviceOwned).toBe(true) + open = true + await render() + expect(graphQLFetchOwnedDevices).toHaveBeenCalledTimes(3) act(() => root.unmount()) }) }) diff --git a/frontend/src/hooks/useOwnedDevices.ts b/frontend/src/hooks/useOwnedDevices.ts index 19b8c1599..76002b7be 100644 --- a/frontend/src/hooks/useOwnedDevices.ts +++ b/frontend/src/hooks/useOwnedDevices.ts @@ -26,11 +26,16 @@ export function useOwnedDevices(enabled: boolean) { const [owned, setOwned] = useState() const [failed, setFailed] = useState(false) const fetchedFor = useRef() + const fresh = useRef(false) useEffect(() => { - if (!enabled || !userId) return - if (owned && (!thisId || thisId === fetchedFor.current)) return + if (!enabled || !userId) { + fresh.current = false + return + } + if (fresh.current && owned && (!thisId || thisId === fetchedFor.current)) return let current = true + fresh.current = true fetchedFor.current = thisId setOwned(undefined) setFailed(false) From 40fb57fba720fa36b531b45caa8be6d509afc87a Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Thu, 8 Oct 2026 10:01:05 -0700 Subject: [PATCH 9/9] fix(backend): acknowledge registration so unregistering waits for its own answer --- electron/src/backend/Controller.ts | 3 ++- electron/src/backend/server.test.ts | 27 ++++++++++++++++++- frontend/src/models/backend.test.ts | 40 ++++++++++++++--------------- frontend/src/models/backend.ts | 12 +++------ frontend/src/services/Controller.ts | 4 +-- 5 files changed, 53 insertions(+), 33 deletions(-) diff --git a/electron/src/backend/Controller.ts b/electron/src/backend/Controller.ts index 6f15b476e..3d9bb7e78 100644 --- a/electron/src/backend/Controller.ts +++ b/electron/src/backend/Controller.ts @@ -154,9 +154,10 @@ class Controller { this.clients.emit('device', cli.data.device?.uid) } - registration = async (code: string) => { + registration = async (code: string, done?: unknown) => { await cli.set('registration', code) this.clients.emit('device', cli.data.device?.uid) + if (typeof done === 'function') done(cli.data.device?.uid ?? '') } restore = async (deviceId: string) => { diff --git a/electron/src/backend/server.test.ts b/electron/src/backend/server.test.ts index bd8d6f4fc..2a27c06e6 100644 --- a/electron/src/backend/server.test.ts +++ b/electron/src/backend/server.test.ts @@ -19,7 +19,7 @@ jest.mock('./index', () => ({ __esModule: true, default: {} })) jest.mock('./Logger', () => ({ __esModule: true, default: { info: jest.fn(), warn: jest.fn(), error: jest.fn() } })) jest.mock('./cliInterface', () => ({ __esModule: true, - default: { readUser: jest.fn(), signOut: jest.fn(), isSignedOut: () => true, data: {}, EVENTS: {} }, + default: { readUser: jest.fn(), signOut: jest.fn(), set: jest.fn(), isSignedOut: () => true, data: {}, EVENTS: {} }, })) jest.mock('./LAN', () => ({ __esModule: true, default: { EVENTS: {} } })) jest.mock('./systemInfo', () => ({ __esModule: true, default: async () => ({ id: 'device-1' }) })) @@ -163,6 +163,31 @@ describe('backend/server broadcasts', () => { expect(signOut).toHaveBeenCalledTimes(1) }) + it('answers an unregister with the device left registered, and still broadcasts it', async () => { + Object.assign(user, credentials) + const window = await open() + expect(await authenticate(window, credentials)).toBe('authenticated') + const data = cli.data as { device?: { uid: string } } + const set = cli.set as jest.Mock + + data.device = { uid: 'device-1' } + set.mockImplementationOnce(async () => (data.device = undefined)) + const broadcast = next(window, 'device') + expect(await window.emitWithAck('registration', 'DELETE')).toBe('') + await broadcast + + data.device = { uid: 'device-1' } + set.mockImplementationOnce(async () => {}) + expect(await window.emitWithAck('registration', 'DELETE')).toBe('device-1') + }) + + it('leaves a signed-out window unanswered when it asks to unregister', async () => { + const window = await open() + const set = (cli.set as jest.Mock).mockClear() + await expect(window.timeout(200).emitWithAck('registration', 'DELETE')).rejects.toThrow() + expect(set).not.toHaveBeenCalled() + }) + it('lets a signed-in window release the agent, then drops every window signed in as its owner', async () => { const signOut = (cli.signOut as jest.Mock).mockClear() Object.assign(user, { ...credentials, signedIn: true }) diff --git a/frontend/src/models/backend.test.ts b/frontend/src/models/backend.test.ts index bd633d196..b47a56974 100644 --- a/frontend/src/models/backend.test.ts +++ b/frontend/src/models/backend.test.ts @@ -1,7 +1,7 @@ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' +import { describe, it, expect, vi, beforeEach } from 'vitest' -const { emit } = vi.hoisted(() => ({ emit: vi.fn() })) -vi.mock('../services/Controller', () => ({ emit })) +const { emit, emitWithAck } = vi.hoisted(() => ({ emit: vi.fn(), emitWithAck: vi.fn() })) +vi.mock('../services/Controller', () => ({ emit, default: { emitWithAck } })) vi.mock('../services/browser', () => ({ default: {}, setLocalStorage: vi.fn(), getOs: vi.fn() })) vi.mock('../i18n', () => ({ default: { t: (k: string) => k } })) @@ -13,39 +13,39 @@ describe('backend.unregisterThisDevice', () => { let effects: any beforeEach(() => { - emit.mockReset().mockReturnValue(true) + vi.resetAllMocks() dispatch = { ui: { set: vi.fn() }, backend: { set: vi.fn() }, devices: {} } effects = (backend as any).effects(dispatch) }) - afterEach(() => vi.useRealTimers()) - it('resolves true once the agent reports this device gone', async () => { - const unregistering = effects.unregisterThisDevice(undefined, state) - expect(emit).toHaveBeenCalledWith('registration', 'DELETE') - await effects.targetDeviceUpdated('', state) - await expect(unregistering).resolves.toBe(true) + it('resolves true once the agent answers that no device is registered', async () => { + emitWithAck.mockResolvedValue('') + await expect(effects.unregisterThisDevice(undefined, state)).resolves.toBe(true) + expect(emitWithAck).toHaveBeenCalledWith('registration', 60 * 1000, 'DELETE') }) - it('resolves false when the device is still registered afterwards', async () => { - const unregistering = effects.unregisterThisDevice(undefined, state) - await effects.targetDeviceUpdated('THIS', state) - await expect(unregistering).resolves.toBe(false) + it('resolves false when the agent answers that the device is still registered', async () => { + emitWithAck.mockResolvedValue('THIS') + await expect(effects.unregisterThisDevice(undefined, state)).resolves.toBe(false) }) - it('resolves false when the local backend is not connected', async () => { - emit.mockReturnValue(false) + it('resolves false when no answer comes back', async () => { + emitWithAck.mockResolvedValue(undefined) await expect(effects.unregisterThisDevice(undefined, state)).resolves.toBe(false) }) - it('resolves false when the agent never answers', async () => { - vi.useFakeTimers() + it('is not settled by an unrelated device broadcast', async () => { + let answer: (deviceId: string) => void = () => {} + emitWithAck.mockReturnValue(new Promise(resolve => (answer = resolve))) const unregistering = effects.unregisterThisDevice(undefined, state) - await vi.advanceTimersByTimeAsync(60 * 1000) - await expect(unregistering).resolves.toBe(false) + await effects.targetDeviceUpdated('THIS', state) + answer('') + await expect(unregistering).resolves.toBe(true) }) it('has nothing to do without a registered device', async () => { await expect(effects.unregisterThisDevice(undefined, { backend: { thisId: '' } })).resolves.toBe(true) + expect(emitWithAck).not.toHaveBeenCalled() expect(emit).not.toHaveBeenCalled() }) }) diff --git a/frontend/src/models/backend.ts b/frontend/src/models/backend.ts index 72d995515..4aed87bb3 100644 --- a/frontend/src/models/backend.ts +++ b/frontend/src/models/backend.ts @@ -1,15 +1,13 @@ import browser, { setLocalStorage, getOs } from '../services/browser' import { createModel } from '@rematch/core' import { RootModel } from '.' -import { emit } from '../services/Controller' -import sleep, { withTimeout } from '../helpers/sleep' +import Controller, { emit } from '../services/Controller' +import sleep from '../helpers/sleep' import i18n from '../i18n' export const NOTICE_VERSION_ID = 'notice-version' const UNREGISTER_TIMEOUT = 60 * 1000 -let onTargetDeviceUpdated: ((id: string) => void) | undefined - export type IBackendState = { initialized: boolean thisId: string @@ -97,16 +95,12 @@ export default createModel()({ async unregisterThisDevice(_: void, state) { const { thisId } = state.backend if (!thisId) return true - const updated = new Promise(resolve => (onTargetDeviceUpdated = id => resolve(!id))) dispatch.ui.set({ silent: thisId }) - const unregistered = emit('registration', 'DELETE') && (await withTimeout(updated, UNREGISTER_TIMEOUT)) - onTargetDeviceUpdated = undefined - return unregistered === true + return (await Controller.emitWithAck('registration', UNREGISTER_TIMEOUT, 'DELETE')) === '' }, async targetDeviceUpdated(newId: string, state) { const { ui, backend, devices } = dispatch const { thisId } = state.backend - onTargetDeviceUpdated?.(newId) if (newId !== thisId) { // registered diff --git a/frontend/src/services/Controller.ts b/frontend/src/services/Controller.ts index b9eb94d43..c7212a6e0 100644 --- a/frontend/src/services/Controller.ts +++ b/frontend/src/services/Controller.ts @@ -147,11 +147,11 @@ class Controller extends EventEmitter { return this } - emitWithAck = (event: SocketAction, timeout: number): Promise => + emitWithAck = (event: SocketAction, timeout: number, ...args: unknown[]): Promise => this.socket?.connected ? this.socket .timeout(timeout) - .emitWithAck(event) + .emitWithAck(event, ...args) .catch(() => undefined) : Promise.resolve(undefined)