Add platform/mattermost-redux package for publishing (#30020)
* Replace key-mirror with mattermost-redux/utils/key_mirror At some point, we made our own version for mattermost-redux with proper type definitions but we seem to have forgotten to use that everywhere in the web app. * Remove Rudder reference from mattermost-redux * Remove Giphy API from mattermost-redux * Remove mattermost-webapp refernces from Client and Types packages * Create platform/mattermost-redux without moving its source files * Don't build mattermost-redux automatically * Copy changes to package.json from platform/mattermost-redux to other packages The changes to the typesVersions and exports fields are to make it easier for tooling to know to make it so that importing a folder imports the index file inside that folder since that's not standard to all CommonJS packages. The added type field is just a good pracice. * Explicitly type re-exported selectors For some reason, the types generated by the previous version of this didn't work when mattermost-redux was built as a standalone package. Explicitly typing these is a bit more verbose, but it fixes things. * Fix import loop in selectors introduced by last commit * Update package versions to 10.6.0 * Add explicit dependencies to mattermost-redux package * Remove check and run scripts from mattermost-redux package * Revert changes to NOTICE.txt
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f52e08754c
Коммит
86aad9d0a5
@@ -3,7 +3,7 @@
|
||||
"browser": {
|
||||
"./client/web_client.jsx": "./client/browser_web_client.jsx"
|
||||
},
|
||||
"version": "9.3.0",
|
||||
"version": "10.6.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/react": "0.26.28",
|
||||
@@ -46,7 +46,6 @@
|
||||
"inobounce": "0.2.1",
|
||||
"ipaddr.js": "2.1.0",
|
||||
"katex": "0.16.10",
|
||||
"key-mirror": "1.0.1",
|
||||
"localforage": "1.10.0",
|
||||
"localforage-observable": "2.1.1",
|
||||
"lodash": "4.17.21",
|
||||
|
||||
@@ -7,11 +7,11 @@ import {Grid} from '@giphy/react-components';
|
||||
import React, {memo, useCallback} from 'react';
|
||||
import {useSelector} from 'react-redux';
|
||||
|
||||
import {getGiphyFetchInstance} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import NoResultsIndicator from 'components/no_results_indicator';
|
||||
import {NoResultsVariant} from 'components/no_results_indicator/types';
|
||||
|
||||
import {getGiphyFetchInstance} from '../selectors';
|
||||
|
||||
const GUTTER_BETWEEN_GIFS = 8;
|
||||
const NUM_OF_GIFS_COLUMNS = 2;
|
||||
|
||||
|
||||
22
webapp/channels/src/components/gif_picker/selectors.ts
Обычный файл
22
webapp/channels/src/components/gif_picker/selectors.ts
Обычный файл
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {GiphyFetch} from '@giphy/js-fetch-api';
|
||||
|
||||
import {createSelector} from 'mattermost-redux/selectors/create_selector';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
export const getGiphyFetchInstance: (state: GlobalState) => GiphyFetch | null = createSelector(
|
||||
'getGiphyFetchInstance',
|
||||
(state) => getConfig(state).GiphySdkKey,
|
||||
(giphySdkKey) => {
|
||||
if (giphySdkKey) {
|
||||
const giphyFetch = new GiphyFetch(giphySdkKey);
|
||||
return giphyFetch;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
);
|
||||
@@ -21,7 +21,7 @@ import {handleLoginLogoutSignal, redirectToOnboardingOrDefaultTeam} from './acti
|
||||
import type {Props} from './root';
|
||||
import Root, {doesRouteBelongToTeamControllerRoutes} from './root';
|
||||
|
||||
jest.mock('mattermost-redux/client/rudder', () => ({
|
||||
jest.mock('utils/rudder', () => ({
|
||||
rudderAnalytics: {
|
||||
identify: jest.fn(),
|
||||
load: jest.fn(),
|
||||
|
||||
@@ -12,7 +12,6 @@ import {ServiceEnvironment} from '@mattermost/types/config';
|
||||
import {setSystemEmojis} from 'mattermost-redux/actions/emojis';
|
||||
import {setUrl} from 'mattermost-redux/actions/general';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import {rudderAnalytics, RudderTelemetryHandler} from 'mattermost-redux/client/rudder';
|
||||
import {Preferences} from 'mattermost-redux/constants';
|
||||
|
||||
import {measurePageLoadTelemetry, temporarilySetPageLoadContext, trackEvent, trackSelectorMetrics} from 'actions/telemetry_actions.jsx';
|
||||
@@ -36,6 +35,7 @@ import {PageLoadContext, SCHEDULED_POST_URL_SUFFIX} from 'utils/constants';
|
||||
import DesktopApp from 'utils/desktop_api';
|
||||
import {EmojiIndicesByAlias} from 'utils/emoji';
|
||||
import {TEAM_NAME_PATH_PATTERN} from 'utils/path';
|
||||
import {rudderAnalytics, RudderTelemetryHandler} from 'utils/rudder';
|
||||
import {getSiteURL} from 'utils/url';
|
||||
import {isAndroidWeb, isChromebook, isDesktopApp, isIosWeb} from 'utils/user_agent';
|
||||
import {applyTheme, isTextDroppableEvent} from 'utils/utils';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import keyMirror from 'key-mirror';
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
export default keyMirror({
|
||||
SCHEDULED_POSTS_RECEIVED: null,
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
export as namespace Reselect;
|
||||
|
||||
export type Selector<S, R> = (state: S) => R;
|
||||
|
||||
export type OutputSelector<S, R, C> = Selector<S, R> & {
|
||||
|
||||
@@ -27,10 +27,10 @@ import {createSelector} from 'mattermost-redux/selectors/create_selector';
|
||||
import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
|
||||
import {getCategoryInTeamByType} from 'mattermost-redux/selectors/entities/channel_categories';
|
||||
import {
|
||||
getCurrentChannelId,
|
||||
getCurrentChannelId as getCurrentChannelIdInternal,
|
||||
getCurrentUser,
|
||||
getMyChannelMemberships,
|
||||
getMyCurrentChannelMembership,
|
||||
getMyChannelMemberships as getMyChannelMembershipsInternal,
|
||||
getMyCurrentChannelMembership as getMyCurrentChannelMembershipInternal,
|
||||
getUsers,
|
||||
} from 'mattermost-redux/selectors/entities/common';
|
||||
import {
|
||||
@@ -69,7 +69,11 @@ import {createIdsSelector} from 'mattermost-redux/utils/helpers';
|
||||
import {isPostPriorityEnabled} from './posts';
|
||||
import {getThreadCounts, getThreadCountsIncludingDirect} from './threads';
|
||||
|
||||
export {getCurrentChannelId, getMyChannelMemberships, getMyCurrentChannelMembership};
|
||||
// Re-define these types to ensure that these are typed correctly when mattermost-redux is published
|
||||
export const getCurrentChannelId: (state: GlobalState) => string = getCurrentChannelIdInternal;
|
||||
export const getMyChannelMemberships: (state: GlobalState) => RelationOneToOne<Channel, ChannelMembership> = getMyChannelMembershipsInternal;
|
||||
export const getMyCurrentChannelMembership: (state: GlobalState) => ChannelMembership | undefined = getMyCurrentChannelMembershipInternal;
|
||||
|
||||
export function getAllChannels(state: GlobalState): IDMappedObjects<Channel> {
|
||||
return state.entities.channels.channels;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {GiphyFetch} from '@giphy/js-fetch-api';
|
||||
|
||||
import type {ClientConfig, FeatureFlags, ClientLicense} from '@mattermost/types/config';
|
||||
import type {UserPropertyField} from '@mattermost/types/properties';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
@@ -134,19 +132,6 @@ export const isMarketplaceEnabled: (state: GlobalState) => boolean = createSelec
|
||||
},
|
||||
);
|
||||
|
||||
export const getGiphyFetchInstance: (state: GlobalState) => GiphyFetch | null = createSelector(
|
||||
'getGiphyFetchInstance',
|
||||
(state) => getConfig(state).GiphySdkKey,
|
||||
(giphySdkKey) => {
|
||||
if (giphySdkKey) {
|
||||
const giphyFetch = new GiphyFetch(giphySdkKey);
|
||||
return giphyFetch;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
||||
export const getUsersStatusAndProfileFetchingPollInterval: (state: GlobalState) => number | null = createSelector(
|
||||
'getUsersStatusAndProfileFetchingPollInterval',
|
||||
getConfig,
|
||||
|
||||
@@ -7,18 +7,22 @@ import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {General, Permissions} from 'mattermost-redux/constants';
|
||||
import {createSelector} from 'mattermost-redux/selectors/create_selector';
|
||||
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/common';
|
||||
import {getCurrentChannelId, getCurrentUserId} from 'mattermost-redux/selectors/entities/common';
|
||||
import type {PermissionsOptions} from 'mattermost-redux/selectors/entities/roles_helpers';
|
||||
import {
|
||||
getMySystemPermissions,
|
||||
getMySystemRoles,
|
||||
getMySystemPermissions as getMySystemPermissionsInternal,
|
||||
getMySystemRoles as getMySystemRolesInternal,
|
||||
getPermissionsForRoles,
|
||||
getRoles,
|
||||
haveISystemPermission,
|
||||
getRoles as getRolesInternal,
|
||||
haveISystemPermission as haveISystemPermissionInternal,
|
||||
} from 'mattermost-redux/selectors/entities/roles_helpers';
|
||||
import {getTeamMemberships, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
export {getMySystemPermissions, getMySystemRoles, getRoles, haveISystemPermission};
|
||||
// Re-define these types to ensure that these are typed correctly when mattermost-redux is published
|
||||
export const getMySystemPermissions: (state: GlobalState) => Set<string> = getMySystemPermissionsInternal;
|
||||
export const getMySystemRoles: (state: GlobalState) => Set<string> = getMySystemRolesInternal;
|
||||
export const getRoles: (state: GlobalState) => Record<string, Role> = getRolesInternal;
|
||||
export const haveISystemPermission: (state: GlobalState, options: PermissionsOptions) => boolean = haveISystemPermissionInternal;
|
||||
|
||||
export const getGroupMemberships: (state: GlobalState) => Record<string, GroupMembership> = createSelector(
|
||||
'getGroupMemberships',
|
||||
|
||||
@@ -17,10 +17,10 @@ import {General} from 'mattermost-redux/constants';
|
||||
import {createSelector} from 'mattermost-redux/selectors/create_selector';
|
||||
import {
|
||||
getCurrentChannelId,
|
||||
getCurrentUser,
|
||||
getCurrentUserId,
|
||||
getCurrentUser as getCurrentUserInternal,
|
||||
getCurrentUserId as getCurrentUserIdInternal,
|
||||
getMyCurrentChannelMembership,
|
||||
getUsers,
|
||||
getUsers as getUsersInternal,
|
||||
getMembersInTeam,
|
||||
getMembersInChannel,
|
||||
} from 'mattermost-redux/selectors/entities/common';
|
||||
@@ -39,7 +39,10 @@ import {
|
||||
applyRolesFilters,
|
||||
} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
export {getCurrentUser, getCurrentUserId, getUsers};
|
||||
// Re-define these types to ensure that these are typed correctly when mattermost-redux is published
|
||||
export const getCurrentUser: (state: GlobalState) => UserProfile = getCurrentUserInternal;
|
||||
export const getCurrentUserId: (state: GlobalState) => string = getCurrentUserIdInternal;
|
||||
export const getUsers: (state: GlobalState) => IDMappedObjects<UserProfile> = getUsersInternal;
|
||||
|
||||
export type Filters = {
|
||||
role?: string;
|
||||
|
||||
8
webapp/channels/src/types/external/key-mirror.d.ts
поставляемый
8
webapp/channels/src/types/external/key-mirror.d.ts
поставляемый
@@ -1,8 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
declare module 'key-mirror' {
|
||||
function keyMirror<T>(obj: T): { [K in keyof T]: K };
|
||||
export = keyMirror;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import solarizedDarkCSS from 'highlight.js/styles/base16/solarized-dark.css';
|
||||
import solarizedLightCSS from 'highlight.js/styles/base16/solarized-light.css';
|
||||
import githubCSS from 'highlight.js/styles/github.css';
|
||||
import monokaiCSS from 'highlight.js/styles/monokai.css';
|
||||
import keyMirror from 'key-mirror';
|
||||
import {defineMessage, defineMessages} from 'react-intl';
|
||||
|
||||
import {CustomStatusDuration} from '@mattermost/types/users';
|
||||
|
||||
import {Preferences as ReduxPreferences} from 'mattermost-redux/constants';
|
||||
import Permissions from 'mattermost-redux/constants/permissions';
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
import * as PostListUtils from 'mattermost-redux/utils/post_list';
|
||||
|
||||
import audioIcon from 'images/icons/audio.svg';
|
||||
|
||||
Ссылка в новой задаче
Block a user