diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index 4c5442654e09..109745969a7a 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -439,13 +439,17 @@ void CustomizeWebUIHTMLSource(const std::string &name, content::WebUIDataSource* } }, { std::string("sync"), { - { "done", IDS_BRAVE_SYNC_SHARED_DONE_BUTTON }, + // Shared strings { "remove", IDS_BRAVE_SYNC_SHARED_REMOVE_PARTIAL }, { "copied", IDS_BRAVE_SYNC_SHARED_COPIED_TEXT }, { "wordCount", IDS_BRAVE_SYNC_SHARED_WORD_COUNT_TEXT }, { "ok", IDS_BRAVE_SYNC_SHARED_OK_BUTTON }, { "cancel", IDS_BRAVE_SYNC_SHARED_CANCEL_BUTTON }, + { "cancelDeviceSyncing", IDS_BRAVE_SYNC_SHARED_CANCEL_SYNCING_TITLE }, + { "cancelDeviceSyncingButton", IDS_BRAVE_SYNC_SHARED_CANCEL_SYNCING_BUTTON }, { "thisSyncChain", IDS_BRAVE_SYNC_SHARED_FROM_THIS_CHAIN_PARTIAL }, + { "lookingForDevice", IDS_BRAVE_SYNC_SCAN_CODE_LOOKING_FOR_DEVICE_BUTTON }, + { "viewSyncCode", IDS_BRAVE_SYNC_ENABLED_VIEW_CODE_BUTTON }, // Enabled Content { "braveSync", IDS_BRAVE_SYNC_ENABLED_BRAVE_TITLE }, { "syncChainDevices", IDS_BRAVE_SYNC_ENABLED_DEVICES_CHAIN_TITLE }, @@ -453,8 +457,9 @@ void CustomizeWebUIHTMLSource(const std::string &name, content::WebUIDataSource* { "thisDevice", IDS_BRAVE_SYNC_ENABLED_TABLE_THIS_DEVICE_TEXT }, { "addedOn", IDS_BRAVE_SYNC_ENABLED_TABLE_ADDED_ON_TITLE }, { "addDevice", IDS_BRAVE_SYNC_ENABLED_ADD_DEVICE_BUTTON }, - { "viewSyncCode", IDS_BRAVE_SYNC_ENABLED_VIEW_CODE_BUTTON }, - { "dataToSync", IDS_BRAVE_SYNC_ENABLED_DATA_TITLE }, + { "settingsTitle", IDS_BRAVE_SYNC_ENABLED_SETTINGS_TITLE }, + { "settingsDescription", IDS_BRAVE_SYNC_ENABLED_SETTINGS_DESCRIPTION }, + { "settings", IDS_BRAVE_SYNC_ENABLED_TABLE_SETTINGS }, { "bookmarks", IDS_BRAVE_SYNC_ENABLED_BOOKMARKS_LABEL }, { "savedSiteSettings", IDS_BRAVE_SYNC_ENABLED_SITE_SETTINGS_LABEL }, { "browsingHistory", IDS_BRAVE_SYNC_ENABLED_HISTORY_LABEL }, @@ -464,7 +469,6 @@ void CustomizeWebUIHTMLSource(const std::string &name, content::WebUIDataSource* { "syncDescription", IDS_BRAVE_SYNC_DISABLED_NEW_CHAIN_DESCRIPTION }, { "startSyncChain", IDS_BRAVE_SYNC_DISABLED_START_NEW_CHAIN_BUTTON }, { "enterSyncChainCode", IDS_BRAVE_SYNC_DISABLED_ENTER_CODE_BUTTON }, - { "confirmSyncCode", IDS_BRAVE_SYNC_DISABLED_CONFIRM_CODE_BUTTON }, // [modal] Enter Sync Code { "enterSyncCode", IDS_BRAVE_SYNC_ENTER_CODE_TITLE }, { "enterSyncCodeDescription", IDS_BRAVE_SYNC_ENTER_CODE_DESCRIPTION }, @@ -481,27 +485,23 @@ void CustomizeWebUIHTMLSource(const std::string &name, content::WebUIDataSource* { "deleteSyncDescription", IDS_BRAVE_SYNC_RESET_REMOVAL_INSTRUCTIONS }, { "startSyncChainHowTo", IDS_BRAVE_SYNC_RESET_START_NEW_INSTRUCTIONS }, { "areYouSure", IDS_BRAVE_SYNC_RESET_ARE_YOU_SURE_TITLE }, - // [modal] Add New Chain - { "scanThisCode", IDS_BRAVE_SYNC_NEW_CHAIN_MAIN_DESCRIPTION }, - { "scanThisCodeHowTo", IDS_BRAVE_SYNC_NEW_CHAIN_MAIN_INSTRUCTIONS }, - { "enterCodeWordsInstead", IDS_BRAVE_SYNC_NEW_CHAIN_MAIN_CODE_WORDS_BUTTON }, - { "previous", IDS_BRAVE_SYNC_NEW_CHAIN_MAIN_PREVIOUS_BUTTON }, - { "lookingForDevice", IDS_BRAVE_SYNC_NEW_CHAIN_MAIN_LOOKING_FOR_DEVICE_BUTTON }, - // [modal] Add New Chain (Camera Option) - // [modal] Add New Chain (no Camera) - { "enterThisCode", IDS_BRAVE_SYNC_NEW_CHAIN_DESKTOP_TITLE }, - { "mobileEnterThisCode", IDS_BRAVE_SYNC_NEW_CHAIN_MOBILE_TITLE }, - { "syncChainCodeHowTo", IDS_BRAVE_SYNC_NEW_CHAIN_DESCRIPTION }, - { "useCameraInstead", IDS_BRAVE_SYNC_NEW_CHAIN_USE_CAMERA_BUTTON }, + // [modal] Scan Code + { "scanThisCode", IDS_BRAVE_SYNC_SCAN_CODE_TITLE }, + { "scanThisCodeHowToPartial1", IDS_BRAVE_SYNC_SCAN_CODE_DESCRIPTION_PARTIAL_1 }, + { "scanThisCodeHowToPartial2", IDS_BRAVE_SYNC_SCAN_CODE_DESCRIPTION_PARTIAL_2 }, + { "scanThisCodeHowToPartial3", IDS_BRAVE_SYNC_SCAN_CODE_DESCRIPTION_PARTIAL_3 }, + // [modal] View Code + { "chainCode", IDS_BRAVE_SYNC_VIEW_CODE_TITLE }, + { "chainCodeDescriptionPartial1", IDS_BRAVE_SYNC_VIEW_CODE_DESCRIPTION_PARTIAL_1 }, + { "chainCodeDescriptionPartial2", IDS_BRAVE_SYNC_VIEW_CODE_DESCRIPTION_PARTIAL_2 }, + { "chainCodeDescriptionPartial3", IDS_BRAVE_SYNC_VIEW_CODE_DESCRIPTION_PARTIAL_3 }, + { "useCameraInstead", IDS_BRAVE_SYNC_VIEW_CODE_USE_CAMERA_BUTTON }, + { "qrCode", IDS_BRAVE_SYNC_VIEW_CODE_QR_CODE }, // [modal] Choose Device Type - { "letsSync", IDS_BRAVE_SYNC_CHOOSE_DEVICE_NEW_DEVICE_TITLE }, - { "chooseDeviceType", IDS_BRAVE_SYNC_CHOOSE_DEVICE_CHOOSE_DEVICE_TITLE }, + { "letsSync", IDS_BRAVE_SYNC_CHOOSE_DEVICE_TITLE }, + { "chooseDeviceType", IDS_BRAVE_SYNC_CHOOSE_DEVICE_DESCRIPTION }, { "phoneTablet", IDS_BRAVE_SYNC_CHOOSE_DEVICE_MOBILE_TITLE }, { "computer", IDS_BRAVE_SYNC_CHOOSE_DEVICE_COMPUTER_TITLE }, - // [modal] View Sync Code - { "qrCode", IDS_BRAVE_SYNC_VIEW_CODE_QR_CODE_TITLE }, - { "wordCode", IDS_BRAVE_SYNC_VIEW_CODE_WORD_CODE_TITLE }, - { "privateKey", IDS_BRAVE_SYNC_VIEW_CODE_PRIVATE_KEY_PHRASE }, // errors { "errorWrongCodeTitle", IDS_BRAVE_SYNC_ERROR_WRONG_CODE_TITLE }, { "errorWrongCodeDescription", IDS_BRAVE_SYNC_ERROR_WRONG_CODE_DESCRIPTION }, diff --git a/components/brave_sync/ui/BUILD.gn b/components/brave_sync/ui/BUILD.gn index c1f015272312..96df9f047c63 100644 --- a/components/brave_sync/ui/BUILD.gn +++ b/components/brave_sync/ui/BUILD.gn @@ -3,8 +3,8 @@ import("//brave/components/common/typescript.gni") transpile_web_ui("ui") { inputs = [ "actions/sync_actions.ts", - "components/modals/addNewChainCameraOption.tsx", - "components/modals/addNewChainNoCamera.tsx", + "components/commonDialogs/areYouSure.tsx", + "components/commonDialogs/cancelDeviceSyncing.tsx", "components/modals/deviceType.tsx", "components/modals/enterSyncCode.tsx", "components/modals/removeDevice.tsx", diff --git a/components/brave_sync/ui/actions/sync_actions.ts b/components/brave_sync/ui/actions/sync_actions.ts index d74a81a12bef..7ba6f6fa3153 100644 --- a/components/brave_sync/ui/actions/sync_actions.ts +++ b/components/brave_sync/ui/actions/sync_actions.ts @@ -115,8 +115,8 @@ export const onSyncSetupError = (error: Sync.SetupErrorType) => { /** * Reset the Sync Error */ -export const resetSyncSetupError = () => { - return action(types.SYNC_RESET_SETUP_ERROR) +export const clearSyncSetupError = () => { + return action(types.SYNC_CLEAR_SETUP_ERROR) } /** diff --git a/components/brave_sync/ui/brave_sync.html b/components/brave_sync/ui/brave_sync.html index b6bfa5a8d8c1..586f9b1955c1 100644 --- a/components/brave_sync/ui/brave_sync.html +++ b/components/brave_sync/ui/brave_sync.html @@ -22,7 +22,8 @@ diff --git a/components/brave_sync/ui/components/commonDialogs/areYouSure.tsx b/components/brave_sync/ui/components/commonDialogs/areYouSure.tsx new file mode 100644 index 000000000000..80472e443a4d --- /dev/null +++ b/components/brave_sync/ui/components/commonDialogs/areYouSure.tsx @@ -0,0 +1,35 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react' + +// Components +import { AlertBox } from 'brave-ui' + +// Feature-specific components +import { Title } from 'brave-ui/features/sync' + +// Utils +import { getLocale } from '../../../../common/locale' + +interface Props { + onClickOk: () => void + onClickCancel: () => void +} + +export default class AreYouSure extends React.PureComponent { + render () { + const { onClickOk, onClickCancel } = this.props + return ( + + {getLocale('areYouSure')} + + ) + } +} diff --git a/components/brave_sync/ui/components/commonDialogs/cancelDeviceSyncing.tsx b/components/brave_sync/ui/components/commonDialogs/cancelDeviceSyncing.tsx new file mode 100644 index 000000000000..bc8fd9d13f4b --- /dev/null +++ b/components/brave_sync/ui/components/commonDialogs/cancelDeviceSyncing.tsx @@ -0,0 +1,36 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react' + +// Components +import { AlertBox } from 'brave-ui' + +// Feature-specific components +import { Title, Paragraph } from 'brave-ui/features/sync' + +// Utils +import { getLocale } from '../../../../common/locale' + +interface Props { + onClickOk: () => void + onClickCancel: () => void +} + +export default class AreYouSure extends React.PureComponent { + render () { + const { onClickOk, onClickCancel } = this.props + return ( + + {getLocale('areYouSure')} + {getLocale('cancelDeviceSyncing')} + + ) + } +} diff --git a/components/brave_sync/ui/components/disabledContent.tsx b/components/brave_sync/ui/components/disabledContent.tsx index ac3f9a8048ea..3faed65cde79 100644 --- a/components/brave_sync/ui/components/disabledContent.tsx +++ b/components/brave_sync/ui/components/disabledContent.tsx @@ -11,10 +11,11 @@ import { Button } from 'brave-ui' import { Main, Title, - SectionBlock, DisabledContentButtonGrid, TableGrid, - Paragraph + Paragraph, + SyncCard, + DisabledContent } from 'brave-ui/features/sync' import { SyncStartIcon } from 'brave-ui/features/sync/images' @@ -62,45 +63,43 @@ export default class SyncDisabledContent extends React.PureComponent - { - newToSync - ? - : null - } - { - existingSyncCode - ? - : null - } - - -
- {getLocale('syncTitle')} - {getLocale('syncDescription')} - - -
+ +
+ { + newToSync + ? + : null + } + { + existingSyncCode + ? + : null + } + + + +
+ {getLocale('syncTitle')} + {getLocale('syncDescription')} +
-
- - -
- - +
+
+
+ + + ) } } diff --git a/components/brave_sync/ui/components/enabledContent.tsx b/components/brave_sync/ui/components/enabledContent.tsx index 18ff3f871ce0..117bc43a5c39 100644 --- a/components/brave_sync/ui/components/enabledContent.tsx +++ b/components/brave_sync/ui/components/enabledContent.tsx @@ -6,6 +6,7 @@ import * as React from 'react' // Components import { Button, AlertBox } from 'brave-ui' +import { CloseCircleIcon } from 'brave-ui/components/icons' import Table, { Cell, Row } from 'brave-ui/components/dataTables/table' import { Toggle } from 'brave-ui/features/shields' @@ -13,20 +14,23 @@ import { Toggle } from 'brave-ui/features/shields' import { Main, Title, - SettingsToggleGrid, - SwitchLabel, + Paragraph, SectionBlock, SubTitle, TableRowDevice, TableRowRemove, TableRowRemoveButton, + TableRowToggleButton, TableGrid, - TableButtonGrid + TableButtonGrid, + EnabledContent, + SyncCard } from 'brave-ui/features/sync' // Modals import RemoveDeviceModal from './modals/removeDevice' import ViewSyncCodeModal from './modals/viewSyncCode' +import ScanCodeModal from './modals/scanCode' import DeviceTypeModal from './modals/deviceType' import ResetSyncModal from './modals/resetSync' @@ -41,6 +45,7 @@ interface Props { interface State { removeDevice: boolean viewSyncCode: boolean + scanCode: boolean addDevice: boolean resetSync: boolean deviceToRemoveName: string | undefined @@ -53,6 +58,7 @@ export default class SyncEnabledContent extends React.PureComponent { + getDevicesRows = (devices?: any): Row[] | undefined => { if (!devices) { return } @@ -81,7 +87,7 @@ export default class SyncEnabledContent extends React.PureComponent - × + ) } @@ -91,7 +97,7 @@ export default class SyncEnabledContent extends React.PureComponent{getLocale('deviceName')} }, { content: getLocale('addedOn') }, @@ -99,6 +105,33 @@ export default class SyncEnabledContent extends React.PureComponent{getLocale('settings')} }, + { content: '' } + ] + } + + get settingsRows (): Row[] { + return [ + { + content: [ + { content: getLocale('bookmarks') }, + { content: ( + + + + ) } + ] + } + ] + } + onClickRemoveDeviceButton = (event: React.MouseEvent) => { if (!event || !event.currentTarget || !event.currentTarget.dataset) { return @@ -107,16 +140,28 @@ export default class SyncEnabledContent extends React.PureComponent { + this.setState({ removeDevice: !this.state.removeDevice }) + } + onUserNoticedError = () => { - this.props.actions.resetSyncSetupError() + this.props.actions.clearSyncSetupError() + } + + onClickCancelChildModals = () => { + this.setState({ scanCode: false, viewSyncCode: false }) } onClickViewSyncCodeButton = () => { - this.setState({ viewSyncCode: !this.state.viewSyncCode }) + this.setState({ scanCode: false, viewSyncCode: true }) + } + + onClickScanCodeButton = () => { + this.setState({ scanCode: true, viewSyncCode: false }) } onClickAddDeviceButton = () => { @@ -136,6 +181,7 @@ export default class SyncEnabledContent extends React.PureComponent - { - syncData.error === 'ERR_SYNC_NO_INTERNET' - ? - {getLocale('errorNoInternetTitle')} - {getLocale('errorNoInternetDescription')} - - : null - } - { - syncData.error === 'ERR_SYNC_INIT_FAILED' - ? - {getLocale('errorSyncInitFailedTitle')} - {getLocale('errorSyncInitFailedDescription')} - - : null - } - { - removeDevice - ? ( - - ) - : null - } - { - viewSyncCode - ? - : null - } - { - addDevice - ? + +
+ { + syncData.error === 'ERR_SYNC_NO_INTERNET' + ? + {getLocale('errorNoInternetTitle')} + {getLocale('errorNoInternetDescription')} + : null - } - { - resetSync - ? + } + { + syncData.error === 'ERR_SYNC_INIT_FAILED' + ? + {getLocale('errorSyncInitFailedTitle')} + {getLocale('errorSyncInitFailedDescription')} + : null - } - {getLocale('braveSync')} - - {getLocale('syncChainDevices')} - - - Device list is empty -
- -