mattermost-plugin-shelfmark/webapp/src/index.tsx
Felipe M. 11f73f6e45
Some checks failed
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci / plugin-ci (push) Has been cancelled
Add RHS panel with channel header toggle button
Register an empty RHS panel component and a channel header button using
the Shelfmark logo icon to toggle it open/closed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 11:35:30 +01:00

35 lines
1.1 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import manifest from 'manifest';
import React from 'react';
import type {Store, Action} from 'redux';
import type {GlobalState} from '@mattermost/types/store';
import RHSPanel from 'components/rhs_panel';
import type {PluginRegistry} from 'types/mattermost-webapp';
export default class Plugin {
public async initialize(registry: PluginRegistry, store: Store<GlobalState>) {
const {toggleRHSPlugin} = registry.registerRightHandSidebarComponent(RHSPanel, 'Shelfmark');
const iconURL = `/plugins/${manifest.id}/public/icon.png`;
const icon = React.createElement('img', {src: iconURL, width: 16, height: 16});
registry.registerChannelHeaderButtonAction(
icon,
() => store.dispatch(toggleRHSPlugin as Action),
'Shelfmark',
'Toggle Shelfmark panel',
);
}
}
declare global {
interface Window {
registerPlugin(pluginId: string, plugin: Plugin): void;
}
}
window.registerPlugin(manifest.id, new Plugin());