Skip to content

Adding teams user app list#1874

Closed
sebastienlevert wants to merge 7 commits intopnp:masterfrom
sebastienlevert:1866
Closed

Adding teams user app list#1874
sebastienlevert wants to merge 7 commits intopnp:masterfrom
sebastienlevert:1866

Conversation

@sebastienlevert
Copy link
Copy Markdown
Contributor

Adding teams user app list.

Closes #1866

@waldekmastykarz
Copy link
Copy Markdown
Member

Hey @sebastienlevert, seems like we're missing some coverage. Care to have another look?

@waldekmastykarz waldekmastykarz marked this pull request as draft October 21, 2020 12:42
@sebastienlevert
Copy link
Copy Markdown
Contributor Author

sebastienlevert commented Oct 21, 2020

It actually seems that something happened on the build side. Running them locally is successful. Trying another thing. Just did a new push and it seems that it's at 100% now. Maybe some instability? CircleCI is all good now!

@sebastienlevert
Copy link
Copy Markdown
Contributor Author

Actually... It might have been a PR / push issue by myself (the squash part, probably).

@garrytrinder
Copy link
Copy Markdown
Member

Thanks @sebastienlevert tests all looks good now 👍

I assume that this PR is good for review? If so, let us know clicking the 'Ready for review' button to take the PR out of draft status and it will show up on our radar 😊

image

@sebastienlevert sebastienlevert marked this pull request as ready for review October 21, 2020 16:00
@waldekmastykarz
Copy link
Copy Markdown
Member

Hey @sebastienlevert, have you checked if this command is working? When I'm running it, I'm getting a 403 Forbidden error. Looking at the docs, it seems like users/<user>/teamwork/installedApps is available only in beta while currently the code points to v1.0. Am I missing something?

@sebastienlevert
Copy link
Copy Markdown
Contributor Author

This is so weird... It works on my tenant on both endpoints... But the documentation says /beta.

image

I'll revert to beta for the code, for now.

@sebastienlevert
Copy link
Copy Markdown
Contributor Author

sebastienlevert commented Oct 22, 2020

Also, these CircleCI tests are breaking on and off... Am I breaking all of this or I'm crazy?

image

It seems like there are issues with App Insights!

image

@sebastienlevert
Copy link
Copy Markdown
Contributor Author

Also @waldekmastykarz, did you reconsent to the app permissions? As this command requires the new TeamsAppInstallation.ReadWriteForUser.All scope!

@waldekmastykarz
Copy link
Copy Markdown
Member

@sebastienlevert I've seen intermittent issues with tests. Not sure where it's coming from, but it's something that popped up recently. Seems like we should investigate it.

As for the permissions, I did reconsent the app, but looking at the token, I'm not seeing this scope despite it being in the app reg. Let me have another look at it. Thanks for confirming and sorry for the trouble.

@waldekmastykarz
Copy link
Copy Markdown
Member

Hey @sebastienlevert, seems like the last change you've pushed, is breaking a couple of your tests:

image

Would you mind having a look?

@waldekmastykarz waldekmastykarz removed their assignment Oct 24, 2020
@waldekmastykarz waldekmastykarz marked this pull request as draft October 24, 2020 12:27
@sebastienlevert
Copy link
Copy Markdown
Contributor Author

Just added the /beta to the Unit Tests!

@sebastienlevert sebastienlevert marked this pull request as ready for review October 24, 2020 18:56
@waldekmastykarz waldekmastykarz self-assigned this Oct 27, 2020
Copy link
Copy Markdown
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done with a few minor changes I've done when merging the PR 👍

public get description(): string {
return 'Lists the apps deployed in the personal scope of the specified user';
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing telemetry to track the usage of optional command options

}

public commandAction(logger: Logger, args: CommandArgs, cb: () => void): void {
var userIdPromise: Promise<{ value: string; }>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use let or const instead of the generic var

public commandAction(logger: Logger, args: CommandArgs, cb: () => void): void {
var userIdPromise: Promise<{ value: string; }>;

if(args.options.userName) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make the code easier to read and maintain by putting userId resolution in a separate method.

userIdPromise.then((userId) => {
const endpoint: string = `${this.resource}/beta/users/${encodeURIComponent(userId.value)}/teamwork/installedApps`

this.getAllItems(endpoint, logger, true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid nesting promises and instead return this operation to the main chain.

this.getAllItems(endpoint, logger, true)
.then((): void => {
this.items.map(i => {
var userAppId = Buffer.from(i.id, 'base64').toString('ascii');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use const instead of var as this const is not assigned another value

.then((): void => {
this.items.map(i => {
var userAppId = Buffer.from(i.id, 'base64').toString('ascii');
var appId = userAppId.substr(userAppId.indexOf("##") + 2, userAppId.length - userId.value.length - 2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use const instead of var as this const is not assigned another value

const options: CommandOption[] = [
{
option: '--userId',
description: 'The ID of user to get the apps from'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't match description from the docs

},
{
option: '--userName',
description: 'The UPN of user to get the apps from'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't match description from the docs

}

public get description(): string {
return 'Lists the apps deployed in the personal scope of the specified user';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't match description from the docs (installed vs. deployed)

@waldekmastykarz waldekmastykarz added the hacktoberfest-accepted Accept for hacktoberfest, will merge later label Oct 27, 2020
@waldekmastykarz
Copy link
Copy Markdown
Member

Merged manually. Thank you! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Accept for hacktoberfest, will merge later pr-merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New command: teams user app list

3 participants