This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Separate calls for Apps #9263
Merged
Merged
Separate calls for Apps #9263
Changes from 28 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
f2f9368
WIP - need to restore Binding.Call
2b9554c
Merge branch 'master' into lev-MM-39092-separate-calls
98075c4
Merge branch 'master' into lev-MM-39092-separate-calls
larkox f05821f
Address missing pieces
larkox b5cd58a
Re-add the submit field on calls and improve tests
larkox df295bf
Update i18n
larkox 09e0b25
apps API changes fixup
46a1615
apps API changes fixup #2: form/modal
3dadf0f
Merge branch 'master' into separateCalls
larkox a26ac2b
Address feedback
larkox 5e757aa
Merge branch 'separateCalls' into lev-separateCalls
larkox 88ab662
Address feedback
larkox d9182f2
Merge pull request #7 from levb/lev-separateCalls
larkox 27406da
Fix lint
larkox bed64e2
Fix missing error->text change
larkox 3c12a59
Merge branch 'master' into separateCalls
mickmister fcf1c98
fix openAppsModal references
mickmister c974c9e
lint, types, and i18n
mickmister 47f1794
lint
mickmister cb60e92
missing method
mickmister 1fe3ccb
update snapshots
mickmister 8c32ad9
Merge branch 'master' of github.com:mattermost/mattermost-webapp into…
4720a78
Fixed handleBindingClick, was double-wrapping .data
2e3960a
fixed embedded button binding
35cd488
Merge branch 'master' of github.com:mattermost/mattermost-webapp into…
b03f3c0
Merge branch 'master' into separateCalls
mattermod c55ed22
Merge branch 'master' into separateCalls
mattermod c5341c4
Merge branch 'master' into separateCalls
mattermod ec02f34
various fixes
mickmister 0e620e9
fix lookups for command parser
mickmister ce445e9
sync app command parser
mickmister 944baf7
Merge branch 'master' into separateCalls
mickmister b31000b
types
mickmister 4571966
fix tests
mickmister a2c93b5
change control flow for cleaning bindings
mickmister 4a27b70
re-expand bindings when post is updated
mickmister d43c479
getDerivedStateFromProps to avoid lint rule
mickmister 4c60359
avoid `this` usage in static function
mickmister 7f31aa3
fix other spot with same issue
mickmister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,7 +12,7 @@ import {IntegrationTypes} from 'mattermost-redux/action_types'; | |||||
import {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; | ||||||
import type {CommandArgs} from 'mattermost-redux/types/integrations'; | ||||||
|
||||||
import {AppCallResponseTypes, AppCallTypes} from 'mattermost-redux/constants/apps'; | ||||||
import {AppCallResponseTypes} from 'mattermost-redux/constants/apps'; | ||||||
|
||||||
import {DoAppCallResult} from 'types/apps'; | ||||||
|
||||||
|
@@ -36,7 +36,7 @@ import {GlobalState} from 'types/store'; | |||||
|
||||||
import {t} from 'utils/i18n'; | ||||||
|
||||||
import {doAppCall, openAppsModal, postEphemeralCallResponseForCommandArgs} from './apps'; | ||||||
import {doAppSubmit, openAppsModal, postEphemeralCallResponseForCommandArgs} from './apps'; | ||||||
|
||||||
export function executeCommand(message: string, args: CommandArgs): ActionFunc { | ||||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { | ||||||
|
@@ -123,16 +123,16 @@ export function executeCommand(message: string, args: CommandArgs): ActionFunc { | |||||
const parser = new AppCommandParser({dispatch, getState: getGlobalState} as any, intlShim, args.channel_id, args.team_id, args.root_id); | ||||||
if (parser.isAppCommand(msg)) { | ||||||
try { | ||||||
const {call, errorMessage} = await parser.composeCallFromCommand(msg); | ||||||
if (!call) { | ||||||
const {creq, errorMessage} = await parser.composeCommandSubmitCall(msg); | ||||||
if (!creq) { | ||||||
return createErrorMessage(errorMessage!); | ||||||
} | ||||||
|
||||||
const res = await dispatch(doAppCall(call, AppCallTypes.SUBMIT, intlShim)) as DoAppCallResult; | ||||||
const res = await dispatch(doAppSubmit(creq, intlShim)) as DoAppCallResult; | ||||||
|
||||||
if (res.error) { | ||||||
const errorResponse = res.error; | ||||||
return createErrorMessage(errorResponse.error || intlShim.formatMessage({ | ||||||
return createErrorMessage(errorResponse.text || intlShim.formatMessage({ | ||||||
id: 'apps.error.unknown', | ||||||
defaultMessage: 'Unknown error.', | ||||||
})); | ||||||
|
@@ -141,13 +141,13 @@ export function executeCommand(message: string, args: CommandArgs): ActionFunc { | |||||
const callResp = res.data!; | ||||||
switch (callResp.type) { | ||||||
case AppCallResponseTypes.OK: | ||||||
if (callResp.markdown) { | ||||||
dispatch(postEphemeralCallResponseForCommandArgs(callResp, callResp.markdown, args)); | ||||||
if (callResp.text) { | ||||||
dispatch(postEphemeralCallResponseForCommandArgs(callResp, callResp.text, args)); | ||||||
} | ||||||
return {data: true}; | ||||||
case AppCallResponseTypes.FORM: | ||||||
if (callResp.form) { | ||||||
dispatch(openAppsModal(callResp.form, call)); | ||||||
dispatch(openAppsModal(callResp.form, creq.context)); | ||||||
} | ||||||
return {data: true}; | ||||||
case AppCallResponseTypes.NAVIGATE: | ||||||
|
@@ -159,7 +159,7 @@ export function executeCommand(message: string, args: CommandArgs): ActionFunc { | |||||
{type: callResp.type}, | ||||||
)); | ||||||
} | ||||||
} catch (err) { | ||||||
} catch (err: any) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return createErrorMessage(err.message || localizeMessage('apps.error.unknown', 'Unknown error.')); | ||||||
} | ||||||
} | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.