keyshade-xyz / keyshade

Realtime secret and configuration management tool, with the best in class security and seamless integration support
https://keyshade.xyz
Mozilla Public License 2.0
196 stars 96 forks source link

feat(API): Added icon and removed description field from workspace #435

Closed unamdev0 closed 2 weeks ago

unamdev0 commented 2 weeks ago

User description

Description

Added icon and removed description field from workspace

Fixes #229

Screenshots of relevant screens

Screenshot 2024-09-15 at 7 37 27 PM Screenshot 2024-09-15 at 7 39 34 PM

Additional changes Required

Sample response for fetching all workspace of a user

            "id": "006bd5bf-43ac-41ad-b7a9-b1317d08f8ee",
            "name": "My first workspace 2",
            "slug": "my-first-workspace-2-0",
            "isFreeTier": true,
            "createdAt": "2024-09-15T13:32:58.131Z",
            "updatedAt": "2024-09-15T13:32:58.131Z",
            "ownerId": "cm0v65bm00000130sigtvry7y",
            "isDefault": false,
            "icon": "๐Ÿค“",
            "lastUpdatedById": null
        },

Request Body for creating a new Workspace

    "name": "My first workspace 2",
    "icon":"๐Ÿค“"
}

PR Type

enhancement, tests


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
workspace.ts
Replace description with icon in workspace creation           

apps/api/src/common/workspace.ts - Replaced `description` field with `icon` in workspace creation.
+1/-1     
create.workspace.ts
Update DTO to include icon instead of description               

apps/api/src/workspace/dto/create.workspace/create.workspace.ts - Changed optional field from `description` to `icon` in DTO.
+1/-1     
workspace.service.ts
Update workspace service to use icon instead of description

apps/api/src/workspace/service/workspace.service.ts
  • Replaced description with icon in workspace service logic.
  • Removed search functionality for description.
  • +8/-23   
    migration.sql
    Database migration to replace description with icon           

    apps/api/src/prisma/migrations/20240915122629_add_icon_remove_description_from_workspace/migration.sql
  • Dropped description column and added icon column in Workspace table.
  • +9/-0     
    schema.prisma
    Update Prisma schema for workspace icon                                   

    apps/api/src/prisma/schema.prisma
  • Removed description field and added icon field in Workspace model.
  • +1/-1     
    Tests
    event.e2e.spec.ts
    Update tests to reflect workspace icon change                       

    apps/api/src/event/event.e2e.spec.ts
  • Updated tests to use icon instead of description for workspace.
  • +12/-12 
    workspace-membership.e2e.spec.ts
    Modify tests for workspace icon update                                     

    apps/api/src/workspace-membership/workspace-membership.e2e.spec.ts
  • Modified tests to use icon instead of description for workspace.
  • +4/-4     
    workspace.e2e.spec.ts
    Update workspace tests for icon field                                       

    apps/api/src/workspace/workspace.e2e.spec.ts - Updated workspace tests to use `icon` instead of `description`.
    +12/-12 

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-free[bot] commented 2 weeks ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 3 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšชโšช
    ๐Ÿงช PR contains tests
    ๐Ÿ”’ No security concerns identified
    โšก Key issues to review

    Search Functionality
    The search functionality has been modified to only search in the 'name' field, removing the ability to search in the 'description' field. This might impact existing search behavior. Data Validation
    The `icon` field is added as an optional string without any specific validation. Consider adding validation for allowed icon formats or characters.
    codiumai-pr-agent-free[bot] commented 2 weeks ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Add a maximum length constraint to the icon field in the database schema ___ **Consider adding a maximum length constraint to the icon field to prevent excessively
    long icon strings and ensure consistent data storage.** [apps/api/src/prisma/schema.prisma [457]](https://github.com/keyshade-xyz/keyshade/pull/435/files#diff-24191263d57c55d02e0cdf394de15225b628d1da20bd826b1541b59b6b02adb4R457-R457) ```diff -icon String? +icon String? @db.VarChar(255) ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Adding a length constraint ensures data consistency and prevents potential issues with excessively long strings, which is a good practice for database schema design.
    8
    Use a more descriptive icon in workspace creation tests ___ **Consider using a more descriptive icon in the test case to better represent a
    real-world scenario and improve test readability.** [apps/api/src/workspace/workspace.e2e.spec.ts [195]](https://github.com/keyshade-xyz/keyshade/pull/435/files#diff-7a691e843fbdae323f1cabe7a12508154fbc917a1a738e5a67a1747fb7c581eaR195-R195) ```diff -icon: "๐Ÿค“" +icon: "๐Ÿข" // Office building icon to represent a workspace ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 5 Why: While using a more descriptive icon can improve test readability, it is a minor improvement and does not significantly impact the functionality or correctness of the tests.
    5
    Maintainability
    Use a constant for repeated icon values in tests ___ **Consider using a constant for the repeated icon value "๐Ÿค“" to improve maintainability
    and consistency across tests.** [apps/api/src/event/event.e2e.spec.ts [102]](https://github.com/keyshade-xyz/keyshade/pull/435/files#diff-e3b2a34abdd21ac689f251a13fc249d534413e3c14ed8a6ae7374021b1663fe2R102-R102) ```diff +const WORKSPACE_ICON = "๐Ÿค“"; const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "๐Ÿค“" + icon: WORKSPACE_ICON }) ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: Using a constant for repeated values improves maintainability and consistency, making it easier to update the icon value across multiple tests if needed.
    7
    Performance
    Use a more specific search condition for workspace names ___ **Consider using a more specific search condition for the workspace name, such as
    'startsWith' instead of 'contains', to potentially improve search performance and
    accuracy.** [apps/api/src/workspace/service/workspace.service.ts [214-216]](https://github.com/keyshade-xyz/keyshade/pull/435/files#diff-a92613f23cf2834d52eaedb87c4e8c460d48b6fca8df4ccc968b2a8af19a9c3fR214-R216) ```diff name: { - contains: search + startsWith: search } ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Using 'startsWith' instead of 'contains' can improve search performance and accuracy, but it may limit the flexibility of search functionality.
    6
    rajdip-b commented 2 weeks ago

    Hey bro, I think you misunderstood the issue. We didn't want to remove the description field. We just wanted to have an additional icon field.

    unamdev0 commented 2 weeks ago

    oh, it was mentioned by @kriptonian1 in issue's description, @kriptonian1 can you confirm if you meant to remove it from the frontend

    rajdip-b commented 2 weeks ago

    Oh right, yes, my bad.