Workspace labels #3101
Description
This PR contains changes related to scope of labels: we have labels specified for projects, this update makes it scoped in workspace. Idea is to make it easier for dashboards especially: sometimes you need to build dashboards based on labels attached to issue and its a bit painful when you have 50+ projects inside
Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Feature (non-breaking change which adds functionality)
- [x] Improvement (change that would cause existing functionality to not work as expected)
- [ ] Code refactoring
- [ ] Performance improvements
- [ ] Documentation update
Test Scenarios
- make sure you have labels (may be with same name in different projects)
- apply this PRs patch
- restart services (especially api which brings with 2 migrations)
- check labels under workspace on
[workspace]/labelsuri: all the labels should be there, duplicated labels must be removed, issues updated accordingly
References
https://github.com/makeplane/plane/issues/3101
Summary by CodeRabbit
-
New Features
- Introduced workspace-level label management, allowing users to create, update, and delete labels scoped to the workspace.
- Added a dedicated workspace labels settings page with a new sidebar navigation item and icon for easy access.
- Implemented permission-aware UI for label management, supporting both ADMIN and MEMBER roles at the workspace level.
-
Improvements
- Unified label handling across workspace and project scopes for more flexible label organization.
- Enhanced label filtering and selection throughout the app to support both workspace and project labels.
- Updated label-related components and services for consistent naming and improved usability.
-
Bug Fixes
- Improved error handling and validation for label creation and updates, ensuring unique label names within a workspace.
-
Refactor
- Refactored label-related components, store logic, and services to support workspace-wide operations and streamline codebase consistency.
- Renamed variables and components for clarity and alignment with new workspace label features.
-
Chores
- Updated type definitions to allow labels without a project association.
- Improved state management for label forms using a centralized store.
Walkthrough
This update introduces workspace-scoped label management, including new API endpoints, viewsets, and UI components. It refactors label operations to support both workspace and project scopes, updates permission checks, and revises unique constraints in the database. The frontend adapts to these changes by generalizing label fetching, storage, and usage across the application.
Changes
| File(s) | Change Summary |
|---|---|
| apiserver/plane/app/urls/workspace.py, apiserver/plane/app/views/init.py, apiserver/plane/app/views/workspace/label.py | Added WorkspaceLabelViewSet for workspace-scoped label CRUD; registered new RESTful routes; updated imports. |
| apiserver/plane/db/models/label.py, apiserver/plane/db/migrations/0097_remove_label_unique_name_when_project_null_and_not_deleted_and_more.py | Modified/removal of unique constraints on label names to consolidate uniqueness enforcement. |
| apiserver/plane/space/serializer/issue.py | Updated LabelSerializer to allow project_detail to be null and made only workspace a read-only field. |
| packages/constants/src/workspace.ts, web/ce/components/workspace/sidebar/helper.tsx | Added workspace label navigation item and icon to sidebar. |
| web/core/services/issue/issue_label.service.ts | Refactored label service to support workspace-level operations and optional project context in CRUD methods. |
| web/core/store/label.store.ts | Unified label handling for workspace and project scopes; added new computed properties and updated CRUD/fetching methods. |
| packages/types/src/issues.d.ts | Made project_id in IIssueLabel nullable. |
| web/core/components/issues/issue-layouts/properties/label-dropdown.tsx, web/core/components/issues/issue-layouts/properties/labels.tsx, web/core/components/issues/select/label.tsx | Refactored label fetching and usage to be workspace-centric; removed project-specific dependencies. |
| web/core/components/inbox/inbox-filter/filters/filter-selection.tsx, web/core/components/inbox/sidebar/inbox-list-item.tsx, web/core/components/issues/archived-issues-header.tsx, web/core/components/issues/filters.tsx, web/core/components/issues/issue-layouts/filters/applied-filters/roots/archived-issue.tsx, web/core/components/issues/issue-layouts/filters/applied-filters/roots/cycle-root.tsx, web/core/components/issues/issue-layouts/filters/applied-filters/roots/draft-issue.tsx, web/core/components/issues/issue-layouts/filters/applied-filters/roots/module-root.tsx, web/core/components/issues/issue-layouts/filters/applied-filters/roots/project-root.tsx, web/core/components/issues/issue-layouts/filters/applied-filters/roots/project-view-root.tsx, web/core/components/views/form.tsx | Renamed label variables from projectLabels to labels for workspace scope; updated props accordingly. |
| web/core/components/labels/setting-label-group.tsx, web/core/components/labels/setting-label-item.tsx, web/core/components/labels/setting-label-list.tsx, web/core/components/labels/index.ts | Renamed and refactored label settings components from project-specific to general settings; updated exports and imports. |
| web/core/components/labels/stores/index.ts | Added MobX store for label form state management. |
| web/core/components/labels/delete-label-modal.tsx | Made label deletion support optional projectId; removed requirement for projectId to be present. |
| web/core/components/labels/label-drag-n-drop-HOC.tsx | Updated permission checks for label editability to consider workspace scope if project_id is absent. |
| web/core/store/issue/issue-details/sub_issues.store.ts | Updated label fetching in sub-issues store to use workspace-scoped method. |
| web/core/components/labels/create-update-label-inline.tsx | Minor syntax update in export, no logic change. |
| web/core/components/issues/issue-detail/label/select/label-select.tsx | Refactored label fetching to workspace scope; improved error handling. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant Frontend
participant API
participant DB
User->>Frontend: Navigates to Workspace Labels
Frontend->>API: GET /workspaces/{slug}/issue-labels/
API->>DB: Query labels WHERE workspace=slug AND project IS NULL
DB-->>API: Return label list
API-->>Frontend: Respond with label data
Frontend-->>User: Display workspace labels
User->>Frontend: Creates/Updates/Deletes a label
Frontend->>API: POST/PUT/PATCH/DELETE /workspaces/{slug}/issue-labels/...
API->>DB: Perform label operation (with unique constraint enforcement)
DB-->>API: Success/Error
API-->>Frontend: Respond with result
Frontend-->>User: Update UI accordingly
Suggested labels
🌟improvement
Suggested reviewers
- prateekshourya29
- anmolsinghbhatia
Poem
In the workspace garden, labels bloom anew,
With endpoints fresh and colors true.
From project roots, they now arise,
Across the space, beneath wide skies.
Rabbits hop and organize with glee—
This patch brings order, for all to see!
🐇🌱✨
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
any news on that ? I'm also interested 👍
Thanks for this contribution. Unfortunately, this feature is not on our roadmap of features.