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 a tab menu for settings on new navigation page #14849

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mlqn
Copy link
Contributor

@mlqn mlqn commented Mar 3, 2025

Description

  • Add a tab menu for settings on new navigation page

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)

Summary by CodeRabbit

  • New Features
    • Added localized labels for settings sections ("Datamodell", "Navigasjon", and "Andre innstillinger") to enhance clarity.
    • Introduced a tabbed interface in the settings view, making it easier to navigate different configuration areas.
    • Updated visual elements for headings and icons, creating a more polished and cohesive user experience.
    • Integrated a work-in-progress message for future content in the settings tabs.

@mlqn mlqn linked an issue Mar 3, 2025 that may be closed by this pull request
3 tasks
Copy link
Contributor

coderabbitai bot commented Mar 3, 2025

Warning

Rate limit exceeded

@mlqn has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9d7110c and a9eed42.

📒 Files selected for processing (2)
  • frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css (1 hunks)
  • frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (1 hunks)
📝 Walkthrough

Walkthrough

This pull request introduces four new localization key-value pairs in the Norwegian language file, adds a new CSS module for styling settings tabs, and creates a new React component named SettingsTabs that utilizes internationalization for tab labels and icons. The SettingsTabs component is integrated into the FormDesignerNavigation component.

Changes

File(s) Change Summary
frontend/language/.../nb.json Added four new key-value pairs under ux_editor.settings: "data_model_tab": "Datamodell", "navigation_tab": "Navigasjon", "other_settings": "Andre innstillinger", and "wip_message": "Denne fanen er under utvikling - innhold kommer snart.".
frontend/.../SettingsTabs.module.css Introduced a new CSS module defining .heading, .icon, and .wipMessage classes.
frontend/.../SettingsTabs.tsx Created a new SettingsTabs React component utilizing react-i18next for translations and rendering tab icons.
frontend/.../FormDesignerNavigation.tsx Integrated the SettingsTabs component into the FormDesignerNavigation layout.

Possibly related PRs

Suggested labels

kind/feature-request, text/content

Suggested reviewers

  • Jondyr
  • Ildest

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.
  • @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. frontend labels Mar 3, 2025
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.79%. Comparing base (8fec646) to head (a9eed42).
Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14849   +/-   ##
=======================================
  Coverage   95.79%   95.79%           
=======================================
  Files        1924     1925    +1     
  Lines       25107    25117   +10     
  Branches     2869     2869           
=======================================
+ Hits        24050    24060   +10     
  Misses        797      797           
  Partials      260      260           

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

@mlqn mlqn marked this pull request as ready for review March 3, 2025 11:58
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/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (1)

8-17: Consider adding type definitions for the tabs array.

Adding explicit type definitions would improve code maintainability and type safety.

-const tabs = [
+interface Tab {
+  icon: React.FC<React.SVGProps<SVGSVGElement>>;
+  title: string;
+}
+
+const tabs: Tab[] = [
  {
    icon: CompassIcon,
    title: 'ux_editor.settings.navigation_tab',
  },
  {
    icon: DatabaseIcon,
    title: 'ux_editor.settings.data_model_tab',
  },
];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dbc9d5f and 57aa377.

📒 Files selected for processing (4)
  • frontend/language/src/nb.json (1 hunks)
  • frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css (1 hunks)
  • frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (1 hunks)
  • frontend/packages/ux-editor/src/containers/FormDesignNavigation/FormDesignerNavigation.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css
⏰ 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/packages/ux-editor/src/containers/FormDesignNavigation/FormDesignerNavigation.tsx (2)

7-7: LGTM! Clean import of the new SettingsTabs component.

The import path is correct and follows the project's convention for relative imports.


19-19: LGTM! SettingsTabs component is properly integrated.

The component is appropriately placed inside the content div, aligning with the UI structure.

frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (2)

1-7: LGTM! Proper imports and dependencies.

All necessary imports are included for the component, with appropriate type definitions and styling.


19-42: Tab content panels are missing.

The component creates tabs but doesn't include any StudioTabs.Panel elements to display content when tabs are selected. This suggests the implementation may be incomplete.

Is this intentional, with tab content to be added in a future PR? If not, consider adding panel content similar to:

<StudioTabs defaultValue={tabs[0].title}>
  <StudioTabs.List>
    {/* existing tab code */}
  </StudioTabs.List>
  
  {tabs.map((tab) => (
    <StudioTabs.Panel key={tab.title} value={tab.title}>
      {/* Content for ${tab.title} */}
    </StudioTabs.Panel>
  ))}
</StudioTabs>
frontend/language/src/nb.json (1)

1916-1918: LGTM! New translation keys match component usage.

The translation keys are properly structured under the ux_editor.settings namespace and provide appropriate Norwegian translations for the tab labels and heading.

Copy link
Contributor

@JamalAlabdullah JamalAlabdullah left a comment

Choose a reason for hiding this comment

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

Good job! It works well. We might be missing a test file for the SettingsTabs component.?

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 (5)
frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (5)

1-7: Imports are well-organized but could be grouped by type.

The imports are properly structured, but it's considered a best practice to group imports by type (React core, external libraries, internal components, styles, etc.) for better readability.

Consider organizing imports in this order:

import type { ReactElement } from 'react';
import React from 'react';
+
import { useTranslation } from 'react-i18next';
import { StudioAlert, StudioHeading, StudioTabs } from '@studio/components';
import { CompassIcon, DatabaseIcon } from '@studio/icons';
+
import classes from './SettingsTabs.module.css';

13-15: Component lacks documentation.

The component is missing JSDoc documentation that would explain its purpose, props, and usage, which would be helpful for other developers.

Add JSDoc documentation to the component:

+/**
+ * SettingsTabs component provides a tabbed interface for accessing different settings
+ * categories within the UX editor. Currently includes Navigation and Database settings.
+ *
+ * @returns {ReactElement} A React element containing the settings tabs interface
+ */
export const SettingsTabs = (): ReactElement => {
  const { t } = useTranslation();

21-31: Enhance accessibility for the tab component.

The tabs implementation could benefit from accessibility improvements like aria-labels for better screen reader support.

-      <StudioTabs defaultValue={Tabs.Navigation}>
+      <StudioTabs 
+        defaultValue={Tabs.Navigation} 
+        aria-label={t('ux_editor.settings.tabs_aria_label')}
+      >
        <StudioTabs.List>
          <StudioTabs.Tab value={Tabs.Navigation}>
            <CompassIcon className={classes.icon} />
            {t('ux_editor.settings.navigation_tab')}
          </StudioTabs.Tab>
          <StudioTabs.Tab value={Tabs.Database}>
            <DatabaseIcon className={classes.icon} />
            {t('ux_editor.settings.data_model_tab')}
          </StudioTabs.Tab>
        </StudioTabs.List>

Note: You'll need to add a new translation key 'ux_editor.settings.tabs_aria_label' in your language files.


32-37: Placeholder content could be more descriptive.

Both tabs currently display the same generic work-in-progress message. Consider adding more context-specific information about what each tab will eventually contain.

        <StudioTabs.Content value={Tabs.Navigation}>
-          <StudioAlert severity='info'>{t('ux_editor.settings.wip_message')}</StudioAlert>
+          <StudioAlert severity='info'>
+            {t('ux_editor.settings.navigation_wip_message')}
+          </StudioAlert>
        </StudioTabs.Content>
        <StudioTabs.Content value={Tabs.Database}>
-          <StudioAlert severity='info'>{t('ux_editor.settings.wip_message')}</StudioAlert>
+          <StudioAlert severity='info'>
+            {t('ux_editor.settings.database_wip_message')}
+          </StudioAlert>
        </StudioTabs.Content>

Note: You'll need to add new translation keys 'ux_editor.settings.navigation_wip_message' and 'ux_editor.settings.database_wip_message' with more specific messages.


16-40: Consider adding state persistence for tab selection.

The component doesn't maintain the selected tab state when the component re-renders. Adding state management would improve the user experience by remembering their tab selection.

import type { ReactElement } from 'react';
-import React from 'react';
+import React, { useState } from 'react';
import { StudioAlert, StudioHeading, StudioTabs } from '@studio/components';
import { useTranslation } from 'react-i18next';
import classes from './SettingsTabs.module.css';
import { CompassIcon, DatabaseIcon } from '@studio/icons';

enum Tabs {
  Navigation = 'navigation',
  Database = 'database',
}

export const SettingsTabs = (): ReactElement => {
  const { t } = useTranslation();
+  const [activeTab, setActiveTab] = useState<Tabs>(Tabs.Navigation);
+
+  const handleTabChange = (value: string) => {
+    setActiveTab(value as Tabs);
+  };

  return (
    <div>
      <StudioHeading level={2} size='xsmall' className={classes.heading}>
        {t('ux_editor.settings.other_settings')}
      </StudioHeading>
-      <StudioTabs defaultValue={Tabs.Navigation}>
+      <StudioTabs value={activeTab} onValueChange={handleTabChange}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 57aa377 and f10b74d.

📒 Files selected for processing (2)
  • frontend/language/src/nb.json (1 hunks)
  • frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/language/src/nb.json
⏰ 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 (3)
frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (3)

8-11: Good use of enum for tab values.

Using an enum for tab values provides type safety and makes the code more maintainable. This is a good practice for defining constant values in TypeScript.


5-5:

✅ Verification successful

Verify if CSS module file exists.

The component imports a CSS module file, but it's important to ensure this file exists and contains the necessary style classes referenced in the component.


🏁 Script executed:

#!/bin/bash
# Description: Check if the CSS module file exists and contains referenced classes

# Check if the module file exists
if [ -f "frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css" ]; then
  echo "CSS module file exists."
  
  # Check for the classes referenced in the component
  grep -q "\.heading" frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css && \
  echo "heading class found." || echo "WARNING: heading class not found in CSS module."
  
  grep -q "\.icon" frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css && \
  echo "icon class found." || echo "WARNING: icon class not found in CSS module."
else
  echo "WARNING: CSS module file not found: frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css"
fi

Length of output: 434


CSS Module Verification Successful:
The CSS module file frontend/packages/ux-editor/src/components/Settings/SettingsTabs.module.css exists and contains the required .heading and .icon classes as referenced in the component. No further action is necessary.


3-3:

❓ Verification inconclusive

Verify if all Studio components are being used.

The StudioAlert component is imported from @studio/components, but it might be better to use a more specific component for work-in-progress messages if available in your design system.


🏁 Script executed:

#!/bin/bash
# Description: Check if there are more appropriate notification components in the design system

# Look for any notification or banner components that might be more suitable for WIP messages
fd --type f ".*\.(tsx|ts)" --exec grep -l "export.*Studio.*Banner\|export.*Studio.*Notification" {} \; --exclude "*test*" | sort

Length of output: 133


Notification Component Usage – Manual Verification Needed

I reviewed the search results, and no alternative notification components (like a StudioNotification or StudioBanner) were found in the codebase. In the current state, using StudioAlert from @studio/components appears to be the only option available for work-in-progress messages. However, please verify manually with the design team or re-run additional checks if a more specialized component should be used.

  • File: frontend/packages/ux-editor/src/components/Settings/SettingsTabs.tsx (line 3)
  • Context: The code imports StudioAlert from @studio/components. No alternative notification components were detected in the repository.

@mlqn mlqn force-pushed the 14737-add-a-tab-menu-for-settings branch from 9d7110c to 795bc88 Compare March 4, 2025 17:46
@mlqn mlqn force-pushed the 14737-add-a-tab-menu-for-settings branch from 795bc88 to a9eed42 Compare March 4, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. frontend solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a tab menu for settings
2 participants