From 9d820b8d029bb9e9984af0d61ba60b3cd4d13ece Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 26 Jul 2022 17:21:08 +0200 Subject: [PATCH] Redirect to USB workflow if user account doesn't have permissions If the user is not allowed to write profiles to the printers, then they'd get errors when trying to sync. Instead we'll redirect them to the USB workflow. This also works for users that have accounts but don't have the printers in the cloud. The original requirements suggest that the entire sync button must be hidden for this case. But to allow those people to still sync via USB I'm opting for this solution instead. Contributes to issue CURA-9220. --- .../Materials/MaterialsSyncDialog.qml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml b/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml index 4fd82b3e02..ce3f9c4303 100644 --- a/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml +++ b/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml @@ -88,7 +88,15 @@ UM.Window { if(Cura.API.account.isLoggedIn) { - swipeView.currentIndex += 2; //Skip sign in page. + if(Cura.API.account.permissions.includes("digital-factory.printer.write")) + { + swipeView.currentIndex += 2; //Skip sign in page. Continue to sync via cloud. + } + else + { + //Logged in, but no permissions to start syncing. Direct them to USB. + swipeView.currentIndex = removableDriveSyncPage.SwipeView.index; + } } else { @@ -112,7 +120,15 @@ UM.Window { if(is_logged_in && signinPage.SwipeView.isCurrentItem) { - swipeView.currentIndex += 1; + if(Cura.API.account.permissions.includes("digital-factory.printer.write")) + { + swipeView.currentIndex += 1; + } + else + { + //Logged in, but no permissions to start syncing. Direct them to USB. + swipeView.currentIndex = removableDriveSyncPage.SwipeView.index; + } } } }