[MM-23082] Fixes whitescreen issue on app upgrade / GPO / whitelabeled app deployments (#1246)
* Fixes whitescreen issue on app upgrade / GPO push / whitelabeled app deployments. If sort order was not present in buildConfig.js (or previous configuration), we will assume reasonable defaults * Fixing eslint bugs - with my apologies * Removing order flag from sample configuration, but leaving it in the documentation. BUGFIX: Accidentally left my custom enableServerManagement flag in place. Reverted to default * Making a more educated guess as to the user's desired sort order. * Update src/common/config/index.js Use forEach's index instead of an external one. Co-Authored-By: Guillermo Vayá <guivaya@gmail.com> * Update src/common/config/index.js Let me test this, I'm not sure I understand how this logic works. :) Co-Authored-By: Guillermo Vayá <guivaya@gmail.com> * Removed optional field * Fixed broken lint:js with my apologies Co-authored-by: Guillermo Vayá <guivaya@gmail.com>
This commit is contained in:
parent
b573e773d8
commit
93f7ae9b47
|
@ -9,6 +9,7 @@
|
|||
* @prop {Object[]} defaultTeams
|
||||
* @prop {string} defaultTeams[].name - The tab name for default team.
|
||||
* @prop {string} defaultTeams[].url - The URL for default team.
|
||||
* @prop {string} defaultTeams[].order - Sort order for team tabs (0, 1, 2)
|
||||
* @prop {string} helpLink - The URL for "Help->Learn More..." menu item.
|
||||
* If null is specified, the menu disappears.
|
||||
* @prop {boolean} enableServerManagement - Whether users can edit servers configuration.
|
||||
|
@ -20,8 +21,8 @@ const buildConfig = {
|
|||
{
|
||||
name: 'example',
|
||||
url: 'https://example.com'
|
||||
}*/
|
||||
],
|
||||
}
|
||||
*/],
|
||||
helpLink: 'https://about.mattermost.com/default-desktop-app-documentation/',
|
||||
enableServerManagement: true,
|
||||
enableAutoUpdater: true,
|
||||
|
|
|
@ -272,7 +272,7 @@ export default class Config extends EventEmitter {
|
|||
delete this.combinedData.defaultTeams;
|
||||
|
||||
// IMPORTANT: properly combine teams from all sources
|
||||
const combinedTeams = [];
|
||||
let combinedTeams = [];
|
||||
|
||||
// - start by adding default teams from buildConfig, if any
|
||||
if (this.buildConfigData.defaultTeams && this.buildConfigData.defaultTeams.length) {
|
||||
|
@ -289,6 +289,9 @@ export default class Config extends EventEmitter {
|
|||
combinedTeams.push(...this.localConfigData.teams);
|
||||
}
|
||||
|
||||
combinedTeams = this.filterOutDuplicateTeams(combinedTeams);
|
||||
combinedTeams = this.sortUnorderedTeams(combinedTeams);
|
||||
|
||||
this.combinedData.teams = combinedTeams;
|
||||
this.combinedData.localTeams = this.localConfigData.teams;
|
||||
this.combinedData.buildTeams = this.buildConfigData.defaultTeams;
|
||||
|
@ -324,6 +327,35 @@ export default class Config extends EventEmitter {
|
|||
return newTeams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a default sort order to the team list, if no order is specified.
|
||||
* @param {array} teams to sort
|
||||
*/
|
||||
sortUnorderedTeams(teams) {
|
||||
// Make a best pass at interpreting sort order. If an order is not specified, assume it is 0.
|
||||
//
|
||||
const newTeams = teams.sort((x, y) => {
|
||||
if (x.order == null) {
|
||||
x.order = 0;
|
||||
}
|
||||
if (y.order == null) {
|
||||
y.order = 0;
|
||||
}
|
||||
|
||||
// once we ensured `order` exists, we can sort numerically
|
||||
return x.order - y.order;
|
||||
});
|
||||
|
||||
// Now re-number all items from 0 to (max), ensuring user's sort order is preserved. The
|
||||
// new tabbed interface requires an item with order:0 in order to raise the first tab.
|
||||
//
|
||||
newTeams.forEach((team, i) => {
|
||||
team.order = i;
|
||||
});
|
||||
|
||||
return newTeams;
|
||||
}
|
||||
|
||||
// helper functions
|
||||
|
||||
readFileSync(filePath) {
|
||||
|
|
Loading…
Reference in a new issue