Skip to content

update: The interface for ordinary users to view resources has been r…#2018

Merged
benjamin-747 merged 1 commit intoweb3infra-foundation:mainfrom
zyd123-cmd:main
Mar 16, 2026
Merged

update: The interface for ordinary users to view resources has been r…#2018
benjamin-747 merged 1 commit intoweb3infra-foundation:mainfrom
zyd123-cmd:main

Conversation

@zyd123-cmd
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9add84d96

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// key by note.id in order to reset tiptap editor state
key={note.id}
note={note}
note={{ ...note, viewer_can_edit: hasWritePermission }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate effective write permission to all note actions

This only patches viewer_can_edit for NoteEditor, while InnerNoteView still passes the original note into NoteBreadcrumbs and NoteTrailingAccessory, both of which gate share/move/delete affordances off note.viewer_can_edit via downstream components. In the exact mismatch case you now surface (!hasWritePermission && note.viewer_can_edit), users are told the doc is read-only but can still open edit-capable menus and trigger mutations that should be blocked, creating inconsistent and error-prone behavior; the effective permission should be applied consistently across the whole note view.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the notes UX to better reflect effective permissions for non-admin users by using the /permissions/me/... endpoint and visually indicating locked/read-only states in note lists and the editor view.

Changes:

  • Use the /api/v1/permissions/me/{resource_type}/{resource_id} endpoint for ordinary users when fetching note permissions.
  • Improve locked/disabled note row UI (lock icon styling + tooltip positioning).
  • In NoteView, derive editability from effective permissions and show a read-only banner when applicable.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
moon/apps/web/hooks/admin/useGetNotesPermissions.ts Switches regular-user permission fetches to the /me permissions endpoint.
moon/apps/web/components/NotesIndex/NoteRow.tsx Updates disabled-note visuals (lock icon, opacity) and tooltip placement.
moon/apps/web/components/NoteView/index.tsx Adds permission lookup to determine write access; shows read-only banner and forces editor read-only.
moon/apps/web/components/NoteEditor/NoteContent.tsx Adjusts editor cursor/caret styling when not fully editable.

Comment on lines +95 to +97
const permission = notesPermissions?.[note.id]
const hasWritePermission = permission?.hasWrite ?? note.viewer_can_edit

Comment on lines +51 to 62
let response

if (isSystemAdmin) {
// Admin users: use admin endpoint
response = await legacyApiClient.v1
.getApiAdminUsersPermissionsByResourceId()
.request(currentUser?.username || '', 'note', note.id)
} else {
// Regular users: use /me endpoint
response = await legacyApiClient.v1.getApiPermissionsMeByResourceId().request('note', note.id)
}

Comment on lines +89 to +92
// Get permissions for this note
const { data: notesPermissions } = useGetNotesPermissions({
notes: [note],
enabled: true
@benjamin-747 benjamin-747 added this pull request to the merge queue Mar 16, 2026
Merged via the queue into web3infra-foundation:main with commit f48ecd0 Mar 16, 2026
9 checks passed
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.

3 participants