Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PLUGIN_PACKAGES += mattermost-plugin-calls-v1.11.0
PLUGIN_PACKAGES += mattermost-plugin-github-v2.5.0
PLUGIN_PACKAGES += mattermost-plugin-gitlab-v1.12.0
PLUGIN_PACKAGES += mattermost-plugin-jira-v4.5.1
PLUGIN_PACKAGES += mattermost-plugin-playbooks-v2.6.1
PLUGIN_PACKAGES += mattermost-plugin-playbooks-v2.6.2
PLUGIN_PACKAGES += mattermost-plugin-servicenow-v2.4.0
PLUGIN_PACKAGES += mattermost-plugin-zoom-v1.11.0
PLUGIN_PACKAGES += mattermost-plugin-agents-v1.7.2
Expand Down
5 changes: 5 additions & 0 deletions server/channels/api4/remote_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func remoteClusterAcceptMessage(c *Context, w http.ResponseWriter, r *http.Reque
return
}

auditRec.Success()

if _, err := w.Write(b); err != nil {
c.Logger.Warn("Error while writing response", mlog.Err(err))
}
Expand Down Expand Up @@ -575,8 +577,11 @@ func generateRemoteClusterInvite(c *Context, w http.ResponseWriter, r *http.Requ
inviteCode, invErr := c.App.CreateRemoteClusterInvite(rc.RemoteId, url, rc.Token, password)
if invErr != nil {
c.Err = invErr
return
}

auditRec.Success()

w.WriteHeader(http.StatusCreated)
if err := json.NewEncoder(w).Encode(inviteCode); err != nil {
c.Logger.Warn("Error while writing response", mlog.Err(err))
Expand Down
1 change: 1 addition & 0 deletions server/channels/api4/shared_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func uninviteRemoteClusterToChannel(c *Context, w http.ResponseWriter, r *http.R

// if the channel is not shared with the remote, we return early
if !hasRemote {
auditRec.Success()
w.WriteHeader(http.StatusNoContent)
return
}
Expand Down
4 changes: 2 additions & 2 deletions server/channels/app/integration_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestPostActionResponseSizeLimit(t *testing.T) {
},
}

post, err := th.App.CreatePostAsUser(th.Context, &interactivePost, "", true)
post, _, err := th.App.CreatePostAsUser(th.Context, &interactivePost, "", true)
require.Nil(t, err)
attachments, ok := post.GetProp(model.PostPropsAttachments).([]*model.SlackAttachment)
require.True(t, ok)
Expand Down Expand Up @@ -272,7 +272,7 @@ func TestPostActionResponseSizeLimit(t *testing.T) {
},
}

post, err := th.App.CreatePostAsUser(th.Context, &interactivePost, "", true)
post, _, err := th.App.CreatePostAsUser(th.Context, &interactivePost, "", true)
require.Nil(t, err)
attachments, ok := post.GetProp(model.PostPropsAttachments).([]*model.SlackAttachment)
require.True(t, ok)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ exports[`components/ElasticSearchSettings should match snapshot, disabled 1`] =
/>
}
id="testConfig"
includeDetailedError={false}
includeDetailedError={true}
requestAction={[Function]}
saveNeeded={false}
showSuccessMessage={true}
Expand Down Expand Up @@ -771,7 +771,7 @@ exports[`components/ElasticSearchSettings should match snapshot, enabled 1`] = `
/>
}
id="testConfig"
includeDetailedError={false}
includeDetailedError={true}
requestAction={[Function]}
saveNeeded={false}
showSuccessMessage={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default class ElasticsearchSettings extends OLDAdminSettings<Props, State
return this.state.canSave;
};

doTestConfig = (success: () => void, error: (error: {message: string; detailed_message?: string}) => void): void => {
doTestConfig = (success: () => void, error: (error: {message: string; detailed_error?: string}) => void): void => {
const config = JSON.parse(JSON.stringify(this.props.config));
this.getConfigFromState(config);

Expand All @@ -193,7 +193,7 @@ export default class ElasticsearchSettings extends OLDAdminSettings<Props, State
});
success();
},
(err: {message: string; detailed_message?: string}) => {
(err: {message: string; detailed_error?: string}) => {
this.setState({
configTested: false,
canSave: false,
Expand Down Expand Up @@ -412,6 +412,7 @@ export default class ElasticsearchSettings extends OLDAdminSettings<Props, State
<RequestButton
id='testConfig'
requestAction={this.doTestConfig}
includeDetailedError={true}
helpText={<FormattedMessage {...messages.testHelpText}/>}
buttonText={<FormattedMessage {...messages.elasticsearch_test_button}/>}
successMessage={defineMessage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export class SchemaAdminSettings extends React.PureComponent<SchemaAdminSettings
return (<></>);
}

const handleRequestAction = (success: () => void, error: (error: {message: string}) => void) => {
const handleRequestAction = (success: () => void, error: (error: {message: string; detailed_error?: string}) => void) => {
if (!setting.skipSaveNeeded && this.state.saveNeeded !== false) {
error({
message: this.props.intl.formatMessage({id: 'admin_settings.save_unsaved_changes', defaultMessage: 'Please save unsaved changes first'}),
Expand Down
43 changes: 43 additions & 0 deletions webapp/channels/src/utils/popouts/popout_windows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See LICENSE.txt for license information.

import DesktopApp from 'utils/desktop_api';
import {getBasePath} from 'utils/url';
import {isDesktopApp} from 'utils/user_agent';

import {FOCUS_REPLY_POST, popoutRhsPlugin, popoutThread} from './popout_windows';
Expand All @@ -20,6 +21,10 @@ jest.mock('utils/user_agent', () => ({
isDesktopApp: jest.fn(),
}));

jest.mock('utils/url', () => ({
getBasePath: jest.fn(),
}));

jest.mock('./browser_popouts', () => {
const mockFn = jest.fn();
(globalThis as typeof globalThis & {mockSetupBrowserPopout: typeof mockFn}).mockSetupBrowserPopout = mockFn;
Expand All @@ -33,6 +38,7 @@ jest.mock('./browser_popouts', () => {

const mockDesktopApp = DesktopApp as jest.Mocked<typeof DesktopApp>;
const mockIsDesktopApp = isDesktopApp as jest.MockedFunction<typeof isDesktopApp>;
const mockGetBasePath = getBasePath as jest.MockedFunction<typeof getBasePath>;

const getMockSetupBrowserPopout = () => {
return (globalThis as typeof globalThis & {mockSetupBrowserPopout: jest.MockedFunction<() => unknown>}).mockSetupBrowserPopout;
Expand All @@ -42,6 +48,9 @@ describe('popout_windows', () => {
beforeEach(() => {
jest.clearAllMocks();
getMockSetupBrowserPopout().mockClear();

// Default: no subpath
mockGetBasePath.mockReturnValue('');
});

describe('popoutThread', () => {
Expand Down Expand Up @@ -121,6 +130,23 @@ describe('popout_windows', () => {
expect(mockOnFocusPost).toHaveBeenCalledTimes(1);
expect(mockOnFocusPost).toHaveBeenCalledWith('post-123', '/team/pl/post-123');
});

it('should include subpath in popout URL when basename is set', async () => {
mockIsDesktopApp.mockReturnValue(false);
mockGetBasePath.mockReturnValue('/company/mattermost');
const mockListeners = {
sendToPopout: jest.fn(),
onMessageFromPopout: jest.fn(),
onClosePopout: jest.fn(),
};
getMockSetupBrowserPopout().mockReturnValue(mockListeners);

await popoutThread('Thread - {channelName} - {teamName} - {serverName}', 'thread-123', 'test-team', mockOnFocusPost);

expect(getMockSetupBrowserPopout()).toHaveBeenCalledWith(
'/company/mattermost/_popout/thread/test-team/thread-123',
);
});
});

describe('popoutRhsPlugin', () => {
Expand Down Expand Up @@ -173,6 +199,23 @@ describe('popout_windows', () => {

expect(result).toEqual(mockListeners);
});

it('should include subpath in popout URL when basename is set', async () => {
mockIsDesktopApp.mockReturnValue(false);
mockGetBasePath.mockReturnValue('/company/mattermost');
const mockListeners = {
sendToPopout: jest.fn(),
onMessageFromPopout: jest.fn(),
onClosePopout: jest.fn(),
};
getMockSetupBrowserPopout().mockReturnValue(mockListeners);

await popoutRhsPlugin('{pluginDisplayName} - {serverName}', 'test-plugin-id', 'test-team', 'test-channel');

expect(getMockSetupBrowserPopout()).toHaveBeenCalledWith(
'/company/mattermost/_popout/rhs/test-team/test-channel/plugin/test-plugin-id',
);
});
});
});

5 changes: 3 additions & 2 deletions webapp/channels/src/utils/popouts/popout_windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {PopoutViewProps} from '@mattermost/desktop-api';
import {Client4} from 'mattermost-redux/client';

import DesktopApp from 'utils/desktop_api';
import {getBasePath} from 'utils/url';
import {isDesktopApp} from 'utils/user_agent';

import BrowserPopouts from './browser_popouts';
Expand All @@ -27,7 +28,7 @@ export async function popoutThread(
onFocusPost: (postId: string, returnTo: string) => void,
) {
const popoutListeners = await popout(
`/_popout/thread/${teamName}/${threadId}`,
`${getBasePath()}/_popout/thread/${teamName}/${threadId}`,
{
isRHS: true,
titleTemplate,
Expand All @@ -54,7 +55,7 @@ export async function popoutRhsPlugin(
channelName: string,
) {
const listeners = await popout(
`/_popout/rhs/${teamName}/${channelName}/plugin/${pluginId}`,
`${getBasePath()}/_popout/rhs/${teamName}/${channelName}/plugin/${pluginId}`,
{
isRHS: true,
titleTemplate,
Expand Down
3 changes: 3 additions & 0 deletions webapp/platform/client/src/client4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4500,6 +4500,7 @@ export default class Client4 {
message: msg,
server_error_id: data.id,
status_code: data.status_code,
detailed_error: data.detailed_error,
url,
});
};
Expand Down Expand Up @@ -4896,6 +4897,7 @@ export class ClientError extends Error implements ServerError {
url?: string;
server_error_id?: string;
status_code?: number;
detailed_error?: string;

constructor(baseUrl: string, data: ServerError, cause?: any) {
super(data.message + ': ' + cleanUrlForLogging(baseUrl, data.url || ''), {cause});
Expand All @@ -4904,6 +4906,7 @@ export class ClientError extends Error implements ServerError {
this.url = data.url;
this.server_error_id = data.server_error_id;
this.status_code = data.status_code;
this.detailed_error = data.detailed_error;

// Ensure message is treated as a property of this class when object spreading. Without this,
// copying the object by using `{...error}` would not include the message.
Expand Down
1 change: 1 addition & 0 deletions webapp/platform/types/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ServerError = {
server_error_id?: string;
stack?: string;
message: string;
detailed_error?: string;
status_code?: number;
url?: string;
};
Loading