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

fix: place icon for StudioProperty.Button next to label #14431

Merged
merged 10 commits into from
Jan 21, 2025

Conversation

standeren
Copy link
Contributor

@standeren standeren commented Jan 16, 2025

Description

Pass icon to StudioProperty.Button directly instead of passing it as a part of the value. This is done in order to align the design consistently across StudioDisplayTile, StudioToggleableTextfield and this one.

See #14401 and #14402, respectively, for updated design of the mentioned components.

Skjermbilde 2025-01-17 kl  15 20 44

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

Release Notes

  • Style Changes

    • Updated styling for property buttons with a new grid layout.
    • Removed align-items: center from button styles.
    • Reduced bottom margin in .texts class.
    • Enhanced spacing below the .navigateSubformButton.
    • Removed several CSS classes related to button and layout styling.
  • Component Updates

    • Simplified rendering of buttons in various configuration components.
    • Removed size='small' property from multiple StudioProperty.Button instances.
    • Updated button rendering logic to directly include icons.
  • CSS Modifications

    • Deleted CSS files for unused classes, affecting layout and spacing.

@standeren standeren added quality/code Violations from current rules for code, best practices, etc. Or just bad code. skip-releasenotes Issues that do not make sense to list in our release notes frontend team/studio-domain1 team/studio-domain2 team/studio-core skip-documentation Issues where updating documentation is not relevant labels Jan 16, 2025
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-storybook".

(The package "eslint-plugin-storybook" was not found when loaded as a Node module from the directory "/frontend/libs/studio-components".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-storybook@latest --save-dev

The plugin "eslint-plugin-storybook" was referenced from the config file in "frontend/libs/studio-components/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

📝 Walkthrough

Walkthrough

The pull request encompasses modifications across multiple frontend components and CSS files, primarily focusing on styling and layout changes. The changes involve removing specific CSS classes, adjusting layout models (such as transitioning from flexbox to grid), and simplifying component rendering. The modifications reflect a shift in the layout strategy for various components, particularly concerning buttons and property-related elements.

Changes

File Change Summary
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css - Changed .propertyButton display from flex to grid
- Added new nested class .property with flex alignment and gap
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css - Removed .selectedOption class
- Removed .currentLinkedDataModel class
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx - Simplified StudioProperty.Button rendering
- Introduced icon prop
- Directly assigned currentDataModelField to value prop
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx - Added optional icon property to StudioPropertyButtonProps
- Updated logic for rendering icon
Multiple Process Editor Components (.tsx files) - Removed size='small' prop from StudioProperty.Button
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css - Removed .definedValue class
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx - Removed definedValueWithLinkIcon variable
- Simplified StudioProperty.Button rendering
frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css - Removed align-items: center; from .button class
frontend/packages/process-editor/src/components/Properties/DataModelBindings.module.css - Removed .dataModelBindings, .container, and .wrapper classes
frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/PropertiesHeader.module.css - Removed padding-bottom from .content class
frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.module.css - Removed .selectedLayoutSet class
frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.tsx - Removed className and color properties from StudioProperty.Button
frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/EditLayoutSetForSubform.module.css - Added margin-bottom to .navigateSubformButton class
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypesToSign/EditDataTypesToSign.module.css - Removed .dataType class
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypesToSign/EditDataTypesToSign.tsx - Simplified rendering of button and introduced icon prop to StudioProperty.Button
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.module.css - Removed .dataType class

Suggested labels

skip-manual-testing

Suggested reviewers

  • ErlingHauan
  • Jondyr

📜 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 e47112f and 84b2760.

📒 Files selected for processing (4)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.tsx (2 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings/EditTextResourceBindings.module.css (1 hunks)
💤 Files with no reviewable changes (1)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.module.css
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings/EditTextResourceBindings.module.css
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.tsx
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css

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

@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Jan 16, 2025
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.69%. Comparing base (9aa2d6f) to head (f56abf3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14431   +/-   ##
=======================================
  Coverage   95.68%   95.69%           
=======================================
  Files        1889     1889           
  Lines       24579    24573    -6     
  Branches     2822     2822           
=======================================
- Hits        23519    23515    -4     
  Misses        799      799           
+ Partials      261      259    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the area/process Area: Related to app process (e.g. signing, receipt, fill inn, payment, etc). label Jan 16, 2025
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

🧹 Nitpick comments (3)
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx (2)

41-41: LGTM! The condition aligns with the PR objectives.

The addition of the definedValue class when both givenIcon and hasValue are true helps achieve the goal of placing icons vertically parallel with labels and values.

However, to improve maintainability, consider extracting this condition into a descriptive variable:

+    const hasDefinedIconAndValue = givenIcon && hasValue;
     const className = cn(
       classes.propertyButton,
       hasValue && classes.withValue,
       compact && classes.compact,
       readOnly && classes.readOnly,
       withoutNegativeMargin && classes.withoutNegativeMargin,
-      givenIcon && hasValue && classes.definedValue,
+      hasDefinedIconAndValue && classes.definedValue,
       givenClass,
     );

Line range hint 9-15: Consider adding JSDoc comments to document the visual states.

Since this component is part of a design system and handles multiple visual states (with/without icon, with/without value, readonly, compact), it would be valuable to document these states and their visual implications in the component's props interface.

 export type StudioPropertyButtonProps = {
+  /** The property label to display */
   property: string;
+  /** The value to display. When present, affects icon placement and styling */
   value?: ReactNode;
+  /** Renders the button in a compact mode */
   compact?: boolean;
+  /** Renders the button in readonly mode with a padlock icon */
   readOnly?: boolean;
+  /** Removes negative margin styling */
   withoutNegativeMargin?: boolean;
 } & Omit<StudioButtonProps, 'children' | 'value'>;
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx (1)

51-57: Consider making the mode logic more explicit.

The mode prop's conditional logic could be made more explicit to better handle edge cases.

Consider this alternative:

-          mode={!actionElement.action ? 'edit' : 'view'}
+          mode={actionElement.action === undefined ? 'edit' : 'view'}

This makes the condition more explicit and helps prevent potential issues with falsy values.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 957851e and 4c15c07.

📒 Files selected for processing (12)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/ActionsEditor/ActionsEditor.module.css (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/ActionsEditor/ActionsEditor.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx (1 hunks)
💤 Files with no reviewable changes (5)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.module.css
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css
✅ Files skipped from review due to trivial changes (2)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/ActionsEditor/ActionsEditor.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/ActionsEditor/ActionsEditor.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: CodeQL
  • GitHub Check: Testing
  • GitHub Check: Typechecking and linting
🔇 Additional comments (3)
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx (1)

50-53: Clean and consistent prop organization!

The changes improve the component's structure by:

  1. Placing the icon prop consistently with other components
  2. Using a direct value prop instead of a wrapped component
  3. Maintaining good accessibility with descriptive aria-label
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx (2)

58-61: LGTM! Button styling change aligns with design standardization.

The removal of the size prop from StudioProperty.Button aligns with the PR's objective of ensuring consistent design across components.


Line range hint 1-63: Well-structured component with good practices!

The component demonstrates excellent practices:

  • Proper use of React hooks and TypeScript
  • Clear separation of concerns
  • Well-managed side effects
  • Good error handling

@standeren standeren force-pushed the align-studio-property-button_with-rest-of-design branch 3 times, most recently from be3ffd9 to fc575ba Compare January 16, 2025 12:00
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

🧹 Nitpick comments (2)
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (2)

98-129: Comprehensive error handling test coverage!

The new test cases thoroughly verify the component's error states. Consider making the test descriptions even more specific:

-  it('should render with error css class when selected data model does not exist'
+  it('should apply error css class to edit button when data model does not exist'
-  it('should render with error css class when selected data model field does not exist in model'
+  it('should apply error css class to edit button when field does not exist in data model'
-  it('should render without error css class when selected data model and field is valid'
+  it('should not apply error css class to edit button when data model and field are valid'

132-141: Consider enhancing mock data structure.

The helper function effectively sets up the test environment, but the mock data structure could be more robust.

Consider:

  1. Adding more realistic metadata fields
  2. Using a type-safe mock data structure
  3. Making the mock data structure reusable across tests

Example enhancement:

interface DataModelMetadata {
  elements: {
    [key: string]: {
      dataBindingName: string;
      maxOccurs: number;
      type?: string;
      minOccurs?: number;
      restrictions?: unknown;
    };
  };
}

const createMockMetadata = (fieldName: string): DataModelMetadata => ({
  elements: {
    [fieldName]: {
      dataBindingName: fieldName,
      maxOccurs: 0,
      type: 'string',
      minOccurs: 0,
    },
  },
});
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be3ffd9 and fc575ba.

📒 Files selected for processing (11)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx (0 hunks)
  • frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (5 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx (1 hunks)
💤 Files with no reviewable changes (6)
  • frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Testing
🔇 Additional comments (5)
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2)

3-4: LGTM! Grid layout improves icon alignment.

The switch from flexbox to grid layout with 1fr auto columns is a good choice for achieving vertical alignment between the icon and label/value. This provides more precise control over the layout.


62-64: LGTM! Semantic color usage.

Good use of the design system's semantic color variable for consistent styling.

frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (3)

9-10: LGTM! New imports are properly utilized.

The added imports for QueryKey and test IDs are necessary for the new test functionality.


18-18: Great improvements to type definitions!

  • Renaming to defaultDefinedBindingProps better reflects its purpose
  • Using Partial<DefinedBindingProps> allows for more flexible test scenarios

Also applies to: 30-30


35-41: Well-structured test utility function!

The simplified renderDefinedBinding function with default parameters and proper props spreading improves test maintainability.

@standeren standeren force-pushed the align-studio-property-button_with-rest-of-design branch from fc575ba to 85e1118 Compare January 16, 2025 12:42
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

🧹 Nitpick comments (3)
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (3)

30-30: Consider adding type safety for required props.

The changes improve flexibility for testing. However, consider adding a type assertion in renderDefinedBinding to ensure required props are always provided through the merge with defaultDefinedBindingProps.

// Add type assertion to ensure type safety
return {
  ...renderWithProviders(<DefinedBinding {...defaultDefinedBindingProps} {...props} /> as React.ReactElement<DefinedBindingProps>, {
    queries,
    queryClient,
  }),
};

Also applies to: 36-42


102-133: Consider adding snapshot tests for visual consistency.

The new test cases effectively cover error handling scenarios. To ensure visual consistency across different states, consider adding snapshot tests for:

  • Error state with non-existent model
  • Error state with non-existent field
  • Valid state

136-145: Consider adding error case handling to the helper function.

The helper function effectively encapsulates the setup logic. Consider adding error case handling to test scenarios where metadata retrieval fails.

// Add error case handling
const renderWithDataModelAndMetadata = (
  modelName: string,
  fieldName: string,
  shouldFail: boolean = false
) => {
  const queryClient = createQueryClientMock();
  queryClient.setQueryData([QueryKey.AppMetadataModelIds, org, app, false], [modelName]);
  const getDataModelMetadata = jest
    .fn()
    .mockImplementation(() =>
      shouldFail
        ? Promise.reject(new Error('Failed to fetch metadata'))
        : Promise.resolve({
            elements: { [fieldName]: { dataBindingName: fieldName, maxOccurs: 0 } },
          })
    );
  renderDefinedBinding({ queries: { getDataModelMetadata }, queryClient });
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc575ba and 85e1118.

📒 Files selected for processing (11)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx (0 hunks)
  • frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (5 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx (1 hunks)
💤 Files with no reviewable changes (6)
  • frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Typechecking and linting
  • GitHub Check: Testing
  • GitHub Check: CodeQL
🔇 Additional comments (2)
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (2)

9-10: LGTM! Clear and purposeful changes.

The variable rename to defaultDefinedBindingProps better reflects its purpose, and the new import is properly utilized.

Also applies to: 18-18


54-54: LGTM! Improved test readability.

The simplified test case calls make the code more maintainable while preserving the test coverage.

Also applies to: 64-64

@standeren standeren linked an issue Jan 16, 2025 that may be closed by this pull request
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

🧹 Nitpick comments (1)
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (1)

62-64: Consider consolidating color definitions.

The .definedValue class sets the same color as .propertyButton.withValue .content. Consider consolidating these styles to avoid duplication and maintain consistency.

-.definedValue {
-  color: var(--fds-semantic-text-neutral-default);
-}

And update the existing rule to cover both cases:

 .propertyButton.withValue .content,
+.propertyButton .definedValue {
   color: var(--fds-semantic-text-neutral-default);
   text-align: left;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 85e1118 and 2d8e46c.

📒 Files selected for processing (3)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/PropertiesHeader.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings/EditTextResourceBindings.module.css (1 hunks)
💤 Files with no reviewable changes (1)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/PropertiesHeader.module.css
✅ Files skipped from review due to trivial changes (1)
  • frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings/EditTextResourceBindings.module.css
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Testing
  • GitHub Check: CodeQL
  • GitHub Check: Typechecking and linting
🔇 Additional comments (2)
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2)

3-4: LGTM! Grid layout improves icon alignment.

The transition from flexbox to grid with 1fr auto columns ensures better vertical alignment of the icon with the label and value, which directly addresses the PR's objective.


7-7: Verify the custom property definition.

The custom property --studio-property-button-vertical-spacing is used but not defined in this file.

Let's verify its definition:

✅ Verification successful

Custom property is properly defined

The --studio-property-button-vertical-spacing property is defined in studio-variables.css and is consistently used across multiple components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the definition of the custom property
rg --type css "studio-property-button-vertical-spacing"

Length of output: 1137

@standeren standeren changed the title fix: place icon for StudioProperty.Button vertically parallel with label AND value fix: place icon for StudioProperty.Button next to label Jan 17, 2025
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

🧹 Nitpick comments (1)
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (1)

3-4: Remove redundant justify-content property.

The switch to grid layout with grid-template-columns: 1fr auto is a good choice for achieving the parallel alignment. However, justify-content: flex-start is redundant with grid layout and should be removed.

  display: grid;
  grid-template-columns: 1fr auto;
- justify-content: flex-start;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8e46c and 533540f.

📒 Files selected for processing (7)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx (2 hunks)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.module.css (1 hunks)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.tsx (1 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.tsx (0 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/EditLayoutSetForSubform.module.css (1 hunks)
💤 Files with no reviewable changes (2)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.tsx
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.module.css
✅ Files skipped from review due to trivial changes (3)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/EditLayoutSetForSubform.module.css
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.module.css
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Typechecking and linting
  • GitHub Check: CodeQL
  • GitHub Check: Testing
🔇 Additional comments (1)
frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (1)

15-19: Well-structured property class implementation!

The new .property class effectively handles the icon-label alignment using flexbox and maintains consistency with the design system through the use of --fds-spacing-1 for gap spacing.

@standeren standeren force-pushed the align-studio-property-button_with-rest-of-design branch from 8bd648f to 9291cd0 Compare January 17, 2025 14:48
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: 1

🧹 Nitpick comments (1)
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypesToSign/EditDataTypesToSign.tsx (1)

23-24: LGTM! Changes align well with the design standardization goals.

The implementation correctly moves the icon to be a direct prop of StudioProperty.Button, which aligns with the PR's objective of ensuring consistent design across components.

However, consider adding aria-label to improve accessibility:

      icon={<LinkIcon />}
+     aria-label={t('process_editor.configuration_panel_set_data_types_to_sign')}
      value={selectedDataTypes?.map((dataType: string) => <div key={dataType}>{dataType}</div>)}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8bd648f and f3d6788.

📒 Files selected for processing (21)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css (2 hunks)
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx (2 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypesToSign/EditDataTypesToSign.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypesToSign/EditDataTypesToSign.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.module.css (0 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx (0 hunks)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.module.css (1 hunks)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.tsx (1 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.tsx (0 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/EditLayoutSetForSubform.module.css (1 hunks)
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/PropertiesHeader.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (5 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx (1 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings/EditTextResourceBindings.module.css (1 hunks)
💤 Files with no reviewable changes (10)
  • frontend/packages/ux-editor/src/components/config/FormComponentConfig.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.module.css
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypesToSign/EditDataTypesToSign.module.css
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/PropertiesHeader.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditActions/EditActions.tsx
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.tsx
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/DefinedLayoutSet/DefinedLayoutSet.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.module.css
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceiptContent.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.tsx
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditUniqueFromSignaturesInDataTypes/EditUniqueFromSignaturesInDataTypes.tsx
  • frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditLayoutSetForSubform/EditLayoutSetForSubform.module.css
  • frontend/packages/ux-editor/src/components/Properties/DataModelBindings.module.css
  • frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings/EditTextResourceBindings.module.css
  • frontend/libs/studio-components/src/components/StudioProperty/StudioPropertyButton/StudioPropertyButton.module.css
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.tsx
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditDataTypes/EditDataTypes.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Testing
  • GitHub Check: Typechecking and linting
  • GitHub Check: CodeQL
  • GitHub Check: Build environment and run e2e test
🔇 Additional comments (5)
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/DefinedBinding/DefinedBinding.test.tsx (5)

9-10: LGTM!

The new imports are properly organized and used in the new test helper function.


18-18: Great improvements to type definitions!

The changes enhance the test setup by:

  1. Renaming to defaultDefinedBindingProps for better clarity
  2. Using Partial<DefinedBindingProps> to allow flexible prop overrides in tests

Also applies to: 30-30


36-44: Well-structured test helper function!

The updated renderDefinedBinding function provides a cleaner API while maintaining proper defaults through props merging.


102-133: Excellent test coverage for error scenarios!

The new test cases thoroughly verify the error handling behavior:

  1. Invalid data model
  2. Invalid field in valid model
  3. Valid model and field (happy path)

The tests are well-structured and follow good testing practices.


136-145: Please clarify the maxOccurs value.

The helper function is well-structured, but could you explain why maxOccurs: 0 was chosen in the mock data? This might be worth documenting with a comment if it's significant for the test scenarios.

@standeren standeren changed the title fix: place icon for StudioProperty.Button next to label fix: place icon for StudioProperty.Button next to label Jan 17, 2025
@TomasEng TomasEng self-assigned this Jan 20, 2025
Copy link
Contributor

@TomasEng TomasEng left a comment

Choose a reason for hiding this comment

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

Nå ble vi kvitt en del kode også, fint!

@standeren standeren assigned standeren and TomasEng and unassigned TomasEng and standeren Jan 20, 2025
@standeren standeren requested a review from TomasEng January 20, 2025 12:06
@TomasEng TomasEng assigned standeren and unassigned TomasEng Jan 20, 2025
@standeren standeren assigned TomasEng and unassigned standeren Jan 20, 2025
@TomasEng TomasEng removed their assignment Jan 20, 2025
Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

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

Test OK 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/process Area: Related to app process (e.g. signing, receipt, fill inn, payment, etc). area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. frontend quality/code Violations from current rules for code, best practices, etc. Or just bad code. skip-documentation Issues where updating documentation is not relevant skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-core team/studio-domain1 team/studio-domain2
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Improve design of Studio components
3 participants