pnp / generator-teams

A Yeoman Generator for Microsoft Teams
https://pnp.github.io/generator-teams
MIT License
428 stars 112 forks source link

Bug report: Configurable Tab has no context in Config page #319

Closed mmsharepoint closed 2 years ago

mmsharepoint commented 2 years ago

Description

I've setup a simple tab (in short: nearly everything set to No) When I directly start this via ngrok The Config page shows a disabled "Save" Quickly debugging shows that useTeams returns context, inTeams as undefined

Steps to reproduce

setup a simple configurable tab Start with ngrok directly (no code modification necessary) Add Tab to a channel Enter config page Detect disabled "Save" button

Expected results

"Save" button should be enabled In fact the hook on "context" should be successfully enter if (context) {...}

Actual results

if (context) {...} is not entered cause of undefined only "Save" stays disabled

Project you experience issues with

generator-teams

generator version

4.0.0

build tools version

1.7.0

nodejs version

v14.17.5

npm version

6.14.14

Operating system (environment)

Windows

Additional Info

No response

stephanbisser commented 2 years ago

Thanks for reporting this Markus, we'll look into it. If you like you can also do a PR to fix it as contributions are more than welcome 😊

mmsharepoint commented 2 years ago

Hi @stephanbisser,

I am already trying but currently quite limited due to health issues... And never handled a tool "inside" like this ... I was extracting the useTeams.ts from Wictor's repo and directly inserting in my project for better debugging and it turns out that this function does not detect the microsoftTeams lib for whatever reasons (I am not yet behind the scenes...)

const isTeamsLibraryLoaded = (): boolean => { // eslint-disable-next-line dot-notation const microsoftTeamsLib = window["microsoftTeams"];

if (!microsoftTeamsLib) {
    return false; // the Microsoft Teams library is for some reason not loaded
}
return true;

};

window["microsoftTeams"]; is undefined here ...

wictorwilen commented 2 years ago

@mmsharepoint - sometimes things goes sideways when you're merging, and you rely on unit testing...that check should no longer be there in that library. An updated version of msteams-react-base-component will be out in an hour or so...

mmsharepoint commented 2 years ago

Fantastic @wictorwilen Will compare, check and give feedback later today

wictorwilen commented 2 years ago

@mmsharepoint - there's a new version in town, or actually two. The msteams-react-base-component@4.0.1 fixes the issue with the missing context and generator-teams@4.0.1 contains a small update to the tab config dialog page that fixes the success notification (another missed merge issue). You can easily fix your existing project by scaffolding out a new empty test project and copy paste the save function.

Thanks for reporting and keep on whacking out great Teams apps!

mmsharepoint commented 2 years ago

Thanks @wictorwilen for the immediate fix now. Configuration works like a charm now. Still facing issues in my more complex sample after that while rendering the tab which seem to show quite similar effect. But let me dive deeper into into it before coming back with the issue or fix report.

mmsharepoint commented 2 years ago

Further issue was on my own (_who would have thought _that__) So everything works now