Files
mattermostest/src/common/tabs/TabView.ts
Devin Binnie 686b4ac9f1 [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
2023-04-12 12:52:34 -04:00

66 lines
1.5 KiB
TypeScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {MattermostTab, Team} from 'types/config';
import {MattermostServer} from 'common/servers/MattermostServer';
export const TAB_MESSAGING = 'TAB_MESSAGING';
export const TAB_FOCALBOARD = 'TAB_FOCALBOARD';
export const TAB_PLAYBOOKS = 'TAB_PLAYBOOKS';
export type TabType = typeof TAB_MESSAGING | typeof TAB_FOCALBOARD | typeof TAB_PLAYBOOKS;
export interface TabView {
id: string;
server: MattermostServer;
isOpen?: boolean;
get type(): TabType;
get url(): URL;
get shouldNotify(): boolean;
toMattermostTab(): MattermostTab;
}
export function getDefaultConfigTeamFromTeam(team: Team & {order: number; lastActiveTab?: number}) {
return {
...team,
tabs: getDefaultTabs(),
};
}
export function getDefaultTabs() {
return [
{
name: TAB_MESSAGING,
order: 0,
isOpen: true,
},
{
name: TAB_FOCALBOARD,
order: 1,
},
{
name: TAB_PLAYBOOKS,
order: 2,
},
];
}
export function getTabDisplayName(tabType: TabType) {
switch (tabType) {
case TAB_MESSAGING:
return 'Channels';
case TAB_FOCALBOARD:
return 'Boards';
case TAB_PLAYBOOKS:
return 'Playbooks';
default:
throw new Error('Not implemeneted');
}
}
export function canCloseTab(tabType: TabType) {
return tabType !== TAB_MESSAGING;
}