mcpField
U
umbraco-entity-actions

umbraco-entity-actions

github.com/umbraco開発27388 回インストール6 週間前に更新
リポジトリ

umbraco-entity-actions について

ドキュメントやメディアなど、Umbraco の特定エンティティに対するアクションを実装するスキルです。バックオフィス拡張の開発者向けに、マニフェストやリンク型アクション、権限関連の例を案内します。

主な機能

  1. 01エンティティ別のコンテキストメニュー操作
  2. 02アクションのマニフェストと実装
  3. 03リンク型アクション
  4. 04権限に関するサンプル
  5. 05ドキュメント確認を先に行う手順

活用シーン

  1. 01ドキュメントやメディアのメニューに操作を追加
  2. 02ユーザー権限に応じて操作を制御
  3. 03エンティティに応じた URL へ移動

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/umbraco/umbraco-cms-backoffice-skills --skill umbraco-entity-actions

インストール後、Claude Code で/umbraco-entity-actionsを入力して読み込まれたか確認します。

詳細

Umbraco エンティティアクション

これは何ですか?

エンティティアクションは、Umbraco 内の特定の項目に対してアクションを実行します。ドキュメント、メディア、カスタムエンティティなどのエンティティ型に関連する二次的な機能のための汎用的な拡張ポイントを提供します。これらのアクションはバックオフィス全体のコンテキストメニューに表示され、ユーザー権限によって制御できます。

ドキュメント

実装する前に必ず最新のドキュメントを取得してください:

参照例

Umbraco のソースには動作する例が含まれています:

権限の操作: /Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/manipulate-document-property-value-permissions/

この例は、ドキュメントのプロパティ権限を操作するエンティティアクションを示しています。

ユーザー権限: /Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/user-permission/

この例は、ユーザー権限制御と統合されたエンティティアクションを示しています。

関連する基盤スキル

  • リポジトリパターン: データ操作が必要なアクションを実装する場合

    • 参照スキル: umbraco-repository-pattern
  • Context API: アクションからワークスペースやその他のコンテキストにアクセスする場合

    • 参照スキル: umbraco-context-api
  • 条件: 権限や状態に基づいてアクションの表示を制御する場合

    • 参照スキル: umbraco-conditions

ワークフロー

  1. ドキュメントを取得 - 上記の URL に対して WebFetch を使用します
  2. 質問する - どのエンティティ型ですか? どのようなアクションを実行しますか? 必要な権限は?
  3. ファイルを生成 - 最新のドキュメントに基づいてマニフェスト + アクションクラスを作成します
  4. 説明 - 作成された内容とテスト方法を示します

最小限の例

マニフェスト (manifests.ts)
import type { ManifestEntityAction } from '@umbraco-cms/backoffice/extension-registry';
import { MyEntityAction } from './my-entity-action.js';

const manifest: ManifestEntityAction = {
  type: 'entityAction',
  alias: 'My.EntityAction',
  name: 'My Entity Action',
  weight: 10,
  api: MyEntityAction,
  forEntityTypes: ['document'],
  meta: {
    icon: 'icon-alarm-clock',
    label: 'My Action',
  },
};

export const manifests = [manifest];
アクションの実装 (my-entity-action.ts)
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';

export class MyEntityAction extends UmbEntityActionBase<never> {
  constructor(host: UmbControllerHost, args: { unique: string; entityType: string }) {
    super(host, args);
  }

  async execute() {
    // this.unique contains the entity's unique identifier
    console.log('Executing action on:', this.unique);

    // Perform your action here
    alert(`Action executed on ${this.unique}`);
  }
}
リポジトリを使用するアクション
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';

export class MyEntityAction extends UmbEntityActionBase<MyRepository> {
  constructor(host: UmbControllerHost, args: { unique: string; entityType: string; repositoryAlias: string }) {
    super(host, args);
  }

  async execute() {
    // Access repository via this.repository
    await this.repository?.myCustomMethod(this.unique);
  }
}
リンクベースのアクション (getHref を使用)
export class MyLinkAction extends UmbEntityActionBase<never> {
  async getHref() {
    return `/some/path/${this.unique}`;
  }

  async execute() {
    // Not needed when using getHref
  }
}

一般的なエンティティ型

  • document - コンテンツノード
  • media - メディア項目
  • member - メンバー
  • data-type - データ型
  • document-type - ドキュメント型
  • media-type - メディア型

以上です! 常に最新のドキュメントを取得し、例は最小限に保ち、完全に動作するコードを生成してください。

コメント