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>
35 lines
1.1 KiB
TypeScript
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());
|