Skip to content

feat: リポジトリ追加・削除を owner ロールに限定#244

Merged
coji merged 3 commits intomainfrom
feat/owner-role-repo-restriction
Mar 23, 2026
Merged

feat: リポジトリ追加・削除を owner ロールに限定#244
coji merged 3 commits intomainfrom
feat/owner-role-repo-restriction

Conversation

@coji
Copy link
Owner

@coji coji commented Mar 23, 2026

Summary

  • GitHub App 移行計画(docs/github-app-migration.md)の Phase 0-A を実施
  • PAT 期間中に admin が他 org のリポを操作できないよう、リポジトリの追加・削除を owner ロールに限定
  • isOrgOwner / requireOrgOwner を追加し、リポ操作ルートに適用
  • 非 owner には Add ボタン・DangerZone(削除UI)を非表示
  • ChangeRoleDialog の form.reset() が Dialog マウント前に呼ばれるバグを修正(条件付きレンダリングで remount する方式に変更)
  • GitHub App 移行計画ドキュメントを追加

Test plan

  • owner ロールでリポジトリ追加・削除ができること
  • admin/member ロールでリポジトリ一覧に Add ボタンが表示されないこと
  • admin/member ロールで /settings/repositories/add に直接アクセスするとリダイレクトされること
  • admin/member ロールでリポジトリ設定画面に DangerZone が表示されないこと
  • リポジトリ設定の update(設定変更)は admin/member でも可能なこと
  • Members ページの Change Role ダイアログが正常に動作すること

Closes #243

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能
    • 組織所有者(Owner)判定と所有者権限チェックを追加しました。
  • 改善
    • リポジトリの追加・削除操作を所有者のみ許可するようUI/操作を制御する表示と認可を導入しました。
    • メンバー権限に応じて「追加」ボタンなどを表示/非表示にする制御を追加しました。
    • 役割変更ダイアログを必要時のみマウントするようにして不要なフォーム状態を抑制しました。
  • テスト
    • 所有者/管理者判定ロジックの単体テストを追加しました。
  • ドキュメント
    • GitHub App移行計画のドキュメントを追加しました。

GitHub App 移行(docs/github-app-migration.md Phase 0-A)の先行実施。
PAT 期間中に admin が他 org のリポを操作できないよう、リポジトリの
追加・削除を owner ロールに限定する。

- isOrgOwner / requireOrgOwner を追加
- repositories.add の loader/action に owner ガードを適用
- repository settings の delete action に owner ガードを適用(update は全ロール許可)
- UI: 非 owner には Add ボタン・DangerZone を非表示
- fix: ChangeRoleDialog の form.reset() が Dialog マウント前に呼ばれるバグを修正
- docs: GitHub App 移行計画を追加

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Warning

Rate limit exceeded

@coji has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6168facc-06de-4c55-b074-41134bc79a55

📥 Commits

Reviewing files that changed from the base of the PR and between 709a8a5 and 6dcb1d7.

📒 Files selected for processing (1)
  • docs/github-app-migration.md
📝 Walkthrough

Walkthrough

owner ロール判定関数を追加し、リポジトリの追加・削除をオーナーに限定する認可ゲートをサーバー側(loader/action)に導入。フロントは所有権に基づくボタン表示を制御し、メンバー操作ダイアログのマウントを遅延させる変更を含む。

Changes

Cohort / File(s) Summary
Authorization System
app/libs/member-role.ts, app/libs/auth.server.ts, app/libs/member-role.test.ts
isOrgOwner(role) を追加、isOrgOwner をエクスポート。requireOrgOwner(membership, orgSlug) を追加して ownership を検証し失敗時は redirect。テストを追加。
Repository Management Routes
app/routes/$orgSlug/settings/repositories.add/index.tsx, app/routes/$orgSlug/settings/repositories/$repository/settings/index.tsx
loader / actionmembership を参照して requireOrgOwner を実行。削除系 intent(confirm-delete, delete)はオーナー限定でガード。
Repository UI Layer
app/routes/$orgSlug/settings/repositories._index/index.tsx, app/routes/$orgSlug/settings/repositories._index/+components/repo-table.tsx, app/routes/$orgSlug/settings/repositories._index/+components/data-table-toolbar.tsx
ローダーで canAddRepositories = isOrgOwner(membership.role) を追加し、RepoTableDataTableToolbar に伝搬。Add ボタンを所有者のみ表示に。
Member Dialogs
app/routes/$orgSlug/settings/members/+components/member-row-actions.tsx
ChangeRoleDialog のレンダリングを条件付きでマウント(roleOpen && ...)に変更し、開時の form.reset() / fetcher.reset() を削除。
Documentation
docs/github-app-migration.md
GitHub App への移行計画を新規追加(移行フェーズ、DB 変更、Webhook、権限要件などを記載)。

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Route as "Route Loader/Action"
  participant Auth as "auth.server"
  participant RepoSvc as "Repository logic"

  Client->>Route: リクエスト (loader/action)
  Route->>Auth: requireOrgOwner(membership, orgSlug)?
  alt isOrgOwner == true
    Auth-->>Route: OK
    Route->>RepoSvc: 続行(データ取得 / 処理)
    RepoSvc-->>Route: 結果
    Route-->>Client: 返却 / 正常処理
  else not owner
    Auth-->>Route: redirect
    Route-->>Client: redirect to /:orgSlug/settings/repositories
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 オーナーのみ、鍵を持つ朝、
ボタンは静かに選ばれた友へ。
管理は待ち、権限は光る、
小さなゲートに跳ぶ一歩、
うさぎは草むらで拍手する 🌱✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR タイトルはリポジトリ追加・削除を owner ロールに限定することを明確に述べており、変更の主目的を正確に要約しています。
Linked Issues check ✅ Passed PR は #243 のすべての要件を実装しています。owner ロールチェック関数 isOrgOwner および requireOrgOwner を作成し、repositories.add および repository settings 削除アクションに適用しています。
Out of Scope Changes check ✅ Passed PR に含まれるすべての変更は #243 の要件に関連しており、スコープ外の変更はありません。github-app-migration.md ドキュメントは Phase 0-A の背景として適切です。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/owner-role-repo-restriction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/github-app-migration.md`:
- Around line 46-56: The two fenced code blocks (the one beginning "既存
App「upflow-team」を techtalkjp org に Transfer + 権限追加" and the later block
beginning "1. クライアントに GitHub App インストールを依頼") are missing a language identifier
and trigger markdownlint MD040; update both opening triple-backtick lines to use
a language specifier such as ```text (or another appropriate language), leaving
the block contents unchanged, so the fences become ```text ... ``` for both
occurrences.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d9881f63-3476-4c89-b18d-0aa9bf3f4eee

📥 Commits

Reviewing files that changed from the base of the PR and between 050760d and 596dcf0.

📒 Files selected for processing (10)
  • app/libs/auth.server.ts
  • app/libs/member-role.test.ts
  • app/libs/member-role.ts
  • app/routes/$orgSlug/settings/members/+components/member-row-actions.tsx
  • app/routes/$orgSlug/settings/repositories._index/+components/data-table-toolbar.tsx
  • app/routes/$orgSlug/settings/repositories._index/+components/repo-table.tsx
  • app/routes/$orgSlug/settings/repositories._index/index.tsx
  • app/routes/$orgSlug/settings/repositories.add/index.tsx
  • app/routes/$orgSlug/settings/repositories/$repository/settings/index.tsx
  • docs/github-app-migration.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coji coji assigned coji and unassigned coji Mar 23, 2026
@coji coji merged commit 0a2c371 into main Mar 23, 2026
6 checks passed
@coji coji deleted the feat/owner-role-repo-restriction branch March 23, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

リポジトリ追加・削除を owner ロールに限定する

1 participant