diff --git a/Makefile b/Makefile index 7872bff..5e677a5 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ ifneq ($(wildcard $(ASSETS_DIR)/.),) cp -r $(ASSETS_DIR) dist/$(PLUGIN_ID)/ endif ifneq ($(HAS_PUBLIC),) - cp -r public dist/$(PLUGIN_ID)/ + cp -r public dist/$(PLUGIN_ID)/public/ endif ifneq ($(HAS_SERVER),) mkdir -p dist/$(PLUGIN_ID)/server diff --git a/public/app-bar-icon.png b/public/app-bar-icon.png new file mode 100644 index 0000000..8a5215c Binary files /dev/null and b/public/app-bar-icon.png differ diff --git a/webapp/src/index.tsx b/webapp/src/index.tsx index e4e3286..f25c261 100644 --- a/webapp/src/index.tsx +++ b/webapp/src/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import {Store, Action} from 'redux'; import {GlobalState} from 'mattermost-redux/types/store'; +import {getConfig} from 'mattermost-redux/selectors/entities/general'; import manifest from './manifest'; @@ -22,6 +23,18 @@ export default class Plugin { 'Chess', 'Start a chess game.', ); + + if (registry.registerAppBarComponent) { + const siteUrl = getConfig(store.getState())?.SiteURL || ''; + const iconURL = `${siteUrl}/plugins/${manifest.id}/public/app-bar-icon.png`; + registry.registerAppBarComponent( + iconURL, + () => { + store.dispatch(challenge() as any); + }, + 'Start a chess game.', + ); + } } } diff --git a/webapp/src/types/mattermost-webapp/index.d.ts b/webapp/src/types/mattermost-webapp/index.d.ts index 307e99b..f262c30 100644 --- a/webapp/src/types/mattermost-webapp/index.d.ts +++ b/webapp/src/types/mattermost-webapp/index.d.ts @@ -10,6 +10,7 @@ export interface PluginRegistry { registerReducer(reducer: Reducer); registerChannelHeaderButtonAction(icon: React.ReactNode, action: (channel: Channel, channelMembership: ChannelMembership) => void, dropdownText: string, tooltip: string); registerMainMenuAction(text: React.ReactNode, action: () => void, mobileIcon: React.ReactNode); + registerAppBarComponent(iconURL: string, action: (channel: Channel, member: ChannelMembership) => void, tooltipText: React.ReactNode) // Add more if needed from https://developers.mattermost.com/extend/plugins/webapp/reference }