Browse Source

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.
Ghostkeeper 2 years ago
parent
commit
9d820b8d02
1 changed files with 18 additions and 2 deletions
  1. 18 2
      resources/qml/Preferences/Materials/MaterialsSyncDialog.qml

+ 18 - 2
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;
+                        }
                     }
                 }
             }