[MM-53294] Fix bad user feedback when plugins are disabled (#2772)

This commit is contained in:
Devin Binnie
2023-06-23 09:50:39 -04:00
committed by GitHub
parent 23b2fa6815
commit f51a7d31db
3 changed files with 14 additions and 8 deletions

View File

@@ -336,7 +336,7 @@ describe('app/serverViewState', () => {
beforeEach(() => {
MattermostServer.mockImplementation(({url}) => ({url}));
ServerInfo.mockImplementation(({url}) => ({
fetchRemoteInfo: jest.fn().mockImplementation(() => ({
fetchConfigData: jest.fn().mockImplementation(() => ({
serverVersion: '7.8.0',
siteName: 'Mattermost',
siteURL: url,
@@ -400,7 +400,7 @@ describe('app/serverViewState', () => {
it('should attempt HTTP when HTTPS fails, and generate a warning', async () => {
ServerInfo.mockImplementation(({url}) => ({
fetchRemoteInfo: jest.fn().mockImplementation(() => {
fetchConfigData: jest.fn().mockImplementation(() => {
if (url.startsWith('https:')) {
return undefined;
}
@@ -420,7 +420,7 @@ describe('app/serverViewState', () => {
it('should show a warning when the ping request times out', async () => {
ServerInfo.mockImplementation(() => ({
fetchRemoteInfo: jest.fn().mockImplementation(() => {
fetchConfigData: jest.fn().mockImplementation(() => {
throw new Error();
}),
}));
@@ -432,7 +432,7 @@ describe('app/serverViewState', () => {
it('should update the users URL when the Site URL is different', async () => {
ServerInfo.mockImplementation(() => ({
fetchRemoteInfo: jest.fn().mockImplementation(() => {
fetchConfigData: jest.fn().mockImplementation(() => {
return {
serverVersion: '7.8.0',
siteName: 'Mattermost',
@@ -448,7 +448,7 @@ describe('app/serverViewState', () => {
it('should warn the user when the Site URL is different but unreachable', async () => {
ServerInfo.mockImplementation(({url}) => ({
fetchRemoteInfo: jest.fn().mockImplementation(() => {
fetchConfigData: jest.fn().mockImplementation(() => {
if (url === 'https://mainserver.com/') {
return undefined;
}
@@ -468,7 +468,7 @@ describe('app/serverViewState', () => {
it('should warn the user when the Site URL already exists as another server', async () => {
ServerManager.lookupViewByURL.mockReturnValue({server: {name: 'Server 1', id: 'server-1', url: new URL('https://mainserver.com')}});
ServerInfo.mockImplementation(() => ({
fetchRemoteInfo: jest.fn().mockImplementation(() => {
fetchConfigData: jest.fn().mockImplementation(() => {
return {
serverVersion: '7.8.0',
siteName: 'Mattermost',

View File

@@ -343,7 +343,7 @@ export class ServerViewState {
const server = new MattermostServer({name: 'temp', url: parsedURL.toString()}, false);
const serverInfo = new ServerInfo(server);
try {
const remoteInfo = await serverInfo.fetchRemoteInfo();
const remoteInfo = await serverInfo.fetchConfigData();
return remoteInfo;
} catch (error) {
return undefined;

View File

@@ -16,11 +16,17 @@ export class ServerInfo {
this.remoteInfo = {};
}
fetchRemoteInfo = async () => {
fetchConfigData = async () => {
await this.getRemoteInfo<ClientConfig>(
new URL(`${this.server.url.toString()}/api/v4/config/client?format=old`),
this.onGetConfig,
);
return this.remoteInfo;
}
fetchRemoteInfo = async () => {
await this.fetchConfigData();
await this.getRemoteInfo<Array<{id: string; version: string}>>(
new URL(`${this.server.url.toString()}/api/v4/plugins/webapp`),
this.onGetPlugins,