feat: add mime type mappings and resolve functions for text and icon representations #2

Merged
jonasclaes merged 3 commits from feature/dpapp-32 into main 2025-06-08 21:42:29 +00:00
jonasclaes commented 2025-06-08 21:39:33 +00:00 (Migrated from github.com)

Summary by CodeRabbit

  • New Features
    • File lists now display more descriptive labels and improved icons based on file type, providing clearer information and better visual cues for each file.
  • Refactor
    • Enhanced the logic for determining file icons and labels by using a mapping-based approach, resulting in more consistent and user-friendly file representations.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - File lists now display more descriptive labels and improved icons based on file type, providing clearer information and better visual cues for each file. - **Refactor** - Enhanced the logic for determining file icons and labels by using a mapping-based approach, resulting in more consistent and user-friendly file representations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
linear[bot] commented 2025-06-08 21:39:36 +00:00 (Migrated from github.com)
<p><a href="https://linear.app/docport/issue/DPAPP-32/as-a-user-i-can-see-the-file-type-of-a-document">DPAPP-32 As a user, I can see the file type of a document</a></p>
coderabbitai[bot] commented 2025-06-08 21:39:39 +00:00 (Migrated from github.com)

Caution

Review failed

The pull request is closed.

Walkthrough

A new module was introduced to map MIME types to user-friendly text labels and icon categories, along with resolution functions. The project details page now imports these utilities, updating its icon selection and file description logic to use the new mapping-based approach instead of hardcoded MIME type checks.

Changes

File(s) Change Summary
src/lib/file-mappings.ts Added a module exporting MIME type to text/icon mappings, a union type for icon categories, and two resolution functions.
src/routes/(user)/projects/[id]/+page.svelte Updated to use new mapping functions for icon and label resolution; changed icon logic and file description display.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Project Details Page
    participant FileMappings as file-mappings.ts

    UI->>FileMappings: resolveIconMapping(file.mimeType)
    FileMappings-->>UI: iconCategory

    UI->>FileMappings: resolveTextMapping(file.mimeType)
    FileMappings-->>UI: textLabel

    UI->>UI: getFileIcon(iconCategory)
    UI->>UI: Display icon and textLabel for file

Poem

In the warren of code, a mapping appears,
MIME types transformed, confusion disappears!
Icons and labels now smartly assigned,
No more hardcoding, just mappings aligned.
With every file shown, the meaning is clear—
A rabbit’s delight, let’s all give a cheer! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e350571989 and 4698a2b247.

📒 Files selected for processing (2)
  • src/lib/file-mappings.ts (1 hunks)
  • src/routes/(user)/projects/[id]/+page.svelte (3 hunks)
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.

❤️ Share
🪧 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- This is an auto-generated comment: failure by coderabbit.ai --> > [!CAUTION] > ## Review failed > > The pull request is closed. <!-- end of auto-generated comment: failure by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough A new module was introduced to map MIME types to user-friendly text labels and icon categories, along with resolution functions. The project details page now imports these utilities, updating its icon selection and file description logic to use the new mapping-based approach instead of hardcoded MIME type checks. ## Changes | File(s) | Change Summary | |----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------| | src/lib/file-mappings.ts | Added a module exporting MIME type to text/icon mappings, a union type for icon categories, and two resolution functions. | | src/routes/(user)/projects/[id]/+page.svelte | Updated to use new mapping functions for icon and label resolution; changed icon logic and file description display. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant UI as Project Details Page participant FileMappings as file-mappings.ts UI->>FileMappings: resolveIconMapping(file.mimeType) FileMappings-->>UI: iconCategory UI->>FileMappings: resolveTextMapping(file.mimeType) FileMappings-->>UI: textLabel UI->>UI: getFileIcon(iconCategory) UI->>UI: Display icon and textLabel for file ``` ## Poem > In the warren of code, a mapping appears, > MIME types transformed, confusion disappears! > Icons and labels now smartly assigned, > No more hardcoding, just mappings aligned. > With every file shown, the meaning is clear— > A rabbit’s delight, let’s all give a cheer! 🐇✨ <!-- walkthrough_end --> <!-- internal state start --> <!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4AzEtS5pa9ZvDaRcs7iUjM03bngMImRMegppfAspSBtsDDF4fAxkG3w+GgAPXHQMengmLAjeaXZqJJSDADlsZgFKLgAmAwBVRAbIIWS0RAYLNGkjfWNwKDJ6fBscAmIyZRp6JlZ2Ll5+YVFxKRl5JiUqVXUtHWGTKDhUVExpwlJyKgWFZYxOSCoAd0hEWr8KeTkFPsVGpNNpdGBDCNTAZEBQGAB6CzwATwmzwKxgPwBIIhDS4RAcAwAIhJBgAxGTIABBACSs3u1DoXx+aD+/CmDFgmFIiCMVMg5E+zEU2CskCUaPIyCxgWCoTyb0iFjwFVi8USyVS6UgAFkaTqAKIeLzSDz4SDYdoUMA2CjwcYWeRZHL9eoWeX5QqMRlEdL2xAaSA0nIkTLcdL4jzvc1Ygn8ci+fyyohfbwMeBohi6/VGzzeZAEcXSBh27hbHzOyCukjuyAAChIGiIGgANJAAAoAEQAYm2AFo09vUuEIKQASjbYVy+FwsEoiexwWzhuN+bNKC9DB9ftN3056GQAHJaPgGLV2Ie24fWZzJCRL/w+Ie3GhSIfA3AfMLaKKfGh3eaobhhQka4NGaoJOImpcAABhEiBRFI0ChrgOpJjiMG5PQcFKlINKFGhi5EDBgYGmg+5xJBqq4GgADWppoMuuYml8uB2kuU4RLg2AUCkHhzgoFDweGeQ4h4KFVioNaPhuyTejQvp/IGNJTLOPh6iueY+KgQFIumuCOgu3i0G2akQRqRQkNxvEFgJMpMhI/7YI2kAAPJqRQ7xICQbbqLE/61gI5G0euJRopkYBBe0LjULeS5yWZGnMd4rHsS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4U26H82QGyJFrS+HknwVVXH9HkEkiqRA2AvGoeaJM4wPpKF6KWcs4lshFjtFIOuojxGxFucgTpOtLRiTec3Oah9/HtEYFycxpiojBPLIZRACAbA5EsWIrkFBaB7CZHSlinJRC0RRh9EuRBIo9DegER+uzYjalujwiSy8VS9RhuSSkVI4FI2xo4gS6N+jmr4nbLWBM+BExJh1dgFM8HnAEhov63hI6xLWmongmMDHzh1mY0gFKrFu37sRdcniY7xJ8cI12D8n40H/m/K0n9v6/3xIAkB4DIGkA0DAmsNASIINvqrCEUIxgKjthVGY2THhLAxa8D4zIMFsgBJKg4IJjjgj0EAA== --> <!-- internal state end --> --- <details> <summary>📜 Recent review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e350571989f8f5542445b6643172212e87f3adc7 and 4698a2b24742641cd7ff58df839be64a987978b2. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/lib/file-mappings.ts` (1 hunks) * `src/routes/(user)/projects/[id]/+page.svelte` (3 hunks) </details> </details> <!-- finishing_touch_checkbox_start --> <details open="true"> <summary>✨ Finishing Touches</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings </details> <!-- finishing_touch_checkbox_end --> <!-- tips_start --> --- 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. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=DocPort-io/app&utm_content=2): - 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 `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai explain this code block.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in 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](https://www.coderabbit.ai/contact-us/support) 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 pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. - `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-06-08 21:40:18 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR adds new functions and mappings to resolve MIME type representations for both text labels and icon types within project file display components.

  • Introduces MIME type mappings and resolver functions in a new file (src/lib/file-mappings.ts).
  • Updates the Svelte project page to use the new resolver functions for displaying file icons and text labels.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/routes/(user)/projects/[id]/+page.svelte Updated file icon and text rendering logic to use new MIME type mapping functions
src/lib/file-mappings.ts Added MIME type to text and icon mappings with resolver functions
Comments suppressed due to low confidence (2)

src/lib/file-mappings.ts:64

  • [nitpick] The icon mapping for MIME types starting with 'text/' returns 'code', while the text mapping returns 'Text File'. Please confirm that 'code' is the intended icon for text files or update it to be more consistent with expected UI representations.
if (mimeType.startsWith('text/')) { return 'code'; }

src/lib/file-mappings.ts:18

  • [nitpick] The Siemens TIA Portal Project Archive is mapped to 'unknown' for icons. If a more specific icon is available or expected for this MIME type, consider updating its mapping.
['application/vnd.siemens.tiaportal.project.archive', 'unknown'],
## Pull Request Overview This PR adds new functions and mappings to resolve MIME type representations for both text labels and icon types within project file display components. - Introduces MIME type mappings and resolver functions in a new file (src/lib/file-mappings.ts). - Updates the Svelte project page to use the new resolver functions for displaying file icons and text labels. ### Reviewed Changes Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments. | File | Description | | ---- | ----------- | | src/routes/(user)/projects/[id]/+page.svelte | Updated file icon and text rendering logic to use new MIME type mapping functions | | src/lib/file-mappings.ts | Added MIME type to text and icon mappings with resolver functions | <details> <summary>Comments suppressed due to low confidence (2)</summary> **src/lib/file-mappings.ts:64** * [nitpick] The icon mapping for MIME types starting with 'text/' returns 'code', while the text mapping returns 'Text File'. Please confirm that 'code' is the intended icon for text files or update it to be more consistent with expected UI representations. ``` if (mimeType.startsWith('text/')) { return 'code'; } ``` **src/lib/file-mappings.ts:18** * [nitpick] The Siemens TIA Portal Project Archive is mapped to 'unknown' for icons. If a more specific icon is available or expected for this MIME type, consider updating its mapping. ``` ['application/vnd.siemens.tiaportal.project.archive', 'unknown'], ``` </details>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DocPort/app-pb!2
No description provided.