[MM-50042] Detect Boards using the BuildBoards flag in the client config (#2535)

This commit is contained in:
Devin Binnie
2023-02-02 11:31:11 -05:00
committed by GitHub
parent db5a2e055d
commit 61a0b41d47
4 changed files with 10 additions and 2 deletions

View File

@@ -23,6 +23,9 @@ jest.mock('electron', () => ({
if (event === 'data') { if (event === 'data') {
responseCallback(url === badDataURL ? '98&H09986t&(*6BV789RhN^t97rb6Ev^*e5v89 re5bg^&' : JSON.stringify(testData)); responseCallback(url === badDataURL ? '98&H09986t&(*6BV789RhN^t97rb6Ev^*e5v89 re5bg^&' : JSON.stringify(testData));
} }
if (event === 'end') {
responseCallback();
}
}), }),
statusCode: (url === validURL || url === badDataURL) ? 200 : 404, statusCode: (url === validURL || url === badDataURL) ? 200 : 404,
}); });

View File

@@ -38,9 +38,12 @@ export async function getServerAPI<T>(url: URL, isAuthenticated: boolean, onSucc
req.on('response', (response: Electron.IncomingMessage) => { req.on('response', (response: Electron.IncomingMessage) => {
log.silly('getServerAPI.response', response); log.silly('getServerAPI.response', response);
if (response.statusCode === 200) { if (response.statusCode === 200) {
let raw = '';
response.on('data', (chunk: Buffer) => { response.on('data', (chunk: Buffer) => {
log.silly('getServerAPI.response.data', `${chunk}`); log.silly('getServerAPI.response.data', `${chunk}`);
const raw = `${chunk}`; raw += `${chunk}`;
});
response.on('end', () => {
try { try {
const data = JSON.parse(raw) as T; const data = JSON.parse(raw) as T;
onSuccess(data); onSuccess(data);

View File

@@ -44,12 +44,13 @@ export class ServerInfo {
onGetConfig = (data: ClientConfig) => { onGetConfig = (data: ClientConfig) => {
this.remoteInfo.serverVersion = data.Version; this.remoteInfo.serverVersion = data.Version;
this.remoteInfo.siteURL = data.SiteURL; this.remoteInfo.siteURL = data.SiteURL;
this.remoteInfo.hasFocalboard = this.remoteInfo.hasFocalboard || data.BuildBoards === 'true';
this.trySendRemoteInfo(); this.trySendRemoteInfo();
} }
onGetPlugins = (data: Array<{id: string; version: string}>) => { onGetPlugins = (data: Array<{id: string; version: string}>) => {
this.remoteInfo.hasFocalboard = data.some((plugin) => plugin.id === 'focalboard'); this.remoteInfo.hasFocalboard = this.remoteInfo.hasFocalboard || data.some((plugin) => plugin.id === 'focalboard');
this.remoteInfo.hasPlaybooks = data.some((plugin) => plugin.id === 'playbooks'); this.remoteInfo.hasPlaybooks = data.some((plugin) => plugin.id === 'playbooks');
this.trySendRemoteInfo(); this.trySendRemoteInfo();

View File

@@ -12,4 +12,5 @@ export type RemoteInfo = {
export type ClientConfig = { export type ClientConfig = {
Version: string; Version: string;
SiteURL: string; SiteURL: string;
BuildBoards: string;
} }