Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-50111] Use /install-listed path directly to install marketplace apps #12079

Merged
merged 7 commits into from
Mar 9, 2023

Conversation

mickmister
Copy link
Member

@mickmister mickmister commented Jan 27, 2023

Summary

As we are transitioning to support HTTP apps in Cloud servers, we need to have a consistent install path across all environments.

At the moment, the frontend has conditional logic of how to install marketplace apps. This PR makes it so the App framework can instead have this logic.

Ticket Link

Fixes https://mattermost.atlassian.net/browse/MM-50111

NONE

@mickmister mickmister added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jan 27, 2023
@mattermost-build
Copy link
Contributor

E2E tests not automatically triggered, because PR has no approval yet. Please ask a developer to review and then try again to attach the QA label.

Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Thanks for cleanin up my messy code 👍

I leave a few comment, but nothing blocking.

actions/marketplace.ts Outdated Show resolved Hide resolved
const channelID = getCurrentChannelId(state);
const teamID = getCurrentTeamId(state);
const context = createCallContext('apps', '/marketplace', channelID, teamID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is /marketplace the location here? What is the location used in other form calls?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hanzei Yes I kind of made this new location up here. The location in other form calls would be something like /command/jira/issue/create. 0/5 on what the location should be here, or if we should include one at all

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just not use a location at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hanzei I think there are tradeoffs between including or not including a location. I think we have the convention that all calls come from a location, but I think that can be avoided in this case. Do you see value in including the location? We can instead have it be an empty string.

Comment on lines +173 to 183

const callResp = res.data!;
if (callResp.type === AppCallResponseTypes.FORM && callResp.form) {
dispatch(openAppsModal(callResp.form, creq.context));
}

if (callResp.text) {
dispatch(postEphemeralCallResponseForContext(callResp, callResp.text, context));
}

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we de-duplicate the code used here? Is there a way to throw the call response in the normal event pipeline?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hanzei We purposely have the logic different in each binding location case, so special cases can easily be handled. We could have a "default" handler to be used that does these sort of actions shown above. A "nothing special" call response handler function

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is out of scope of this PR though.

There is an improvement I made in the mobile app for this https://github.com/mattermost/mattermost-mobile/blob/aa6c1ff0583751085967c9fdffd67789f7b24421/app/hooks/apps.ts#L21-L26

export type UseAppBindingConfig = {
    onSuccess: (callResponse: AppCallResponse, message: string) => void;
    onError: (callResponse: AppCallResponse, message: string) => void;
    onForm?: (form: AppForm) => void;
    onNavigate?: (callResp: AppCallResponse) => void;
}

This allows the caller to supply at least onSuccess and onError, and things like opening a form is done automatically. I made a ticket to add this to the webapp https://mattermost.atlassian.net/browse/MM-50197

@hanzei
Copy link
Contributor

hanzei commented Jan 31, 2023

/update-branch

@hanzei hanzei changed the title Use /install-listed path directly to install marketplace apps [https://mattermost.atlassian.net/browse/]MM-50111] Use /install-listed path directly to install marketplace apps Jan 31, 2023
@hanzei hanzei changed the title [https://mattermost.atlassian.net/browse/]MM-50111] Use /install-listed path directly to install marketplace apps [MM-50111] Use /install-listed path directly to install marketplace apps Jan 31, 2023
@amyblais
Copy link
Member

amyblais commented Feb 7, 2023

/update-branch

@amyblais
Copy link
Member

amyblais commented Feb 7, 2023

@levb @DHaussermann Kind note to prioritize this PR review if this is needed for v7.8.

@DHaussermann
Copy link

DHaussermann commented Feb 7, 2023

@mickmister can you clarify if this will have a code dependancy on what version of the Apps framework plugin is running? Or would existing version of the Apps framework also be functional with this code change?

I can of course test this - I'm just curious about the expected behavior here.

@mickmister
Copy link
Member Author

@DHaussermann This change is backwards compatible with the framework. No changes are needed on the framework side

@amyblais amyblais removed this from the v7.8.0 milestone Feb 9, 2023
@hanzei hanzei added this to the v7.9.0 milestone Feb 14, 2023
@hanzei hanzei requested a review from hmhealey February 14, 2023 15:15
Copy link
Member

@hmhealey hmhealey left a comment

Choose a reason for hiding this comment

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

I don't understand the apps logic enough to review that fully, but the code itself looks good to me from what I can tell

@hanzei hanzei removed the request for review from levb February 16, 2023 20:47
@hanzei hanzei removed the 2: Dev Review Requires review by a core commiter label Feb 16, 2023
@amyblais amyblais removed this from the v7.9.0 milestone Feb 23, 2023
@DHaussermann
Copy link

/update-branch

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

Test Results

       1 files     815 suites   14m 27s ⏱️
6 933 tests 6 932 ✔️ 1 💤 0
7 109 runs  7 108 ✔️ 1 💤 0

Results for commit 5ccdb5f.

Copy link

@DHaussermann DHaussermann left a comment

Choose a reason for hiding this comment

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

Tested and passed

  • Tested that marketplace install button works consistently now
  • Cloud license and non-cloud license
  • Apps 1.2.0 as well as newest 1.2.1 (not yet released)
  • In all cases the marketplace UI button works now
  • Regression tested installing via command line as a precaution
  • Regression tested HTTP installs as a precaution

LGTM!

@DHaussermann DHaussermann added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels Mar 9, 2023
@mickmister mickmister merged commit 1404fa7 into master Mar 9, 2023
@mickmister mickmister deleted the marketplace-install-listed-app branch March 9, 2023 15:25
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Lifecycle/frozen release-note-none
Projects
None yet
8 participants