SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.94k stars 1.23k forks source link

No way to hide user preferences entry added with sap.ushell.renderers.fiori2.Renderer.addUserPreferencesEntry #3959

Open OussamaK opened 7 months ago

OussamaK commented 7 months ago

OpenUI5 version: 1.71.62 and above Browser/version (+device/version): NA

I created a user preferences entry using the API found here: https://sapui5.hana.ondemand.com/sdk/#/api/sap.ushell.renderers.fiori2.Renderer%23methods/addUserPreferencesEntry This entry remains as long as the user doesn't refresh the page. This means preferences entries aren't application specific, even when we add them in the App.controller.js for example, since the user can still see the entry when they navigate to a new application. I looked around a bit in UserSettings.controller.js and found that the entry factory can a take "visible" boolean to control whether the entry is visible or not:

return new StandardListItem(sId, {
                title: { path: "entries>title" },
                description: { path: "entries>valueResult" },
                icon: {
                    parts: [
                        { path: "entries>icon" },
                        { path: "/userImage/account" }
                    ],
                    formatter: this._getEntryIcon
                },
                visible: {
                    parts: [
                        { path: "entries>visible"},
                        { path: "entries>defaultVisibility"},
                        { path: "entries>title"}
                    ],
                    formatter: this._getEntryVisible.bind(this)
                },
                type: Device.system.phone ? "Navigation" : "Inactive"
            }).addStyleClass("sapUshellUserSettingMasterListItem");

However, in Shell.controller.js this is completely ignored

return {
                "entryHelpID": entryObject.entryHelpID,
                "title": entryObject.title,
                "editable": !!entryObject.content,
                "valueArgument": entryObject.value,
                "valueResult": null,
                "onSave": entryObject.onSave,
                "onCancel": entryObject.onCancel,
                "contentFunc": entryObject.content,
                "contentResult": null,
                "icon": entryObject.icon
            };

If I add the visible attribute manually, the other settings are broken, and an error in the console complains about creating duplicates.

If there is no way to destroy the entry once it is created, there must be a way to hide it. The current workaround would be to reference directly the sap.m.StandardListItem control using sap.ui.getCore().byId() and hide it, or somehow navigate upward from the user preferences' content to that control and hide it.

yanaminkova commented 7 months ago

Hello @OussamaK

Thank you for sharing this finding. I've created an internal incident DINC0060204. The status of the issue will be updated here in GitHub.

Regards, Yana