openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

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

Open OussamaK opened this issue 1 year ago • 1 comments

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.

OussamaK avatar Jan 30 '24 09:01 OussamaK

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

yanaminkova avatar Feb 06 '24 14:02 yanaminkova