# トピック管理パネルにカスタムオプションはありますか？

**URL:** <https://meta.discourse.org/t/custom-option-in-the-topic-admin-panel/95617>\
**Category:** Development\
**Created:** [2018 年 8 月 25 日午前 4:29 UTC](https://meta.discourse.org/t/custom-option-in-the-topic-admin-panel/95617 "2018-08-25T04:29:44Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Kampfkarren](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kampfkarren/32/109627_2.png) [@Kampfkarren](https://meta.discourse.org/u/Kampfkarren)\
**Post date:** [2018 年 8 月 25 日午前 4:29 UTC](https://meta.discourse.org/t/custom-option-in-the-topic-admin-panel/95617/1 "2018-08-25T04:29:45Z")

</div>

過去15時間、私の時間は悪夢そのものでした。既存のプラグインやソースコードを読み漁り、極めて基本的な機能を実装して最初のプラグインを作成しようとしたからです。助けが必要です。

具体的には、各投稿に対して管理パネル（左下のボタン）に新しいボタンを追加する方法が知りたいです。私が達成できたのは、そのボタンをウィジェットと同じ要素に配置することまでです。

 ![](https://global.discourse-cdn.com/meta/original/3X/f/3/f3d6f5dd82f529014ca7059ff97732396eab3b10.png)

しかし、箇条書きの点に注目してください。これは、私が作成したものが本来入るべき `ul` 要素に入っていないためです。どう修正すればよいのか全く見当が付きません。

![](https://global.discourse-cdn.com/meta/original/3X/8/e/8e0be1bbe0bbcb9c58c92e5d23bc4e4682c96fe4.png)

（この `div` が私のオプションです）

私は以下のコードでそれを行いました。

```plaintext
import { withPluginApi } from 'discourse/lib/plugin-api';
import showModal from "discourse/lib/show-modal";

export default {
	name: 'tl-post-lock',
	initialize() {
		withPluginApi('0.8.24', function(api) {
			const user = api.getCurrentUser()

			if(user.trust_level >= api.container.lookup('site-settings:main').tl_lock_minimum) {
				// ユーザーはボタンを表示する権限がある

				api.decorateWidget('topic-admin-menu:after', (decorator) => {
					// 管理メニューにボタンを追加
					return decorator.attach('admin-menu-button', {
						icon: 'ban',
						fullLabel: 'tl_post_lock.button_label',
						action: 'actionTlLock'
					})
				})
				
			}
		})
	}
}

```

その後、実際にクリックできるようにする方法が見つかりません。`decorateWidget` ブロックの後に、以下のような形式のコードを書くと、

![image](https://global.discourse-cdn.com/meta/original/3X/9/0/90a39c26260e7cede9e188be7e7078113f5a6aa6.png)

存在しない行や文字を指す、全く役に立たない以下のエラーが発生します。

![](https://global.discourse-cdn.com/meta/original/3X/6/9/6960c876b15dbdcb4fcafd71580ec4352c5389d3.png)

さらに、その他にも多数のスパムメッセージが表示されます。

正気を失いそうです。クリックしたときにコードを実行できるよう、単に管理パネルの左下にボタンを追加する方法を教えてください。

---

_[View the full topic](https://meta.discourse.org/t/custom-option-in-the-topic-admin-panel/95617)._
