Mig82
Mig82

Reputation: 5478

How to show or hide MS Teams tabs programmatically?

We're working on an app for Microsoft Teams where we need to make some tabs visible or not at runtime, depending on tenant and user permissions. So for example:

These are all personal tabs BTW. I can't find anything in the docs that would help in this regard. Seems the tabs are fixed by the manifest and will show the same for all users.

Can this be done? how? I might settle for any feasible workarounds.

Upvotes: 2

Views: 1067

Answers (1)

Sayali-MSFT
Sayali-MSFT

Reputation: 369

As such there no direct way to do that .

However you can have ConfigureTabs and when you add that tab to a channel configure page, it will show up. You can then get the context and check what you want to do with that specific team (Maybe need to use Graph API to get more info with team Id).

This logic will run on the configuration page when the user selects to save. You can have a tab according to the logic.

microsoftTeams.settings.registerOnSaveHandler((saveEvent) => {
    microsoftTeams.settings.setSettings({
        websiteUrl: "https://your-website.com",
        contentUrl: "https://your-website.com/red",
        entityId: "redIconTab",
        suggestedDisplayName: "MyNewTab"
    })
    saveEvent.notifySuccess()
})

This can't be done with multiple config tabs or with static tabs. About showing tabs to some users, that is also not possible directly with the manifest.

However, you can use getContext and get the userObjectId, based on which we can show a page maybe saying "You don't have permission".

Upvotes: 2

Related Questions