Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions _locales/_untranslated_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,29 @@
},
"accounts_list_item_menu_label": {
"message": "Actions with Profile"
},
"transports": {
"message": "Transports"
},
"transport_settings": {
"message": "Transport Settings"
},
"add_transport": {
"message": "Add Transport"
},
"edit_transport": {
"message": "Edit Transport"
},
"remove_transport": {
"message": "Remove Transport"
},
"confirm_add_transport": {
"message": "Are you sure you want to add this transport?"
},
"confirm_remove_transport": {
"message": "Are you sure you want to remove this transport? %1$s"
},
"invalid_transport_qr": {
"message": "The scanned QR code does not contain a valid transport"
}
}
1 change: 1 addition & 0 deletions images/icons/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/frontend/scss/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ i.material-icon-trash {
transform: translate(0px, -0.07em);
}

i.material-icon-edit {
mask-image: url(./images/icons/edit.svg);
-webkit-mask-image: url(./images/icons/edit.svg);
transform: translate(0px, -0.07em);
}

i.material-icon-copy {
mask-image: url(./images/icons/copy.svg);
-webkit-mask-image: url(./images/icons/copy.svg);
Expand Down
20 changes: 19 additions & 1 deletion packages/frontend/src/components/Settings/Advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import DesktopSettingsSwitch from './DesktopSettingsSwitch'
import { AutostartState } from '@deltachat-desktop/shared/shared-types'
import ProxyConfiguration from '../dialogs/ProxyConfiguration'
import { selectedAccountId } from '../../ScreenController'
import TransportsDialog from '../dialogs/Transports'

type Props = {
settingsStore: SettingsStoreState
Expand All @@ -31,6 +32,15 @@ export default function Advanced({ settingsStore }: Props) {
})
}

const openTransportSettings = () => {
openDialog(TransportsDialog, {
accountId: selectedAccountId(),
configured: true,
})
}

const addr = settingsStore.settings.addr

return (
<>
<SettingsButton onClick={() => runtime.openLogFile()}>
Expand Down Expand Up @@ -61,7 +71,7 @@ export default function Advanced({ settingsStore }: Props) {
<SettingsButton
onClick={() => {
openDialog(EditAccountAndPasswordDialog, {
settingsStore,
addr,
})
}}
dataTestid='open-account-and-password'
Expand All @@ -76,6 +86,14 @@ export default function Advanced({ settingsStore }: Props) {
>
{tx('proxy_settings')}
</SettingsButton>
<SettingsButton
onClick={() => {
openTransportSettings()
}}
dataTestid='open-transport-settings'
>
{tx('transport_settings')}
</SettingsButton>

{settingsStore.settings.is_chatmail === '0' && (
<ImapFolderHandling settingsStore={settingsStore} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@ import Dialog, { DialogBody, DialogFooter, FooterActions } from '../Dialog'
import FooterActionButton from '../Dialog/FooterActionButton'
import { QrReader, QrCodeScanRef } from '../QrReader'
import useTranslationFunction from '../../hooks/useTranslationFunction'
import { processQr } from '../../backend/qr'
import useAlertDialog from '../../hooks/dialog/useAlertDialog'
import { selectedAccountId } from '../../ScreenController'

import type { DialogProps } from '../../contexts/DialogContext'

/**
* QR code scanner for proxy configuration
* Processes scanned QR code and calls onSuccess if it is a valid proxy QR code
* copied from dialogs/QrCode.tsx
* Basic QR code scanner
* Just returns the scanned QR code as string
*/
export default function ProxyQrScanner({
export default function BasicQrScanner({
onSuccess,
onClose,
}: DialogProps & { onSuccess: (result: string) => void }) {
const tx = useTranslationFunction()
const accountId = selectedAccountId()
const openAlertDialog = useAlertDialog()
const qrReaderRef = useRef<QrCodeScanRef | null>(null)

Expand All @@ -29,25 +25,18 @@ export default function ProxyQrScanner({
const errorMessage = error?.message || error.toString()
openAlertDialog({
message: `${tx('qrscan_failed')} ${errorMessage}`,
dataTestid: 'proxy-scan-failed',
dataTestid: 'scan-failed',
})
},
[openAlertDialog, tx]
)

const handleScan = useCallback(
async (data: string) => {
if (data) {
const { qr } = await processQr(accountId, data)
if (qr.kind === 'proxy') {
onSuccess(data)
onClose()
} else {
handleError(new Error(tx('proxy_invalid')))
}
}
onSuccess(data)
onClose()
},
[onSuccess, onClose, accountId, handleError, tx]
[onSuccess, onClose]
)

const pasteClipboard = useCallback(async () => {
Expand All @@ -57,7 +46,7 @@ export default function ProxyQrScanner({
}, [])

return (
<Dialog onClose={onClose} dataTestid='proxy-qrscan-dialog'>
<Dialog onClose={onClose} dataTestid='transport-qrscan-dialog'>
<DialogBody>
<QrReader
onScanSuccess={handleScan}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@
import AlertDialog from './AlertDialog'
import { T } from '@deltachat/jsonrpc-client'

type AccountAndPasswordDialogProps = DialogProps & {
addr?: string
}

/**
* uses a prefilled LoginForm with existing
* credentials to edit transport settings
*/
export default function EditAccountAndPasswordDialog({ onClose }: DialogProps) {
export default function EditAccountAndPasswordDialog({
onClose,
addr,
}: AccountAndPasswordDialogProps) {
const tx = useTranslationFunction()

return (
<Dialog canOutsideClickClose={false} onClose={onClose}>
<DialogHeader title={tx('login_header')} />
{EditAccountInner(onClose)}
{EditAccountInner(onClose, addr)}
</Dialog>
)
}

function EditAccountInner(onClose: DialogProps['onClose']) {
function EditAccountInner(onClose: DialogProps['onClose'], addr?: string) {
const [initialSettings, setInitialAccountSettings] =
useState<Credentials>(defaultCredentials())

Expand All @@ -51,7 +58,15 @@
if (transports.length === 0) {
throw new Error('no transport found')
}
const accountSettings: T.EnteredLoginParam = transports[0]
const configuredAddress =
addr || (await BackendRemote.rpc.getConfig(accountId, 'configured_addr'))
const accountSettings: T.EnteredLoginParam | undefined = transports.find(
t => t.addr === configuredAddress
)

if (!accountSettings) {
throw new Error('configured transport not found in transport list')
}

setInitialAccountSettings(accountSettings)
setAccountSettings(accountSettings)
Expand All @@ -59,7 +74,7 @@

useEffect(() => {
loadSettings()
}, [])

Check warning on line 77 in packages/frontend/src/components/dialogs/EditAccountAndPasswordDialog.tsx

View workflow job for this annotation

GitHub Actions / Code Validation

React Hook useEffect has a missing dependency: 'loadSettings'. Either include it or remove the dependency array

const onUpdate = useCallback(async () => {
const onSuccess = () => onClose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { getLogger } from '@deltachat-desktop/shared/logger'
import { unknownErrorToString } from '../../helpers/unknownErrorToString'

import ProxyItemRow from './ProxyItemRow'
import ProxyQrScanner from '../ProxyQrScanner'
import { processQr } from '../../../backend/qr'
import BasicQrScanner from '../BasicScanner'

const log = getLogger('proxy-configuration')

Expand Down Expand Up @@ -210,12 +211,21 @@ export default function ProxyConfiguration(
)

const openQrScanner = useCallback(() => {
openDialog(ProxyQrScanner, {
onSuccess: (result: string) => {
addProxy(result)
openDialog(BasicQrScanner, {
onSuccess: async (result: string) => {
if (result) {
const { qr } = await processQr(accountId, result)
if (qr.kind === 'proxy') {
addProxy(result)
} else {
openAlertDialog({
message: tx('proxy_invalid'),
})
}
}
},
})
}, [openDialog, addProxy])
}, [openDialog, accountId, addProxy, openAlertDialog, tx])

const changeActiveProxy = useCallback(
(proxyUrl: string) => {
Expand Down
Loading
Loading