MM-51735 Remove references to mattermost-redux from Boards (#22694)

* MM-51735 Remove references to mattermost-redux from Boards

* Fix styling and remove debug comments

* Update Playbooks Jest config to point to mattermost-redux correctly
Этот коммит содержится в:
Harrison Healey
2023-03-28 15:36:04 -04:00
коммит произвёл GitHub
родитель 1cbfef65f1
Коммит fb2dac307b
8 изменённых файлов: 100 добавлений и 624 удалений

Просмотреть файл

@@ -45,7 +45,6 @@
"glob-parent": "6.0.2",
"lodash": "^4.17.21",
"marked": "^4.0.12",
"mattermost-redux": "5.33.1",
"mini-create-react-context": "^0.4.1",
"moment": "^2.29.1",
"nanoevents": "^5.1.13",

Просмотреть файл

@@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react'
import {Post} from 'mattermost-redux/types/posts'
import {Post} from '@mattermost/types/posts'
const PostTypeCloudUpgradeNudge = (props: {post: Post}): JSX.Element => {
const ctaHandler = (e: React.MouseEvent) => {

Просмотреть файл

@@ -6,16 +6,14 @@ import {Store, Action} from 'redux'
import {Provider as ReduxProvider} from 'react-redux'
import {createBrowserHistory, History} from 'history'
import {rudderAnalytics, RudderTelemetryHandler} from 'mattermost-redux/client/rudder'
import {GlobalState} from 'mattermost-redux/types/store'
import {selectTeam} from 'mattermost-redux/actions/teams'
import {GlobalState} from '@mattermost/types/store'
import {SuiteWindow} from 'src/types/index'
import {PluginRegistry} from 'src/types/mattermost-webapp'
import {rudderAnalytics, RudderTelemetryHandler} from 'src/rudder'
import appBarIcon from 'static/app-bar-icon.png'
import {Constants} from 'src/constants'
@@ -294,9 +292,13 @@ export default class Plugin {
const currentUserId = mmStore.getState().entities.users.currentUserId
if (currentTeamID !== fbPrevTeamID) {
fbPrevTeamID = currentTeamID
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
mmStore.dispatch(selectTeam(currentTeamID))
mmStore.dispatch({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
type: 'SELECT_TEAM',
data: currentTeamID,
})
localStorage.setItem(`user_prev_team:${currentUserId}`, currentTeamID)
}
})

65
webapp/boards/src/rudder.ts Обычный файл
Просмотреть файл

@@ -0,0 +1,65 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// This file is duplicated from mattermost-redux in the web app with some slight modifications to make it standalone
// As per rudder-sdk-js documentation, import this only once and use like a singleton.
// See https://github.com/rudderlabs/rudder-sdk-js#step-1-install-rudderstack-using-the-code-snippet
import * as rudderAnalytics from 'rudder-sdk-js'
export {rudderAnalytics}
import {TelemetryHandler} from '@mattermost/client'
import {Utils} from 'src/utils'
export class RudderTelemetryHandler implements TelemetryHandler {
trackEvent(userId: string, userRoles: string, category: string, event: string, props?: any) {
const properties = Object.assign({
category,
type: event,
user_actual_role: getActualRoles(userRoles),
user_actual_id: userId,
}, props)
const options = {
context: {
ip: '0.0.0.0',
},
page: {
path: '',
referrer: '',
search: '',
title: '',
url: '',
},
anonymousId: '00000000000000000000000000',
}
rudderAnalytics.track('event', properties, options)
}
pageVisited(userId: string, userRoles: string, category: string, name: string) {
rudderAnalytics.page(
category,
name,
{
path: '',
referrer: '',
search: '',
title: '',
url: '',
user_actual_role: getActualRoles(userRoles),
user_actual_id: userId,
},
{
context: {
ip: '0.0.0.0',
},
anonymousId: '00000000000000000000000000',
},
)
}
}
function getActualRoles(userRoles: string) {
return userRoles && Utils.isSystemAdmin(userRoles) ? 'system_admin, system_user' : 'system_user'
}

Просмотреть файл

@@ -3,7 +3,7 @@
import type React from 'react'
import type {Channel, ChannelMembership} from 'mattermost-redux/types/channels'
import type {Channel, ChannelMembership} from '@mattermost/types/channels'
type ReactResolvable = React.ReactNode | React.ElementType

Просмотреть файл

@@ -53,8 +53,6 @@ const config = {
resolve: {
alias: {
src: path.resolve(__dirname, './src/'),
// 'mattermost-redux': path.resolve(__dirname, '../channels/src/packages/mattermost-redux/src/'),
// reselect: path.resolve(__dirname, '../channels/src/packages/reselect/src/index'),
'@mattermost/client': path.resolve(__dirname, '../platform/client/src/'),
'@mattermost/components': path.resolve(__dirname, '../platform/components/src/'),
},