diff options
-rw-r--r-- | resources/qml/ApplicationSwitcher/ApplicationSwitcherPopup.qml | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/resources/qml/ApplicationSwitcher/ApplicationSwitcherPopup.qml b/resources/qml/ApplicationSwitcher/ApplicationSwitcherPopup.qml index ede42fcd5f..d79bf29079 100644 --- a/resources/qml/ApplicationSwitcher/ApplicationSwitcherPopup.qml +++ b/resources/qml/ApplicationSwitcher/ApplicationSwitcherPopup.qml @@ -33,63 +33,72 @@ Popup thumbnail: UM.Theme.getIcon("PrinterTriple", "high"), description: catalog.i18nc("@tooltip:button", "Monitor printers in Ultimaker Digital Factory."), link: "https://digitalfactory.ultimaker.com/app/printers?utm_source=cura&utm_medium=software&utm_campaign=switcher-digital-factory-printers", - DFAccessRequired: true + DFAccessRequired: true, + permissionsRequired: ["digital-factory.printer.read"] }, { displayName: "Digital Library", //Not translated, since it's a brand name. thumbnail: UM.Theme.getIcon("Library", "high"), description: catalog.i18nc("@tooltip:button", "Create print projects in Digital Library."), link: "https://digitalfactory.ultimaker.com/app/library?utm_source=cura&utm_medium=software&utm_campaign=switcher-library", - DFAccessRequired: true + DFAccessRequired: true, + permissionsRequired: ["digital-factory.project.read.shared"] }, { displayName: catalog.i18nc("@label:button", "Print jobs"), thumbnail: UM.Theme.getIcon("FoodBeverages"), description: catalog.i18nc("@tooltip:button", "Monitor print jobs and reprint from your print history."), link: "https://digitalfactory.ultimaker.com/app/print-jobs?utm_source=cura&utm_medium=software&utm_campaign=switcher-digital-factory-printjobs", - DFAccessRequired: true + DFAccessRequired: true, + permissionsRequired: ["digital-factory.print-job.read"] }, { displayName: "Ultimaker Marketplace", //Not translated, since it's a brand name. thumbnail: UM.Theme.getIcon("Shop", "high"), description: catalog.i18nc("@tooltip:button", "Extend Ultimaker Cura with plugins and material profiles."), link: "https://marketplace.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-marketplace-materials", - DFAccessRequired: false + DFAccessRequired: false, + permissionsRequired: [] }, { displayName: "Ultimaker Academy", //Not translated, since it's a brand name. thumbnail: UM.Theme.getIcon("Knowledge"), description: catalog.i18nc("@tooltip:button", "Become a 3D printing expert with Ultimaker e-learning."), link: "https://academy.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-academy", - DFAccessRequired: false + DFAccessRequired: false, + permissionsRequired: [] }, { displayName: catalog.i18nc("@label:button", "Ultimaker support"), thumbnail: UM.Theme.getIcon("Help", "high"), description: catalog.i18nc("@tooltip:button", "Learn how to get started with Ultimaker Cura."), link: "https://support.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-support", - DFAccessRequired: false + DFAccessRequired: false, + permissionsRequired: [] }, { displayName: catalog.i18nc("@label:button", "Ask a question"), thumbnail: UM.Theme.getIcon("Speak", "high"), description: catalog.i18nc("@tooltip:button", "Consult the Ultimaker Community."), link: "https://community.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-community", - DFAccessRequired: false + DFAccessRequired: false, + permissionsRequired: [] }, { displayName: catalog.i18nc("@label:button", "Report a bug"), thumbnail: UM.Theme.getIcon("Bug", "high"), description: catalog.i18nc("@tooltip:button", "Let developers know that something is going wrong."), link: "https://github.com/Ultimaker/Cura/issues/new/choose", - DFAccessRequired: false + DFAccessRequired: false, + permissionsRequired: [] }, { displayName: "Ultimaker.com", //Not translated, since it's a URL. thumbnail: UM.Theme.getIcon("Browser"), description: catalog.i18nc("@tooltip:button", "Visit the Ultimaker website."), link: "https://ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-umwebsite", - DFAccessRequired: false + DFAccessRequired: false, + permissionsRequired: [] } ] @@ -99,7 +108,28 @@ Popup iconSource: modelData.thumbnail tooltipText: modelData.description isExternalLink: true - visible: modelData.DFAccessRequired ? Cura.API.account.isLoggedIn & Cura.API.account.additionalRights["df_access"] : true + visible: + { + if(modelData.DFAccessRequired && (!Cura.API.account.isLoggedIn || !Cura.API.account.additionalRights["df_access"])) + { + return false; + } + try + { + modelData.permissionsRequired.forEach(function(permission) + { + if(!Cura.API.account.isLoggedIn || !Cura.API.account.permissions.includes(permission)) //This required permission is not in the account. + { + throw "No permission to use this application."; //Can't return from within this lambda. Throw instead. + } + }); + } + catch(e) + { + return false; + } + return true; + } onClicked: Qt.openUrlExternally(modelData.link) } |