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: add message to display list being empty #300

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

RohitR311
Copy link
Collaborator

@RohitR311 RohitR311 commented Dec 28, 2024

If in Capture List action all data fields are discarded display a message in the right side panel stating no list items.

Summary by CodeRabbit

  • New Features
    • Added localized "empty list" messages for multiple languages (German, English, Spanish, Japanese, Chinese).
    • Enhanced user feedback in the Right Side Panel to display a message when no fields are selected in a list.

Copy link

coderabbitai bot commented Dec 28, 2024

Walkthrough

The pull request introduces a new localization message "list_empty" across multiple language files (German, English, Spanish, Japanese, and Chinese) to provide user feedback when no fields are selected in a list. Simultaneously, the RightSidePanel component is updated to conditionally render this new message when a list step contains no fields, enhancing the user interface's clarity and communication.

Changes

File Change Summary
public/locales/de.json Added German "list_empty" message: "Liste ist leer. Es wurden keine Felder ausgewählt."
public/locales/en.json Added English "list_empty" message: "List is empty. No fields have been selected."
public/locales/es.json Added Spanish "list_empty" message: "La lista está vacía. No se han seleccionado campos."
public/locales/ja.json Added Japanese "list_empty" message: "リストが空です。フィールドが選択されていません。"
public/locales/zh.json Added Chinese "list_empty" message: "列表为空。尚未选择任何字段。"
src/components/organisms/RightSidePanel.tsx Updated rendering logic to display "list_empty" message when no fields are present in a list step

Sequence Diagram

sequenceDiagram
    participant User
    participant RightSidePanel
    participant ListStep
    
    User->>RightSidePanel: Interacts with list
    RightSidePanel->>ListStep: Check fields
    alt No fields selected
        RightSidePanel->>User: Display "list_empty" message
    else Fields selected
        RightSidePanel->>User: Show list fields
    end
Loading

Poem

🐰 A Rabbit's Localization Delight 🌈

Empty lists no longer hide,
With messages clear and wide,
In languages from far and near,
Our users' confusion we'll clear!
A linguistic dance, oh so bright! 🌟


📜 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 6665a4e and 7dc2bb5.

📒 Files selected for processing (6)
  • public/locales/de.json (1 hunks)
  • public/locales/en.json (1 hunks)
  • public/locales/es.json (1 hunks)
  • public/locales/ja.json (1 hunks)
  • public/locales/zh.json (1 hunks)
  • src/components/organisms/RightSidePanel.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • public/locales/de.json
  • public/locales/es.json
  • public/locales/zh.json
  • public/locales/en.json
  • public/locales/ja.json
  • src/components/organisms/RightSidePanel.tsx

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b12139 and 6665a4e.

📒 Files selected for processing (6)
  • public/locales/de.json (1 hunks)
  • public/locales/en.json (1 hunks)
  • public/locales/es.json (1 hunks)
  • public/locales/ja.json (1 hunks)
  • public/locales/zh.json (1 hunks)
  • src/components/organisms/RightSidePanel.tsx (1 hunks)
🔇 Additional comments (7)
src/components/organisms/RightSidePanel.tsx (1)

548-550: Consider adding a null/undefined check for step.fields.
If there's any scenario where step.fields might be undefined or null, Object.entries(step.fields) will throw an error. If you're certain step.fields is always defined at this point, you can ignore this. Otherwise, consider optional chaining or a defensive check.

public/locales/zh.json (1)

194-195: Translation addition looks good.
These new keys accurately convey an empty list message in a concise manner, consistent with existing translations.

public/locales/ja.json (1)

194-195: New “list_empty” message is well-formed.
The addition is grammatically correct and maintains consistency with the structure of other keys.

public/locales/en.json (1)

194-195: Localization string addition is appropriate.
The new message aligns with existing wording, improving clarity when the list contains no fields.

public/locales/es.json (1)

194-195: LGTM! Spanish translation is accurate and well-formatted.

The translation "La lista está vacía. No se han seleccionado campos." is grammatically correct and effectively conveys the empty list state to Spanish-speaking users.

public/locales/de.json (2)

193-194: LGTM! German translation is accurate and well-formatted.

The translation "Liste ist leer. Es wurden keine Felder ausgewählt." is grammatically correct and effectively conveys the empty list state to German-speaking users.


193-195: Verify translations in other language files.

The AI summary mentions translations in English, Japanese, and Chinese files. Let's verify they exist and are consistent.

✅ Verification successful

Translations are consistent across all language files

The verification shows that the "list_empty" message exists in all language files (en, ja, zh, de) with appropriate translations:

  • English: "List is empty. No fields have been selected."
  • Japanese: "リストが空です。フィールドが選択されていません。"
  • Chinese: "列表为空。尚未选择任何字段。"
  • German: "Liste ist leer. Es wurden keine Felder ausgewählt."

Each translation maintains the same meaning while being culturally appropriate for its target language.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the "list_empty" message exists in all language files
# and display their translations for comparison.

echo "Checking translations in all language files..."
for lang in en ja zh; do
  if [ -f "public/locales/${lang}.json" ]; then
    echo "=== ${lang}.json ==="
    # Extract the list_empty message using jq
    jq -r '.right_panel.messages.list_empty' "public/locales/${lang}.json"
  else
    echo "Warning: public/locales/${lang}.json not found"
  fi
done

Length of output: 679

Comment on lines 551 to 604
<>
<Typography>{t('right_panel.messages.list_selected')}</Typography>
{Object.entries(step.fields).map(([key, field]) => (
<Box key={key}>
<TextField
label={t('right_panel.fields.field_label')}
value={field.label || ''}
onChange={(e) => handleTextLabelChange(field.id, e.target.value, step.id, key)}
fullWidth
margin="normal"
InputProps={{
readOnly: confirmedListTextFields[field.id]?.[key],
startAdornment: (
<InputAdornment position="start">
<EditIcon />
</InputAdornment>
)
}}
/>
<TextField
label={t('right_panel.fields.field_data')}
value={field.data || ''}
fullWidth
margin="normal"
InputProps={{
readOnly: true,
startAdornment: (
<InputAdornment position="start">
<TextFieldsIcon />
</InputAdornment>
)
}}
/>
{!confirmedListTextFields[step.id]?.[key] && (
<Box display="flex" justifyContent="space-between" gap={2}>
<Button
variant="contained"
onClick={() => handleListTextFieldConfirm(step.id, key)}
disabled={!field.label?.trim()}
>
{t('right_panel.buttons.confirm')}
</Button>
<Button
variant="contained"
color="error"
onClick={() => handleListTextFieldDiscard(step.id, key)}
>
{t('right_panel.buttons.discard')}
</Button>
</Box>
)}
</Box>
))}
</>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix mismatched indices in readOnly condition for list fields.
Currently, the code uses confirmedListTextFields[field.id]?.[key] to determine if the field is read-only. However, the confirm/discard logic uses handleListTextFieldConfirm(step.id, key) and handleListTextFieldDiscard(step.id, key), storing confirmation state in confirmedListTextFields[step.id][key]. This mismatch prevents the field from toggling read-only properly.

Below is a proposed fix for the relevant read-only line, switching to step.id so it matches the stored structure:

-                        readOnly: confirmedListTextFields[field.id]?.[key],
+                        readOnly: confirmedListTextFields[step.id]?.[key],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<>
<Typography>{t('right_panel.messages.list_selected')}</Typography>
{Object.entries(step.fields).map(([key, field]) => (
<Box key={key}>
<TextField
label={t('right_panel.fields.field_label')}
value={field.label || ''}
onChange={(e) => handleTextLabelChange(field.id, e.target.value, step.id, key)}
fullWidth
margin="normal"
InputProps={{
readOnly: confirmedListTextFields[field.id]?.[key],
startAdornment: (
<InputAdornment position="start">
<EditIcon />
</InputAdornment>
)
}}
/>
<TextField
label={t('right_panel.fields.field_data')}
value={field.data || ''}
fullWidth
margin="normal"
InputProps={{
readOnly: true,
startAdornment: (
<InputAdornment position="start">
<TextFieldsIcon />
</InputAdornment>
)
}}
/>
{!confirmedListTextFields[step.id]?.[key] && (
<Box display="flex" justifyContent="space-between" gap={2}>
<Button
variant="contained"
onClick={() => handleListTextFieldConfirm(step.id, key)}
disabled={!field.label?.trim()}
>
{t('right_panel.buttons.confirm')}
</Button>
<Button
variant="contained"
color="error"
onClick={() => handleListTextFieldDiscard(step.id, key)}
>
{t('right_panel.buttons.discard')}
</Button>
</Box>
)}
</Box>
))}
</>
<>
<Typography>{t('right_panel.messages.list_selected')}</Typography>
{Object.entries(step.fields).map(([key, field]) => (
<Box key={key}>
<TextField
label={t('right_panel.fields.field_label')}
value={field.label || ''}
onChange={(e) => handleTextLabelChange(field.id, e.target.value, step.id, key)}
fullWidth
margin="normal"
InputProps={{
readOnly: confirmedListTextFields[step.id]?.[key],
startAdornment: (
<InputAdornment position="start">
<EditIcon />
</InputAdornment>
)
}}
/>
<TextField
label={t('right_panel.fields.field_data')}
value={field.data || ''}
fullWidth
margin="normal"
InputProps={{
readOnly: true,
startAdornment: (
<InputAdornment position="start">
<TextFieldsIcon />
</InputAdornment>
)
}}
/>
{!confirmedListTextFields[step.id]?.[key] && (
<Box display="flex" justifyContent="space-between" gap={2}>
<Button
variant="contained"
onClick={() => handleListTextFieldConfirm(step.id, key)}
disabled={!field.label?.trim()}
>
{t('right_panel.buttons.confirm')}
</Button>
<Button
variant="contained"
color="error"
onClick={() => handleListTextFieldDiscard(step.id, key)}
>
{t('right_panel.buttons.discard')}
</Button>
</Box>
)}
</Box>
))}
</>

@amhsirak amhsirak added the Type: Enhancement Improvements to existing features label Dec 28, 2024
Copy link
Member

@amhsirak amhsirak left a comment

Choose a reason for hiding this comment

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

@RohitR311 resolve merge conflicts

@RohitR311 RohitR311 requested a review from amhsirak January 8, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants