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

Dialog template back. Added test to check dialog title is shown #197

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

jinek
Copy link
Owner

@jinek jinek commented Dec 8, 2024

No description provided.

Added test to check dialog title is shown
@jinek jinek linked an issue Dec 8, 2024 that may be closed by this pull request
@jinek jinek added the bug Something isn't working label Dec 8, 2024
@jinek jinek requested a review from tomlm December 8, 2024 17:14
Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

📝 Walkthrough

Walkthrough

This pull request introduces several changes across multiple files related to the DialogWindow component in the Consolonia project. In SomeDialogWindow.axaml, the Title attribute of the DialogWindow element has been removed, which means the dialog will no longer display a title in its title bar. In the accompanying code-behind file SomeDialogWindow.axaml.cs, a new constant DialogTitle is defined and assigned the value "Dialog popup," which is then used to set the title of the SomeDialogWindow instance during its construction.

The AllControls.axaml file has been modified to change how the DialogWindow resource is included, moving from a merged dictionary inclusion to a direct style inclusion. Additionally, the DialogWindow.axaml file has undergone structural changes, with the root element changed from <ResourceDictionary> to <Styles>, and various properties of the dialog window are now encapsulated within a <Style> element. Finally, a new assertion related to the dialog title has been added to the DialogTests.cs file to ensure the title is displayed correctly during tests.

Possibly related PRs

  • Add Italic, strikethrough and fix line draw bug  #133: This PR introduces support for italic and strikethrough text, which relates to the changes in SomeDialogWindow.axaml.cs where the DialogTitle constant is used to set the title of the dialog window. The modifications in both PRs involve text presentation and formatting, indicating a connection in how text elements are handled in the UI.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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 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
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (3)
src/Tests/Consolonia.Gallery.Tests/DialogTests.cs (1)

20-20: LGTM! Consider adding a descriptive comment.

The new assertion correctly verifies that the dialog title is shown. To improve test readability, consider adding a comment explaining the test flow: navigation -> dialog open -> title verification -> dialog close.

            await UITest.KeyInput(Key.Tab);
            await UITest.KeyInput(Key.Enter);
            await UITest.KeyInput(Key.Tab);
            await UITest.AssertHasText("One More");
+           // Verify dialog title is shown
            await UITest.AssertHasText(SomeDialogWindow.DialogTitle);
            await UITest.KeyInput(Key.Escape);
src/Consolonia.Themes/Templates/Controls/DialogWindow.axaml (2)

1-8: LGTM! Good architectural improvement

The change from ResourceDictionary to Styles as the root element is a better architectural choice for control templates, following Avalonia's recommended patterns for control styling.


Line range hint 97-104: Consider using a resource for content margins

The content presenter's margin values (2,1,2,1) are hardcoded. Consider moving these to a resource for better maintainability and consistency.

+    <Styles.Resources>
+        <Thickness x:Key="ConsoloniaDialogWindowContentMargin">2,1,2,1</Thickness>
+    </Styles.Resources>
-        <Panel Margin="2,1,2,1">
+        <Panel Margin="{DynamicResource ConsoloniaDialogWindowContentMargin}">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 62b0f1b and 0738aea.

📒 Files selected for processing (5)
  • src/Consolonia.Gallery/Gallery/GalleryViews/SomeDialogWindow.axaml (0 hunks)
  • src/Consolonia.Gallery/Gallery/GalleryViews/SomeDialogWindow.axaml.cs (1 hunks)
  • src/Consolonia.Themes/Templates/Controls/AllControls.axaml (1 hunks)
  • src/Consolonia.Themes/Templates/Controls/DialogWindow.axaml (2 hunks)
  • src/Tests/Consolonia.Gallery.Tests/DialogTests.cs (2 hunks)
💤 Files with no reviewable changes (1)
  • src/Consolonia.Gallery/Gallery/GalleryViews/SomeDialogWindow.axaml
🔇 Additional comments (4)
src/Consolonia.Gallery/Gallery/GalleryViews/SomeDialogWindow.axaml.cs (1)

10-11: LGTM! Clean implementation of dialog title.

Good use of a constant for the dialog title, making it reusable across the class and tests while maintaining encapsulation with the internal modifier.

Also applies to: 17-17

src/Consolonia.Themes/Templates/Controls/AllControls.axaml (1)

46-46: Verify impact on other dialog windows.

The change from MergeResourceInclude to StyleInclude aligns with the template structure. However, let's verify this doesn't affect other dialog windows in the codebase.

✅ Verification successful

Change from MergeResourceInclude to StyleInclude is correct and safe

The verification confirms this change is appropriate because:

  1. The DialogWindow.axaml file contains Styles as its root element, making StyleInclude the correct inclusion method
  2. Other dialog windows (SomeDialogWindow.axaml) reference DialogWindow as a control, not as a resource
  3. TurboVisionDark theme extends the base DialogWindow style properly using ControlTheme
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other dialog window implementations that might be affected
rg -l "DialogWindow" --type xaml

Length of output: 61


Script:

#!/bin/bash
# Search for dialog window files and usages with regular extension
rg -l "DialogWindow" --type xml

# Find all XAML files in the repository
fd -e axaml

Length of output: 5588


Script:

#!/bin/bash
# Let's check the content of relevant dialog-related files
cat src/Consolonia.Core/Controls/Dialog/DialogWrap.axaml
cat src/Consolonia.Gallery/Gallery/GalleryViews/SomeDialogWindow.axaml
cat src/Consolonia.Themes/Templates/Controls/DialogWindow.axaml
cat src/Consolonia.Themes/TurboVisionDark/Controls/DialogWindow.axaml

Length of output: 9480

src/Consolonia.Themes/Templates/Controls/DialogWindow.axaml (2)

Line range hint 23-47: LGTM! Well-structured visual implementation

The layered approach using multiple panels with proper z-indexing creates a clean console-style UI. The consistent use of ConsoloniaDialogWindowBorderMargin resource ensures uniform spacing.


Line range hint 76-81: Verify title binding with programmatic title setting

The template correctly binds to the Title property, but let's verify it works with the programmatic title setting mentioned in the PR summary.

✅ Verification successful

Let me gather more information about the title binding implementation in the template.


Title binding implementation is correctly configured and working

The verification confirms that:

  • The template correctly binds to Title using {TemplateBinding Title} in the TextBlock
  • The sample dialog (SomeDialogWindow) demonstrates proper programmatic title setting
  • The title appears in a StackPanel alongside the icon with appropriate layout
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Title property usage in dialog windows
rg -t cs "Title\s*=\s*DialogTitle" --type-add "cs:*.{cs,axaml}"

# Search for any other title-related bindings
rg -t cs "Title\s*=\s*" --type-add "cs:*.{cs,axaml}" -g "**/*DialogWindow*.{cs,axaml}"

Length of output: 490


Script:

#!/bin/bash
# Search for Title property in DialogWindow template
rg -t cs "Title" -A 5 -B 5 src/Consolonia.Themes/Templates/Controls/DialogWindow.axaml

# Search for title-related properties in DialogWindow class
ast-grep --pattern 'class DialogWindow {
  $$$
  Title
  $$$
}'

Length of output: 908

@jinek jinek enabled auto-merge (squash) December 8, 2024 17:20
@jinek jinek merged commit c28d793 into main Dec 8, 2024
3 checks passed
@jinek jinek deleted the 186-dialog-is-broken branch December 8, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dialog is broken
2 participants