MM-49393 Begin splitting up utils.tsx (#22983)

* Add selectors/urls to Channels

* Create utils/notification_sounds in Channels

* Move Utils.isLinux to UserAgent.isLinux

* Remove Utils.isMac in favour of UserAgent.isMac

* Move cmdOrCtrlPressed and isKeyPressed into new utils/keyboard

* Remove eslint-disable for max-lines in utils.tsx
Этот коммит содержится в:
Harrison Healey
2023-04-17 15:10:15 -04:00
коммит произвёл GitHub
родитель 941ee8509a
Коммит 3f022e728f
76 изменённых файлов: 508 добавлений и 491 удалений

53
webapp/channels/src/selectors/urls.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,53 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Post} from '@mattermost/types/posts';
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {getRedirectChannelNameForTeam} from 'mattermost-redux/selectors/entities/channels';
import {
getCurrentRelativeTeamUrl,
getCurrentTeam,
getCurrentTeamId,
getTeam,
} from 'mattermost-redux/selectors/entities/teams';
import {GlobalState} from 'types/store';
import Constants from 'utils/constants';
function getTeamRelativeUrl(team: Team | undefined) {
if (!team) {
return '';
}
return '/' + team.name;
}
export function getPermalinkURL(state: GlobalState, teamId: Team['id'], postId: Post['id']): string {
let team = getTeam(state, teamId);
if (!team) {
team = getCurrentTeam(state);
}
return `${getTeamRelativeUrl(team)}/pl/${postId}`;
}
export function getChannelURL(state: GlobalState, channel: Channel, teamId: string): string {
let notificationURL;
if (channel && (channel.type === Constants.DM_CHANNEL || channel.type === Constants.GM_CHANNEL)) {
notificationURL = getCurrentRelativeTeamUrl(state) + '/channels/' + channel.name;
} else if (channel) {
const team = getTeam(state, teamId);
notificationURL = getTeamRelativeUrl(team) + '/channels/' + channel.name;
} else if (teamId) {
const team = getTeam(state, teamId);
const redirectChannel = getRedirectChannelNameForTeam(state, teamId);
notificationURL = getTeamRelativeUrl(team) + `/channels/${redirectChannel}`;
} else {
const currentTeamId = getCurrentTeamId(state);
const redirectChannel = getRedirectChannelNameForTeam(state, currentTeamId);
notificationURL = getCurrentRelativeTeamUrl(state) + `/channels/${redirectChannel}`;
}
return notificationURL;
}