[MM-53294] Fix bad user feedback when plugins are disabled (#2772)
This commit is contained in:
@@ -336,7 +336,7 @@ describe('app/serverViewState', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
MattermostServer.mockImplementation(({url}) => ({url}));
|
MattermostServer.mockImplementation(({url}) => ({url}));
|
||||||
ServerInfo.mockImplementation(({url}) => ({
|
ServerInfo.mockImplementation(({url}) => ({
|
||||||
fetchRemoteInfo: jest.fn().mockImplementation(() => ({
|
fetchConfigData: jest.fn().mockImplementation(() => ({
|
||||||
serverVersion: '7.8.0',
|
serverVersion: '7.8.0',
|
||||||
siteName: 'Mattermost',
|
siteName: 'Mattermost',
|
||||||
siteURL: url,
|
siteURL: url,
|
||||||
@@ -400,7 +400,7 @@ describe('app/serverViewState', () => {
|
|||||||
|
|
||||||
it('should attempt HTTP when HTTPS fails, and generate a warning', async () => {
|
it('should attempt HTTP when HTTPS fails, and generate a warning', async () => {
|
||||||
ServerInfo.mockImplementation(({url}) => ({
|
ServerInfo.mockImplementation(({url}) => ({
|
||||||
fetchRemoteInfo: jest.fn().mockImplementation(() => {
|
fetchConfigData: jest.fn().mockImplementation(() => {
|
||||||
if (url.startsWith('https:')) {
|
if (url.startsWith('https:')) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -420,7 +420,7 @@ describe('app/serverViewState', () => {
|
|||||||
|
|
||||||
it('should show a warning when the ping request times out', async () => {
|
it('should show a warning when the ping request times out', async () => {
|
||||||
ServerInfo.mockImplementation(() => ({
|
ServerInfo.mockImplementation(() => ({
|
||||||
fetchRemoteInfo: jest.fn().mockImplementation(() => {
|
fetchConfigData: jest.fn().mockImplementation(() => {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
@@ -432,7 +432,7 @@ describe('app/serverViewState', () => {
|
|||||||
|
|
||||||
it('should update the users URL when the Site URL is different', async () => {
|
it('should update the users URL when the Site URL is different', async () => {
|
||||||
ServerInfo.mockImplementation(() => ({
|
ServerInfo.mockImplementation(() => ({
|
||||||
fetchRemoteInfo: jest.fn().mockImplementation(() => {
|
fetchConfigData: jest.fn().mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
serverVersion: '7.8.0',
|
serverVersion: '7.8.0',
|
||||||
siteName: 'Mattermost',
|
siteName: 'Mattermost',
|
||||||
@@ -448,7 +448,7 @@ describe('app/serverViewState', () => {
|
|||||||
|
|
||||||
it('should warn the user when the Site URL is different but unreachable', async () => {
|
it('should warn the user when the Site URL is different but unreachable', async () => {
|
||||||
ServerInfo.mockImplementation(({url}) => ({
|
ServerInfo.mockImplementation(({url}) => ({
|
||||||
fetchRemoteInfo: jest.fn().mockImplementation(() => {
|
fetchConfigData: jest.fn().mockImplementation(() => {
|
||||||
if (url === 'https://mainserver.com/') {
|
if (url === 'https://mainserver.com/') {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -468,7 +468,7 @@ describe('app/serverViewState', () => {
|
|||||||
it('should warn the user when the Site URL already exists as another server', async () => {
|
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')}});
|
ServerManager.lookupViewByURL.mockReturnValue({server: {name: 'Server 1', id: 'server-1', url: new URL('https://mainserver.com')}});
|
||||||
ServerInfo.mockImplementation(() => ({
|
ServerInfo.mockImplementation(() => ({
|
||||||
fetchRemoteInfo: jest.fn().mockImplementation(() => {
|
fetchConfigData: jest.fn().mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
serverVersion: '7.8.0',
|
serverVersion: '7.8.0',
|
||||||
siteName: 'Mattermost',
|
siteName: 'Mattermost',
|
||||||
|
@@ -343,7 +343,7 @@ export class ServerViewState {
|
|||||||
const server = new MattermostServer({name: 'temp', url: parsedURL.toString()}, false);
|
const server = new MattermostServer({name: 'temp', url: parsedURL.toString()}, false);
|
||||||
const serverInfo = new ServerInfo(server);
|
const serverInfo = new ServerInfo(server);
|
||||||
try {
|
try {
|
||||||
const remoteInfo = await serverInfo.fetchRemoteInfo();
|
const remoteInfo = await serverInfo.fetchConfigData();
|
||||||
return remoteInfo;
|
return remoteInfo;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@@ -16,11 +16,17 @@ export class ServerInfo {
|
|||||||
this.remoteInfo = {};
|
this.remoteInfo = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchRemoteInfo = async () => {
|
fetchConfigData = async () => {
|
||||||
await this.getRemoteInfo<ClientConfig>(
|
await this.getRemoteInfo<ClientConfig>(
|
||||||
new URL(`${this.server.url.toString()}/api/v4/config/client?format=old`),
|
new URL(`${this.server.url.toString()}/api/v4/config/client?format=old`),
|
||||||
this.onGetConfig,
|
this.onGetConfig,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this.remoteInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchRemoteInfo = async () => {
|
||||||
|
await this.fetchConfigData();
|
||||||
await this.getRemoteInfo<Array<{id: string; version: string}>>(
|
await this.getRemoteInfo<Array<{id: string; version: string}>>(
|
||||||
new URL(`${this.server.url.toString()}/api/v4/plugins/webapp`),
|
new URL(`${this.server.url.toString()}/api/v4/plugins/webapp`),
|
||||||
this.onGetPlugins,
|
this.onGetPlugins,
|
||||||
|
Reference in New Issue
Block a user