
* Rename MattermostTeam -> UniqueServer, MattermostTab -> UniqueView * Rename 'team' to 'server' * Some further cleanup * Rename weirdly named function * Rename 'tab' to 'view' in most instances * Fix i18n * PR feedback
41 lines
949 B
TypeScript
41 lines
949 B
TypeScript
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {v4 as uuid} from 'uuid';
|
|
|
|
import {UniqueServer, Server} from 'types/config';
|
|
|
|
import {parseURL} from 'common/utils/url';
|
|
|
|
export class MattermostServer {
|
|
id: string;
|
|
name: string;
|
|
url!: URL;
|
|
isPredefined: boolean;
|
|
|
|
constructor(server: Server, isPredefined: boolean) {
|
|
this.id = uuid();
|
|
|
|
this.name = server.name;
|
|
this.updateURL(server.url);
|
|
|
|
this.isPredefined = isPredefined;
|
|
}
|
|
|
|
updateURL = (url: string) => {
|
|
this.url = parseURL(url)!;
|
|
if (!this.url) {
|
|
throw new Error('Invalid url for creating a server');
|
|
}
|
|
}
|
|
|
|
toUniqueServer = (): UniqueServer => {
|
|
return {
|
|
name: this.name,
|
|
url: this.url.toString(),
|
|
id: this.id,
|
|
isPredefined: this.isPredefined,
|
|
};
|
|
}
|
|
}
|