implement registry for channel intro button (#2181)

This commit is contained in:
Scott Bishel 2022-01-31 10:15:50 -07:00 committed by GitHub
parent a07a48a9ae
commit 7e0fb26875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -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(<FocalboardIcon/>, 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(<FocalboardIcon/>, goToFocalboardTemplate, 'Boards')
this.registry.registerProduct('/boards', 'product-boards', 'Boards', '/boards/welcome', MainApp, HeaderComponent)
this.registry.registerPostWillRenderEmbedComponent((embed) => embed.type === 'boards', BoardsUnfurl, false)
} else {

View file

@ -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)

View file

@ -8,6 +8,7 @@ export const TelemetryCategory = 'boards'
export const TelemetryActions = {
ClickChannelHeader: 'clickChannelHeader',
ClickChannelIntro: 'channelIntro_boardLink',
ViewBoard: 'viewBoard',
CreateBoard: 'createBoard',
DuplicateBoard: 'duplicateBoard',