MM-56625: Use patchConfig to update configs from system console (#26332)

While updating config from admin console, the webapp would set
any config param to null if the user doesn't have permission to edit
that setting.

This is common in cloud environments where a lot of config settings
are set to `cloud_restrictable`.

The problem due to that is since the client uses the updateConfig
endpoint, this acts as a full config replace and therefore, the null
fields get replaced by their default values.

To fix this, we use the patch endpoint which only updates the fields
that are actually set.

https://mattermost.atlassian.net/browse/MM-56625

```release-note
Fix a bug where config cannot be updated from admin console
in cloud environments.
```


Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Agniva De Sarker
2024-03-08 21:21:23 +05:30
коммит произвёл GitHub
родитель 1eec4ad30f
Коммит f34445a6f4
22 изменённых файлов: 67 добавлений и 52 удалений

Просмотреть файл

@@ -8,6 +8,7 @@ import type {RouteComponentProps} from 'react-router-dom';
import type {CloudState} from '@mattermost/types/cloud';
import type {AdminConfig, ClientLicense, EnvironmentConfig} from '@mattermost/types/config';
import type {Role} from '@mattermost/types/roles';
import type {DeepPartial} from '@mattermost/types/utilities';
import type {ActionResult} from 'mattermost-redux/types/actions';
@@ -43,7 +44,7 @@ type ExtraProps = {
setNavigationBlocked: (blocked: boolean) => void;
roles: Record<string, Role>;
editRole: (role: Role) => void;
updateConfig: (config: AdminConfig) => Promise<ActionResult>;
patchConfig: (config: DeepPartial<AdminConfig>) => Promise<ActionResult>;
cloud: CloudState;
isCurrentUserSystemAdmin: boolean;
}
@@ -173,7 +174,7 @@ class AdminConsole extends React.PureComponent<Props, State> {
showNavigationPrompt,
roles,
} = this.props;
const {setNavigationBlocked, cancelNavigation, confirmNavigation, editRole, updateConfig} = this.props.actions;
const {setNavigationBlocked, cancelNavigation, confirmNavigation, editRole, patchConfig} = this.props.actions;
if (!this.props.currentUserHasAnAdminRole) {
return (
@@ -203,7 +204,7 @@ class AdminConsole extends React.PureComponent<Props, State> {
setNavigationBlocked,
roles,
editRole,
updateConfig,
patchConfig,
cloud: this.props.cloud,
isCurrentUserSystemAdmin: this.props.isCurrentUserSystemAdmin,
};