[MM-50485] Migrate app to ServerManager, remove view names and replace with IDs (#2672)

* Migrate app to ServerManager, remove view names and replace with IDs

* Fixed a test

* Fixed a bug when adding the initial server

* Merge'd

* Bug fixes and PR feedback
This commit is contained in:
Devin Binnie
2023-04-12 12:52:34 -04:00
committed by GitHub
parent d87097b1eb
commit 686b4ac9f1
58 changed files with 1570 additions and 2175 deletions

View File

@@ -3,7 +3,7 @@
import {v4 as uuid} from 'uuid';
import {Team} from 'types/config';
import {MattermostTeam, Team} from 'types/config';
import urlUtils from 'common/utils/url';
@@ -13,14 +13,13 @@ export class MattermostServer {
url!: URL;
isPredefined: boolean;
constructor(server: Team, isPredefined = false) {
constructor(server: Team, isPredefined: boolean) {
this.id = uuid();
this.name = server.name;
this.updateURL(server.url);
this.isPredefined = isPredefined;
if (!this.url) {
throw new Error('Invalid url for creating a server');
}
}
updateURL = (url: string) => {
@@ -29,4 +28,13 @@ export class MattermostServer {
throw new Error('Invalid url for creating a server');
}
}
toMattermostTeam = (): MattermostTeam => {
return {
name: this.name,
url: this.url.toString(),
id: this.id,
isPredefined: this.isPredefined,
};
}
}