OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
686 stars 95 forks source link

Office.ribbon.requestUpdate functionality not able to enabled or disabled menu items dynamically. #3991

Open pankaj59314 opened 10 months ago

pankaj59314 commented 10 months ago

Expected behavior

Current Behaviour

Ribbon JSON

<!--- Include as many relevant details about the environment so we can triage your issue -->
export const getContextualRibbonJSON = (appURL: string) => {
    return {
        actions: [
            {
                id: "idAlphaRibbonAction",
                type: "ExecuteFunction",
                functionName: "openDialog"
            },
            {
                id: "activationBtnAction",
                type: "ExecuteFunction",
                functionName: "openTaskPane"
            },
            {
                id: "taskBtnAction",
                type: "ExecuteFunction",
                functionName: "openTaskMenu"
            },
            {
                id: "configBtnAction",
                type: "ExecuteFunction",
                functionName: "openConfigMenu"
            },
            {
                id: "goToBtnAction",
                type: "ExecuteFunction",
                functionName: "openGoToMenu"
            },
            {
                id: "idLanguageBtnAction",
                type: "ExecuteFunction",
                functionName: "openGoToMenu"
            },
            {
                id: "idLogoBtnAction",
                type: "ExecuteFunction",
                functionName: "openGoToMenu"
            },
            {
                id: "idUserBtnAction",
                type: "ExecuteFunction",
                functionName: "openGoToMenu"
            },
            {
                id: "idAdminBtnAction",
                type: "ExecuteFunction",
                functionName: "openGoToMenu"
            },
            {
                id: "openPrintWindow",
                type: "ExecuteFunction",
                functionName: "openPrintDialog"
            }
        ],
        tabs: [
            {
                id: "TabAddIns",
                label: "AlphA",
                visible: true,
                groups: [
                    {
                        id: "navigationGroup",
                        label: " ",
                        icon: [
                            {
                                size: 16,
                                sourceLocation: `${appURL}/assets/icons/activation/icon-16.png`
                            },
                            {
                                size: 32,
                                sourceLocation: `${appURL}/assets/icons/activation/icon-32.png`
                            },
                            {
                                size: 80,
                                sourceLocation: `${appURL}/assets/icons/activation/icon-80.png`
                            }
                        ],
                        controls: [
                            {
                                type: "Menu",
                                id: "alphaNavigateBtn",
                                label: "Navig",
                                toolTip: "Navig",
                                enabled: true,
                                superTip: {
                                    title: "Navig",
                                    description: "Open configuration windows and display AlphA default sheets"
                                },
                                icon: [
                                    {
                                        size: 16,
                                        sourceLocation: `${appURL}/assets/icons/navigate/icon-16.png`
                                    },
                                    {
                                        size: 32,
                                        sourceLocation: `${appURL}/assets/icons/navigate/icon-32.png`
                                    },
                                    {
                                        size: 80,
                                        sourceLocation: `${appURL}/assets/icons/navigate/icon-80.png`
                                    }
                                ],
                                items: [
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idMainQuoteMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/quote/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/quote/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/quote/icon-80.png`
                                            }
                                        ],
                                        label: "Main Quote",
                                        toolTip: "Main Quote",
                                        superTip: {
                                            title: "Main Quote",
                                            description: "Main Quote"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idRateCardMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/rate_card/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/rate_card/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/rate_card/icon-80.png`
                                            }
                                        ],
                                        label: "Ratecard Film",
                                        toolTip: "Ratecard Film",
                                        superTip: {
                                            title: "Ratecard Film",
                                            description: "Ratecard Film"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idRateCardPhotoMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/rate_card_photo/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/rate_card_photo/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/rate_card_photo/icon-80.png`
                                            }
                                        ],
                                        label: "Ratecard Photo",
                                        toolTip: "Ratecard Photo",
                                        superTip: {
                                            title: "Ratecard Photo",
                                            description: "Ratecard Photo"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idRateCardDigitalMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/rate_card_digital/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/rate_card_digital/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/rate_card_digital/icon-80.png`
                                            }
                                        ],
                                        label: "Ratecard Digital",
                                        toolTip: "Ratecard Digital",
                                        superTip: {
                                            title: "Ratecard Digital",
                                            description: "Ratecard Digital"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idListOfQuoteMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/list_quote/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/list_quote/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/list_quote/icon-80.png`
                                            }
                                        ],
                                        label: "List of Quote",
                                        toolTip: "List of Quote",
                                        superTip: {
                                            title: "List of Quote",
                                            description: "List of Quote"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idLogMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/logs/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/logs/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/logs/icon-80.png`
                                            }
                                        ],
                                        label: "Log",
                                        toolTip: "Log",
                                        superTip: {
                                            title: "Log",
                                            description: "Log"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idConsMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/cons/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/cons/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/cons/icon-80.png`
                                            }
                                        ],
                                        label: "Cons",
                                        toolTip: "Cons",
                                        superTip: {
                                            title: "Cons",
                                            description: "Cons"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idPettyCashMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/petty_cash/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/petty_cash/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/petty_cash/icon-80.png`
                                            }
                                        ],
                                        label: "Petty Cash",
                                        toolTip: "Petty Cash",
                                        superTip: {
                                            title: "Petty Cash",
                                            description: "Petty Cash"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    },
                                    {
                                        type: "MenuItem",
                                        enabled: true,
                                        id: "idAddictiveModelMenu",
                                        icon: [
                                            {
                                                size: 16,
                                                sourceLocation: `${appURL}/assets/icons/model/icon-16.png`
                                            },
                                            {
                                                size: 32,
                                                sourceLocation: `${appURL}/assets/icons/model/icon-32.png`
                                            },
                                            {
                                                size: 80,
                                                sourceLocation: `${appURL}/assets/icons/model/icon-80.png`
                                            }
                                        ],
                                        label: "Additive Model",
                                        toolTip: "Additive Model",
                                        superTip: {
                                            title: "Additive Model",
                                            description: "Additive Model"
                                        },
                                        actionId: "idAlphaRibbonAction"
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

Expected behavior

Current Behaviour

Wenjun-Gong commented 10 months ago

@EsterBergen would you please help to take a look?