MM-58066-Use Client Config to determine AppsEnabled (#27872)

* remove enabling apps plugin by default

* use client config to determine creating app bindings.

* update the way dispatch is made

* updated type setting

* fixed unit test

* prevent a nil check

* dispatch batch

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Scott Bishel 2024-08-26 16:03:17 -06:00 committed by GitHub
parent 081aa8f6dc
commit e64cdfb34b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 4 deletions

View file

@ -302,6 +302,7 @@ func GenerateLimitedClientConfig(c *model.Config, telemetryID string, license *m
props["HasImageProxy"] = strconv.FormatBool(*c.ImageProxySettings.Enable)
props["PluginsEnabled"] = strconv.FormatBool(*c.PluginSettings.Enable)
props["AppsPluginEnabled"] = strconv.FormatBool(*c.PluginSettings.Enable && c.PluginSettings.PluginStates[model.PluginIdApps] != nil && c.PluginSettings.PluginStates[model.PluginIdApps].Enable)
props["PasswordMinimumLength"] = strconv.Itoa(*c.PasswordSettings.MinimumLength)
props["PasswordRequireLowercase"] = strconv.FormatBool(*c.PasswordSettings.Lowercase)

View file

@ -66,7 +66,7 @@ import {
import {removeNotVisibleUsers} from 'mattermost-redux/actions/websocket';
import {Client4} from 'mattermost-redux/client';
import {General, Permissions} from 'mattermost-redux/constants';
import {appsFeatureFlagEnabled} from 'mattermost-redux/selectors/entities/apps';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
import {
getChannel,
getChannelMembersInChannels,
@ -230,7 +230,7 @@ export function reconnect() {
const mostRecentId = getMostRecentPostIdInChannel(state, currentChannelId);
const mostRecentPost = getPost(state, mostRecentId);
if (appsFeatureFlagEnabled(state)) {
if (appsEnabled(state)) {
dispatch(handleRefreshAppsBindings());
}

View file

@ -86,6 +86,9 @@ jest.mock('plugins', () => ({
let mockState = {
entities: {
apps: {
enablePlugin: false,
},
users: {
currentUserId: 'currentUserId',
profiles: {

View file

@ -1,11 +1,13 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {batchActions} from 'redux-batched-actions';
import {LogLevel} from '@mattermost/types/client4';
import type {ClientConfig} from '@mattermost/types/config';
import type {SystemSetting} from '@mattermost/types/general';
import {GeneralTypes} from 'mattermost-redux/action_types';
import {AppsTypes, GeneralTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import type {ActionFuncAsync} from 'mattermost-redux/types/actions';
@ -26,7 +28,9 @@ export function getClientConfig(): ActionFuncAsync<ClientConfig> {
Client4.setEnableLogging(data.EnableDeveloper === 'true');
Client4.setDiagnosticId(data.DiagnosticId);
dispatch({type: GeneralTypes.CLIENT_CONFIG_RECEIVED, data});
const type = data.AppsPluginEnabled === 'true' ? AppsTypes.APPS_PLUGIN_ENABLED : AppsTypes.APPS_PLUGIN_DISABLED;
const actions = [{type: GeneralTypes.CLIENT_CONFIG_RECEIVED, data}, {type}];
dispatch(batchActions(actions));
return {data};
};

View file

@ -11,6 +11,7 @@ export type ClientConfig = {
AndroidLatestVersion: string;
AndroidMinVersion: string;
AppDownloadLink: string;
AppsPluginEnabled: string;
AsymmetricSigningPublicKey: string;
AvailableLocales: string;
BannerColor: string;