Files
mattermostest/src/common/servers/MattermostServer.ts
Devin Binnie 316beba950 [MM-14093] Rename 'team' to 'server' and 'tab' to 'view' in most cases, some additional cleanup (#2711)
* 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
2023-05-08 09:17:01 -04:00

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,
};
}
}