-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix: permission control doesn't work when opening the page at the first time #8023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR updates the page‐access control to use a read‐only default on first load, fixes initial permission logic, lowers logging verbosity for view operations, and switches shared‐feature widgets to Rust‐backed repositories. Sequence Diagram: Initial Page Access Level DeterminationsequenceDiagram
actor User
participant PageUI
participant PageAccessLevelBloc
participant RustPageAccessLevelRepositoryImpl
participant UserAuthService
User->>PageUI: Opens page
PageUI->>PageAccessLevelBloc: Request page access level for pageId
PageAccessLevelBloc->>RustPageAccessLevelRepositoryImpl: getCurrentUserAccessLevelInPage(pageId)
RustPageAccessLevelRepositoryImpl->>UserAuthService: currentUser()
UserAuthService-->>RustPageAccessLevelRepositoryImpl: UserProfile (or null)
alt User is null or not found in page members list
RustPageAccessLevelRepositoryImpl-->>PageAccessLevelBloc: FlowyResult.success(ShareAccessLevel.readOnly) # New default
else User is in page members list
RustPageAccessLevelRepositoryImpl-->>PageAccessLevelBloc: FlowyResult.success(DeterminedAccessLevel) # Existing logic
end
PageAccessLevelBloc-->>PageUI: Update with determined access level
PageUI-->>User: Displays page with appropriate access
Class Diagram: PageAccessLevelState Default Initialization UpdateclassDiagram
class PageAccessLevelState {
+ShareAccessLevel accessLevel
+bool isLocked
+int lockCounter
+SharedSectionType sectionType
+static PageAccessLevelState initial()
}
class ShareAccessLevel {
<<enumeration>>
readOnly
readAndWrite
fullAccess
none
}
PageAccessLevelState o-- ShareAccessLevel : accessLevel
note "The initial() method now sets 'accessLevel' to ShareAccessLevel.readOnly instead of ShareAccessLevel.readAndWrite."
Class Diagram: RustPageAccessLevelRepositoryImpl Default Fallback UpdateclassDiagram
class RustPageAccessLevelRepositoryImpl {
+Future<FlowyResult<View>> getView(String pageId)
+Future<FlowyResult<void>> lockView(String pageId)
+Future<FlowyResult<void>> unlockView(String pageId)
+Future<FlowyResult<ShareAccessLevel>> getCurrentUserAccessLevelInPage(String pageId)
}
class ShareAccessLevel {
<<enumeration>>
readOnly
readAndWrite
}
RustPageAccessLevelRepositoryImpl ..> ShareAccessLevel : uses
note for RustPageAccessLevelRepositoryImpl "getCurrentUserAccessLevelInPage now defaults to ShareAccessLevel.readOnly if user/permissions not found, previously ShareAccessLevel.readAndWrite."
Class Diagram: ShareButton's Updated Dependency via ShareTabBlocclassDiagram
class ShareButton {
+View view
+String workspaceId
+Widget build(BuildContext context)
}
class ShareTabBloc {
+ShareTabBloc(IShareWithUserRepository repository, String pageId, String workspaceId)
}
class RustShareWithUserRepositoryImpl {
+IShareWithUserRepository
}
class IShareWithUserRepository {
<<interface>>
}
IShareWithUserRepository <|.. RustShareWithUserRepositoryImpl
ShareButton ..> ShareTabBloc : creates & provides via BlocProvider
ShareTabBloc o-- IShareWithUserRepository : repository (now RustShareWithUserRepositoryImpl)
Class Diagram: SharedSection's Updated Dependency via SharedSectionBlocclassDiagram
class SharedSection {
+Widget build(BuildContext context)
}
class SharedSectionBloc {
+SharedSectionBloc(ISharedPagesRepository repository, String workspaceId)
}
class RustSharedPagesRepositoryImpl {
+ISharedPagesRepository
}
class ISharedPagesRepository {
<<interface>>
}
ISharedPagesRepository <|.. RustSharedPagesRepositoryImpl
SharedSection ..> SharedSectionBloc : creates & provides via BlocProvider
SharedSectionBloc o-- ISharedPagesRepository : repository (now RustSharedPagesRepositoryImpl)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @LucasXu0 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| 'failed to get user access level: $failure, in page: $pageId', | ||
| ); | ||
|
|
||
| // return the read and write access level if the user is not found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Update or remove outdated inline comment
The inline comment is now inaccurate; please update it to match the current return value or remove it.
e5b4eef to
1b20289
Compare
Feature Preview
PR Checklist
Summary by Sourcery
Fix permission control on initial page load by defaulting share access to read-only and switching to Rust backend implementations for sharing repositories; lower view log verbosity.
Bug Fixes:
Enhancements: