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

Commit

Permalink
Merge branch 'feature/cloud-apps-rebase' into select-visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mattermod committed Apr 7, 2021
2 parents 49f0825 + 4180838 commit 4202781
Show file tree
Hide file tree
Showing 93 changed files with 1,420 additions and 382 deletions.
10 changes: 3 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
stages:
- test
# These need to have separate stages, otherwise artifacts would overwrite each other
- te-build
- te-s3
- ee-build
- ee-s3
- create-vars
- build
- s3
- trigger

variables:
Expand All @@ -18,7 +14,7 @@ include:
file: private.yml

empty:
stage: create-vars
stage: test
script:
- echo "empty"

Expand Down
2 changes: 1 addition & 1 deletion actions/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {getSiteURL, shouldOpenInNewTab} from 'utils/url';
import {browserHistory} from 'utils/browser_history';
import {makeCallErrorResponse} from 'utils/apps';

export function doAppCall<Res=unknown>(call: AppCallRequest, type: AppCallType, intl: any): ActionFunc { // eslint-disable-line @typescript-eslint/no-unused-vars
export function doAppCall<Res=unknown>(call: AppCallRequest, type: AppCallType, intl: any): ActionFunc {
return async (dispatch: DispatchFunc) => {
try {
const res = await Client4.executeAppCall(call, type) as AppCallResponse<Res>;
Expand Down
3 changes: 1 addition & 2 deletions actions/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {savePreferences} from 'mattermost-redux/actions/preferences';
import {getCurrentChannel, getRedirectChannelNameForTeam, isFavoriteChannel} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getCurrentRelativeTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
import {IntegrationTypes} from 'mattermost-redux/action_types';
import {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
import type {CommandArgs} from 'mattermost-redux/types/integrations';
Expand All @@ -31,8 +32,6 @@ import {intlShim} from 'components/suggestion/command_provider/app_command_parse

import {GlobalState} from 'types/store';

import {appsEnabled} from 'utils/apps';

import {t} from 'utils/i18n';

import {doAppCall} from './apps';
Expand Down
3 changes: 1 addition & 2 deletions actions/global_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentTeamId, getMyTeams, getTeam, getMyTeamMember, getTeamMemberships} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUser, getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getCurrentChannelStats, getCurrentChannelId, getMyChannelMember, getRedirectChannelNameForTeam, getChannelsNameMapInTeam, getAllDirectChannels} from 'mattermost-redux/selectors/entities/channels';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
import {ChannelTypes} from 'mattermost-redux/action_types';
import {fetchAppBindings} from 'mattermost-redux/actions/apps';
import {Channel, ChannelMembership} from 'mattermost-redux/types/channels';
Expand Down Expand Up @@ -43,8 +44,6 @@ import {filterAndSortTeamsByDisplayName} from 'utils/team_utils.jsx';
import * as Utils from 'utils/utils.jsx';
import SubMenuModal from '../components/widgets/menu/menu_modals/submenu_modal/submenu_modal';

import {appsEnabled} from 'utils/apps';

import {openModal} from './views/modals';

const dispatch = store.dispatch;
Expand Down
3 changes: 1 addition & 2 deletions actions/marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Client4} from 'mattermost-redux/client';

import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';

import {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
import type {MarketplaceApp, MarketplacePlugin} from 'mattermost-redux/types/marketplace';
Expand All @@ -17,8 +18,6 @@ import {ActionTypes} from 'utils/constants';

import {isError} from 'types/actions';

import {appsEnabled} from 'utils/apps';

import {executeCommand} from './command';

// fetchPlugins fetches the latest marketplace plugins and apps, subject to any existing search filter.
Expand Down
12 changes: 10 additions & 2 deletions actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general
import {getChannelsInTeam, getChannel, getCurrentChannel, getCurrentChannelId, getRedirectChannelNameForTeam, getMembersInCurrentChannel, getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels';
import {getPost, getMostRecentPostIdInChannel} from 'mattermost-redux/selectors/entities/posts';
import {haveISystemPermission, haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
import {getStandardAnalytics} from 'mattermost-redux/actions/admin';

import {fetchAppBindings} from 'mattermost-redux/actions/apps';
Expand All @@ -83,7 +84,6 @@ import {getSiteURL} from 'utils/url';
import {isGuest} from 'utils/utils';
import RemovedFromChannelModal from 'components/removed_from_channel_modal';
import InteractiveDialog from 'components/interactive_dialog';
import {appsEnabled} from 'utils/apps';

const dispatch = store.dispatch;
const getState = store.getState;
Expand Down Expand Up @@ -183,6 +183,7 @@ export function reconnect(includeWebSocket = true) {
const mostRecentId = getMostRecentPostIdInChannel(state, currentChannelId);
const mostRecentPost = getPost(state, mostRecentId);
dispatch(loadChannelsForCurrentUser());
dispatch(handleRefreshAppsBindings());
if (mostRecentPost) {
dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at));
} else {
Expand Down Expand Up @@ -484,8 +485,10 @@ export function handleEvent(msg) {
case SocketEvents.CLOUD_PAYMENT_STATUS_UPDATED:
dispatch(handleCloudPaymentStatusUpdated(msg));
break;
case SocketEvents.FIRST_ADMIN_VISIT_MARKETPLACE_STATUS_RECEIVED:
handleFirstAdminVisitMarketplaceStatusReceivedEvent(msg);
break;

// Apps framework events
case SocketEvents.APPS_FRAMEWORK_REFRESH_BINDINGS: {
dispatch(handleRefreshAppsBindings(msg));
break;
Expand Down Expand Up @@ -1377,3 +1380,8 @@ function handleRefreshAppsBindings() {
return {data: true};
};
}

function handleFirstAdminVisitMarketplaceStatusReceivedEvent(msg) {
const receivedData = JSON.parse(msg.data.firstAdminVisitMarketplaceStatus);
store.dispatch({type: GeneralTypes.FIRST_ADMIN_VISIT_MARKETPLACE_STATUS_RECEIVED, data: receivedData});
}
29 changes: 18 additions & 11 deletions client/websocket_client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ const MAX_WEBSOCKET_RETRY_TIME = 300000; // 5 mins
export default class WebSocketClient {
private conn: WebSocket | null;
private connectionUrl: string | null;
private sequence: number;
private eventSequence: number;

// responseSequence is the number to track a response sent
// via the websocket. A response will always have the same sequence number
// as the request.
private responseSequence: number;

// serverSequence is the incrementing sequence number from the
// server-sent event stream.
private serverSequence: number;
private connectFailCount: number;
private eventCallback: ((msg: any) => void) | null;
private responseCallbacks: {[x: number]: ((msg: any) => void)};
Expand All @@ -22,8 +29,8 @@ export default class WebSocketClient {
constructor() {
this.conn = null;
this.connectionUrl = null;
this.sequence = 1;
this.eventSequence = 0;
this.responseSequence = 1;
this.serverSequence = 0;
this.connectFailCount = 0;
this.eventCallback = null;
this.responseCallbacks = {};
Expand Down Expand Up @@ -52,7 +59,7 @@ export default class WebSocketClient {
this.connectionUrl = connectionUrl;

this.conn.onopen = () => {
this.eventSequence = 0;
this.serverSequence = 0;

if (token) {
this.sendMessage('authentication_challenge', {token});
Expand All @@ -72,7 +79,7 @@ export default class WebSocketClient {

this.conn.onclose = () => {
this.conn = null;
this.sequence = 1;
this.responseSequence = 1;

if (this.connectFailCount === 0) {
console.log('websocket closed'); //eslint-disable-line no-console
Expand Down Expand Up @@ -125,11 +132,11 @@ export default class WebSocketClient {
Reflect.deleteProperty(this.responseCallbacks, msg.seq_reply);
}
} else if (this.eventCallback) {
if (msg.seq !== this.eventSequence && this.missedEventCallback) {
console.log('missed websocket event, act_seq=' + msg.seq + ' exp_seq=' + this.eventSequence); //eslint-disable-line no-console
if (msg.seq !== this.serverSequence && this.missedEventCallback) {
console.log('missed websocket event, act_seq=' + msg.seq + ' exp_seq=' + this.serverSequence); //eslint-disable-line no-console
this.missedEventCallback();
}
this.eventSequence = msg.seq + 1;
this.serverSequence = msg.seq + 1;
this.eventCallback(msg);
}
};
Expand Down Expand Up @@ -161,7 +168,7 @@ export default class WebSocketClient {

close() {
this.connectFailCount = 0;
this.sequence = 1;
this.responseSequence = 1;
if (this.conn && this.conn.readyState === WebSocket.OPEN) {
this.conn.onclose = () => {}; //eslint-disable-line no-empty-function
this.conn.close();
Expand All @@ -173,7 +180,7 @@ export default class WebSocketClient {
sendMessage(action: string, data: any, responseCallback?: () => void) {
const msg = {
action,
seq: this.sequence++,
seq: this.responseSequence++,
data,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with
},
Object {
"order": 9,
"text": "Svenska (Beta)",
"text": "Svenska",
"value": "sv",
},
Object {
Expand All @@ -341,7 +341,7 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with
},
Object {
"order": 11,
"text": "Български (Beta)",
"text": "Български",
"value": "bg",
},
Object {
Expand Down Expand Up @@ -447,7 +447,7 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with
},
Object {
"order": 9,
"text": "Svenska (Beta)",
"text": "Svenska",
"value": "sv",
},
Object {
Expand All @@ -457,7 +457,7 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with
},
Object {
"order": 11,
"text": "Български (Beta)",
"text": "Български",
"value": "bg",
},
Object {
Expand Down
3 changes: 2 additions & 1 deletion components/admin_console/custom_plugin_settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {connect} from 'react-redux';
import {createSelector} from 'reselect';

import {getRoles} from 'mattermost-redux/selectors/entities/roles';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';

import {Constants} from 'utils/constants';
import {localizeMessage} from 'utils/utils.jsx';
Expand All @@ -13,7 +14,7 @@ import {getAdminConsoleCustomComponents} from 'selectors/admin_console';
import SchemaAdminSettings from '../schema_admin_settings';
import {it} from '../admin_definition';

import {appsEnabled, appsPluginID} from 'utils/apps';
import {appsPluginID} from 'utils/apps';

import CustomPluginSettings from './custom_plugin_settings.jsx';
import getEnablePluginSetting from './enable_plugin_setting';
Expand Down
3 changes: 1 addition & 2 deletions components/admin_console/plugin_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
} from 'mattermost-redux/actions/admin';

import {GenericAction} from 'mattermost-redux/types/actions';

import {appsEnabled} from 'utils/apps';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';

import PluginManagement from './plugin_management';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const PluginItem = ({
appsEnabled,
isDisabled,
}: PluginItemProps) => {
let activateButton: JSX.Element | null;
let activateButton: React.ReactNode;
const activating = pluginStatus.state === PluginState.PLUGIN_STATE_STARTING;
const deactivating = pluginStatus.state === PluginState.PLUGIN_STATE_STOPPING;

Expand Down Expand Up @@ -257,7 +257,7 @@ const PluginItem = ({
/>
);
}
let removeButton: JSX.Element | null = (
let removeButton: React.ReactNode = (
<span>
{' - '}
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ exports[`components/apps_form/AppsFormContainer should match snapshot 1`] = `
"path": "/form_url",
}
}
emojiMap={
EmojiMap {
"customEmojis": Map {},
"customEmojisArray": Array [],
}
}
form={
Object {
"fields": Array [
Expand Down
48 changes: 14 additions & 34 deletions components/apps_form/__snapshots__/apps_form_header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`components/apps_form/AppsFormHeader should not fail on empty value 1`] = `
<AppsFormHeader
emojiMap={
EmojiMap {
"customEmojis": Map {},
"customEmojisArray": Array [],
<Connect(Markdown)
message=""
options={
Object {
"mentionHighlight": false,
"singleline": false,
}
}
id="testblankvalue"
value=""
>
<span
dangerouslySetInnerHTML={
Object {
"__html": "",
}
}
id="testblankvalue"
/>
</AppsFormHeader>
/>
`;

exports[`components/apps_form/AppsFormHeader should render message with supported values 1`] = `
<AppsFormHeader
emojiMap={
EmojiMap {
"customEmojis": Map {},
"customEmojisArray": Array [],
<Connect(Markdown)
message="**bold** *italic* [link](https://mattermost.com/) <br/> [link target blank](!https://mattermost.com/)"
options={
Object {
"mentionHighlight": false,
"singleline": false,
}
}
id="testsupported"
value="**bold** *italic* [link](https://mattermost.com/) <br/> [link target blank](!https://mattermost.com/)"
>
<span
dangerouslySetInnerHTML={
Object {
"__html": "<p><strong>bold</strong> <em>italic</em> <a class=\\"theme markdown__link\\" href=\\"https://mattermost.com/\\" rel=\\"noreferrer\\" target=\\"_blank\\">link</a> &lt;br/&gt; <a class=\\"theme markdown__link\\" href=\\"!https://mattermost.com/\\" rel=\\"noreferrer\\" target=\\"_blank\\">link target blank</a></p>",
}
}
id="testsupported"
/>
</AppsFormHeader>
/>
`;
3 changes: 0 additions & 3 deletions components/apps_form/apps_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import SpinnerButton from 'components/spinner_button';
import SuggestionList from 'components/suggestion/suggestion_list';
import ModalSuggestionList from 'components/suggestion/modal_suggestion_list';

import EmojiMap from 'utils/emoji_map';
import {localizeMessage} from 'utils/utils.jsx';

import AppsFormField from './apps_form_field';
Expand All @@ -36,7 +35,6 @@ export type AppsFormProps = {
performLookupCall: (field: AppField, values: AppFormValues, userInput: string) => Promise<AppSelectOption[]>;
refreshOnSelect: (field: AppField, values: AppFormValues) => Promise<{data: AppCallResponse<any>}>;
};
emojiMap: EmojiMap;
}

type Props = AppsFormProps & WrappedComponentProps<'intl'>;
Expand Down Expand Up @@ -353,7 +351,6 @@ export class AppsForm extends React.PureComponent<Props, State> {
<AppsFormHeader
id='appsModalHeader'
value={header}
emojiMap={this.props.emojiMap}
/>
)}
{this.renderElements()}
Expand Down
Loading

0 comments on commit 4202781

Please sign in to comment.