From f2f954c24bb2376cb4d2e994717768be59530611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 3 Oct 2023 13:44:45 +0200 Subject: [PATCH] chore(storybook): unbreak (Device)SyncingViewPage and make it configurable a bit --- storybook/pages/DeviceSyncingViewPage.qml | 72 ---------- storybook/pages/SyncingViewPage.qml | 131 ++++++++++++++++++ ui/app/AppLayouts/Profile/ProfileLayout.qml | 1 + .../popups/SyncDeviceCustomizationPopup.qml | 4 +- .../AppLayouts/Profile/views/SyncingView.qml | 13 +- ui/app/AppLayouts/Profile/views/qmldir | 1 + 6 files changed, 142 insertions(+), 80 deletions(-) delete mode 100644 storybook/pages/DeviceSyncingViewPage.qml create mode 100644 storybook/pages/SyncingViewPage.qml diff --git a/storybook/pages/DeviceSyncingViewPage.qml b/storybook/pages/DeviceSyncingViewPage.qml deleted file mode 100644 index d6a9ad23ce..0000000000 --- a/storybook/pages/DeviceSyncingViewPage.qml +++ /dev/null @@ -1,72 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 -import StatusQ.Core 0.1 - -import Storybook 1.0 -import Models 1.0 -import utils 1.0 - -import shared.views 1.0 - -SplitView { - id: root - - Logs { id: logs } - - SplitView { - orientation: Qt.Vertical - SplitView.fillWidth: true - - DeviceSyncingView { - devicesModel: ListModel { - ListElement { - name: "Device 1" - deviceType: "osx" - timestamp: 0 - isCurrentDevice: false - } - ListElement { - name: "Device 2" - deviceType: "windows" - timestamp: 0 - isCurrentDevice: false - } - ListElement { - name: "Device 3" - deviceType: "android" - timestamp: 0 - isCurrentDevice: false - } - ListElement { - name: "Device 4" - deviceType: "ios" - timestamp: 0 - isCurrentDevice: false - } - ListElement { - name: "Device 5" - deviceType: "desktop" - timestamp: 0 - isCurrentDevice: false - } - } - } - - LogsAndControlsPanel { - id: logsAndControlsPanel - - SplitView.minimumHeight: 100 - SplitView.preferredHeight: 200 - - logsView.logText: logs.logText - } - } - - Pane { - SplitView.minimumWidth: 300 - SplitView.preferredWidth: 300 - } -} - -// category: Views diff --git a/storybook/pages/SyncingViewPage.qml b/storybook/pages/SyncingViewPage.qml new file mode 100644 index 0000000000..fc77a77a10 --- /dev/null +++ b/storybook/pages/SyncingViewPage.qml @@ -0,0 +1,131 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 + +import Storybook 1.0 + +import mainui 1.0 +import utils 1.0 +import AppLayouts.Profile.views 1.0 + +SplitView { + id: root + orientation: Qt.Vertical + + Logs { id: logs } + + Popups { + popupParent: root + rootStore: QtObject {} + } + + SyncingView { + id: syncView + SplitView.fillWidth: true + SplitView.fillHeight: true + + contentWidth: 664 + + isProduction: ctrlIsProduction.checked + + advancedStore: QtObject { + readonly property bool isDebugEnabled: ctrlDebugEnabled.checked + } + + devicesStore: QtObject { + function generateConnectionStringAndRunSetupSyncingPopup() { + logs.logEvent("devicesStore::generateConnectionStringAndRunSetupSyncingPopup()") + } + + function setInstallationName(installationId, name) { + logs.logEvent("devicesStore::setInstallationName", ["installationId", "name"], arguments) + } + + readonly property bool isDeviceSetup: ctrlDevicesLoaded.checked + readonly property var devicesModule: QtObject { + readonly property bool devicesLoading: ctrlDevicesLoading.checked + readonly property bool devicesLoadingError: ctrlDevicesLoadingError.checked + } + readonly property var devicesModel: ListModel { + ListElement { + name: "Device 1" + deviceType: "osx" + timestamp: 123456789123 + isCurrentDevice: true + enabled: true + installationId: "a" + } + ListElement { + name: "Device 2" + deviceType: "windows" + timestamp: 123456789123 + isCurrentDevice: false + enabled: false + installationId: "b" + } + ListElement { + name: "Device 3" + deviceType: "android" + timestamp: 3456541235346346322 + isCurrentDevice: false + enabled: true + installationId: "c" + } + ListElement { + name: "Device 4" + deviceType: "ios" + timestamp: 385657923539634639 + isCurrentDevice: false + enabled: true + installationId: "d" + } + ListElement { + name: "Device 5" + deviceType: "desktop" + timestamp: 0 + isCurrentDevice: false + enabled: true + installationId: "e" + } + } + } + } + + LogsAndControlsPanel { + id: logsAndControlsPanel + + SplitView.minimumHeight: 100 + SplitView.preferredHeight: 270 + + logsView.logText: logs.logText + + ColumnLayout { + RadioButton { + id: ctrlDevicesLoaded + text: "Devices loaded" + checked: true + } + RadioButton { + id: ctrlDevicesLoading + text: "Devices loading" + } + RadioButton { + id: ctrlDevicesLoadingError + text: "Devices loading error" + } + + Switch { + id: ctrlDebugEnabled + text: "Debug enabled" + } + + Switch { + id: ctrlIsProduction + text: "Is production" + checked: true + } + } + } +} + +// category: Views diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 59cd2aa93c..f9873bd769 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -236,6 +236,7 @@ StatusSectionLayout { implicitWidth: parent.width implicitHeight: parent.height + isProduction: production profileStore: root.store.profileStore devicesStore: root.store.devicesStore privacyStore: root.store.privacyStore diff --git a/ui/app/AppLayouts/Profile/popups/SyncDeviceCustomizationPopup.qml b/ui/app/AppLayouts/Profile/popups/SyncDeviceCustomizationPopup.qml index a53869e247..c462eeb8aa 100644 --- a/ui/app/AppLayouts/Profile/popups/SyncDeviceCustomizationPopup.qml +++ b/ui/app/AppLayouts/Profile/popups/SyncDeviceCustomizationPopup.qml @@ -19,8 +19,8 @@ import "../stores" StatusDialog { id: root - property DevicesStore devicesStore - property AdvancedStore advancedStore + property var devicesStore + property var advancedStore property var deviceModel readonly property string deviceName: d.deviceName diff --git a/ui/app/AppLayouts/Profile/views/SyncingView.qml b/ui/app/AppLayouts/Profile/views/SyncingView.qml index 5925d76894..dc4f82e985 100644 --- a/ui/app/AppLayouts/Profile/views/SyncingView.qml +++ b/ui/app/AppLayouts/Profile/views/SyncingView.qml @@ -27,10 +27,12 @@ import "../../stores" SettingsContentBase { id: root - property DevicesStore devicesStore + property var devicesStore property ProfileStore profileStore property PrivacyStore privacyStore - property AdvancedStore advancedStore + property var advancedStore + + required property bool isProduction ColumnLayout { id: layout @@ -247,11 +249,10 @@ SettingsContentBase { } StatusButton { - objectName: "setupSyncBackupDataButton" id: backupBtn - visible: !production + visible: !root.isProduction Layout.alignment: Qt.AlignHCenter text: qsTr("Backup Data") onClicked : { @@ -264,7 +265,7 @@ SettingsContentBase { id: personalizeDevicePopup SyncDeviceCustomizationPopup { - anchors.centerIn: parent + destroyOnClose: true devicesStore: root.devicesStore advancedStore: root.advancedStore } @@ -274,7 +275,7 @@ SettingsContentBase { id: setupSyncingPopup SetupSyncingPopup { - anchors.centerIn: parent + destroyOnClose: true devicesStore: root.devicesStore profileStore: root.profileStore } diff --git a/ui/app/AppLayouts/Profile/views/qmldir b/ui/app/AppLayouts/Profile/views/qmldir index c92dd75e77..e96a0918aa 100644 --- a/ui/app/AppLayouts/Profile/views/qmldir +++ b/ui/app/AppLayouts/Profile/views/qmldir @@ -4,3 +4,4 @@ AppearanceView 1.0 AppearanceView.qml NotificationsView 1.0 NotificationsView.qml CommunitiesView 1.0 CommunitiesView.qml BrowserView 1.0 BrowserView.qml +SyncingView 1.0 SyncingView.qml