From 7e0fb26875d6eaf63b5df22cfd568a313ab9e622 Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Mon, 31 Jan 2022 10:15:50 -0700 Subject: [PATCH] implement registry for channel intro button (#2181) --- mattermost-plugin/webapp/src/index.tsx | 11 +++++++++++ .../webapp/src/types/mattermost-webapp/index.d.ts | 1 + webapp/src/telemetry/telemetryClient.ts | 1 + 3 files changed, 13 insertions(+) diff --git a/mattermost-plugin/webapp/src/index.tsx b/mattermost-plugin/webapp/src/index.tsx index 10a854f57..a33d7fdf4 100644 --- a/mattermost-plugin/webapp/src/index.tsx +++ b/mattermost-plugin/webapp/src/index.tsx @@ -20,6 +20,7 @@ import store from '../../../webapp/src/store' import GlobalHeader from '../../../webapp/src/components/globalHeader/globalHeader' import FocalboardIcon from '../../../webapp/src/widgets/icons/logo' import {setMattermostTheme} from '../../../webapp/src/theme' +import {UserSettings} from '../../../webapp/src/userSettings' import TelemetryClient, {TelemetryCategory, TelemetryActions} from '../../../webapp/src/telemetry/telemetryClient' @@ -139,6 +140,16 @@ export default class Plugin { window.open(`${windowAny.frontendBaseURL}/workspace/${currentChannel}`, '_blank', 'noopener') } this.channelHeaderButtonId = registry.registerChannelHeaderButtonAction(, goToFocalboardWorkspace, 'Boards', 'Boards') + + const goToFocalboardTemplate = () => { + const currentChannel = mmStore.getState().entities.channels.currentChannelId + TelemetryClient.trackEvent(TelemetryCategory, TelemetryActions.ClickChannelIntro, {workspaceID: currentChannel}) + UserSettings.lastBoardId = null + UserSettings.lastViewId = null + window.open(`${windowAny.frontendBaseURL}/workspace/${currentChannel}`, '_blank', 'noopener') + } + this.channelHeaderButtonId = registry.registerChannelIntroButtonAction(, goToFocalboardTemplate, 'Boards') + this.registry.registerProduct('/boards', 'product-boards', 'Boards', '/boards/welcome', MainApp, HeaderComponent) this.registry.registerPostWillRenderEmbedComponent((embed) => embed.type === 'boards', BoardsUnfurl, false) } else { diff --git a/mattermost-plugin/webapp/src/types/mattermost-webapp/index.d.ts b/mattermost-plugin/webapp/src/types/mattermost-webapp/index.d.ts index d7ae52386..1c69d7f8f 100644 --- a/mattermost-plugin/webapp/src/types/mattermost-webapp/index.d.ts +++ b/mattermost-plugin/webapp/src/types/mattermost-webapp/index.d.ts @@ -3,6 +3,7 @@ export interface PluginRegistry { registerPostTypeComponent(typeName: string, component: React.ElementType) registerChannelHeaderButtonAction(icon: React.Element, action: () => void, dropdownText: string, tooltipText: string) + registerChannelIntroButtonAction(icon: React.Element, action: () => void, tooltipText: string) registerCustomRoute(route: string, component: React.ElementType) registerProductRoute(route: string, component: React.ElementType) unregisterComponent(componentId: string) diff --git a/webapp/src/telemetry/telemetryClient.ts b/webapp/src/telemetry/telemetryClient.ts index debddf9df..a67eb1f41 100644 --- a/webapp/src/telemetry/telemetryClient.ts +++ b/webapp/src/telemetry/telemetryClient.ts @@ -8,6 +8,7 @@ export const TelemetryCategory = 'boards' export const TelemetryActions = { ClickChannelHeader: 'clickChannelHeader', + ClickChannelIntro: 'channelIntro_boardLink', ViewBoard: 'viewBoard', CreateBoard: 'createBoard', DuplicateBoard: 'duplicateBoard',