[MM-50485] Implement ServerManager, introduce id concept for identifying servers/views (#2654)
* Implement ServerManager, introduce id concept for identifying servers/views * REVERT ME (eventually): Move back to old logging * PR feedback * PR feedback * Revert "REVERT ME (eventually): Move back to old logging" This reverts commit 46954a5bbed4dd29e89ca9d5217bb75af2837bb3. * Merge'd * Use the correct method for Logger in ServerManager
This commit is contained in:
@@ -1,14 +1,30 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {v4 as uuid} from 'uuid';
|
||||
|
||||
import {Team} from 'types/config';
|
||||
|
||||
import urlUtils from 'common/utils/url';
|
||||
|
||||
export class MattermostServer {
|
||||
id: string;
|
||||
name: string;
|
||||
url: URL;
|
||||
constructor(name: string, serverUrl: string) {
|
||||
this.name = name;
|
||||
this.url = urlUtils.parseURL(serverUrl)!;
|
||||
url!: URL;
|
||||
isPredefined: boolean;
|
||||
|
||||
constructor(server: Team, isPredefined = false) {
|
||||
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) => {
|
||||
this.url = urlUtils.parseURL(url)!;
|
||||
if (!this.url) {
|
||||
throw new Error('Invalid url for creating a server');
|
||||
}
|
||||
|
Reference in New Issue
Block a user