Skip to content
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

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

Merged

Conversation

unamdev0
Copy link
Contributor

@unamdev0 unamdev0 commented Sep 15, 2024

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

  • [] Postman updation

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

  • Replaced the description field with an icon field in the workspace model, affecting creation and update operations.
  • Updated database schema and migration scripts to reflect the removal of description and addition of icon.
  • Modified all relevant tests to accommodate the change from description to icon.
  • Adjusted DTOs and service logic to handle the new icon field.

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

    Copy link
    Contributor

    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.

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Sep 15, 2024

    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]

    -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]

    -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]

    +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]

     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 rajdip-b changed the title Feat(API): Added icon and removed description field from workspace feat(API): Added icon and removed description field from workspace Sep 15, 2024
    @rajdip-b
    Copy link
    Member

    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
    Copy link
    Contributor Author

    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
    Copy link
    Member

    Oh right, yes, my bad.

    @rajdip-b rajdip-b force-pushed the feature/add-emoji-icon-in-workspace branch from b54773e to d46c513 Compare September 15, 2024 18:11
    Copy link
    Member

    @rajdip-b rajdip-b left a comment

    Choose a reason for hiding this comment

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

    You would need to update the types and tests in the api-client package. You would need to update these files:

    • workspace.types.ts
    • workspace.spec.ts

    Do let me know if you run into some issue.

    Copy link
    Member

    @rajdip-b rajdip-b left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @rajdip-b rajdip-b force-pushed the feature/add-emoji-icon-in-workspace branch from 9adc705 to 1d9d580 Compare September 16, 2024 13:42
    @rajdip-b rajdip-b merged commit a99c0db into keyshade-xyz:develop Sep 16, 2024
    5 checks passed
    Kiranchaudhary537 pushed a commit to Kiranchaudhary537/keyshade that referenced this pull request Oct 13, 2024
    rajdip-b pushed a commit that referenced this pull request Oct 24, 2024
    ## [2.6.0](v2.5.0...v2.6.0) (2024-10-24)
    
    ### 🚀 Features
    
    * **api:**  Add icon and remove description field from workspace ([#435](#435)) ([a99c0db](a99c0db))
    * **api-client:** Added workspace-membership and related tests ([#452](#452)) ([6a1c091](6a1c091))
    * **api-client:** Create controller for User module ([#484](#484)) ([f9d8e83](f9d8e83))
    * **api:** Add prod env schema in env file ([#436](#436)) ([21c3004](21c3004))
    * **api:** Add resend otp implementation ([#445](#445)) ([4dc6aa1](4dc6aa1))
    * **api:** Fetch total count of environments, [secure]s and variables in project ([#434](#434)) ([0c9e50a](0c9e50a))
    * **api:** Replace `projectId` with `name` and `slug` in workspace-role response.  ([#432](#432)) ([af06071](af06071))
    * **cli:** Add functionality to operate on Secrets ([#504](#504)) ([1b4bf2f](1b4bf2f))
    * **cli:** Add project command ([#451](#451)) ([70448e1](70448e1))
    * **cli:** Add workspace operations ([#441](#441)) ([ed38d22](ed38d22))
    * **cli:** implement commands to get, list, update, and delete, workspace roles ([#469](#469)) ([957ea8d](957ea8d))
    * **cli:** Implemented pagination support ([#453](#453)) ([feb1806](feb1806))
    * **cli:** Secret scan ([#438](#438)) ([85cb8ab](85cb8ab))
    * **cli:** Update environment command outputs ([f4af874](f4af874))
    * **platform:** Clearing email field after waitlisting the user email ([#481](#481)) ([256d659](256d659))
    * Remove project IDs from workspace role export data and update tests ([#448](#448)) ([8fdb328](8fdb328))
    * **web:** Configured extra check for waitlisted users already in the list and created toast message for them ([#492](#492)) ([2ddd0ef](2ddd0ef))
    * **web:** show the toast only when email add successfully ([#490](#490)) ([783c411](783c411))
    
    ### 🐛 Bug Fixes
    
    * **api,api-client:** Add environmentSlug in multiple places across the variable module ([#468](#468)) ([d970aff](d970aff))
    * **api:** Replace the id with slug in the global-search service ([#455](#455)) ([74804b1](74804b1))
    * **platform:** Fixed duplicate Google Logo UI fix  ([#450](#450)) ([fb0d6f7](fb0d6f7))
    * resolve footer website name cut-off or overlap issue ([#444](#444)) ([fe03ba2](fe03ba2))
    * **web:** Horizontal Scrolling issue on the website ([#440](#440)) ([655177b](655177b))
    
    ### 📚 Documentation
    
    * Add documentation for environment in CLI ([#462](#462)) ([dad7394](dad7394))
    * Add documentation for project in CLI ([#466](#466)) ([341fb32](341fb32))
    * Add documentation for scan in CLI ([#461](#461)) ([72281e6](72281e6))
    * Add documentation for workspace command ([#464](#464)) ([4aad8a2](4aad8a2))
    * Add instructions for resetting the local Prisma database ([#495](#495)) ([#501](#501)) ([b07ea17](b07ea17))
    * Added docker support documentation ([#465](#465)) ([bc04be4](bc04be4))
    * Added documentation for running the platform ([#473](#473)) ([8b8386b](8b8386b))
    * Added missing mappings to pages ([5de9fd8](5de9fd8))
    * Fix Documentation Hyperlink and update expired Discord invite link ([#496](#496)) ([5a10e39](5a10e39))
    * Updated CLI docs ([#460](#460)) ([c7e0f13](c7e0f13))
    
    ### 🔧 Miscellaneous Chores
    
    * Add more logging to Sentry init ([#470](#470)) ([de4925d](de4925d))
    * **api:** Optimise API docker image size ([#360](#360)) ([ea40dc1](ea40dc1))
    * **api:** Updated lockfile ([a968e78](a968e78))
    * **CI:** Add [secure] scan validation ([f441262](f441262))
    * **cli:** Update controller invocation in environment commands ([#477](#477)) ([596bd1a](596bd1a))
    * Minor changes to variables ([fe01ca6](fe01ca6))
    * **[secure]-scan:** Failing lint issues ([#507](#507)) ([48f45df](48f45df))
    * **[secure]-scan:** Formatted files ([5884833](5884833))
    * Update .env.example ([70ad4f7](70ad4f7))
    * Updated scripts ([9eb76a7](9eb76a7))
    * **web:** email validation ([#487](#487)) ([e8e737a](e8e737a))
    @rajdip-b
    Copy link
    Member

    🎉 This PR is included in version 2.6.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    API: Add emoji icon and total projects in a workspace
    2 participants