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

Redesign Admin Settings #308

Merged
merged 4 commits into from
Feb 6, 2025
Merged

Conversation

iammajid
Copy link
Contributor

@iammajid iammajid commented Feb 3, 2025

The layout of the Admin Settings page has been updated to improve usability and scalability as new features are added. Previously, labels were placed above the input fields, but they have now been moved to the left and aligned to the right. This adjustment creates more space for additional descriptions above or below the labels and allows error messages to be displayed more clearly without cluttering the UI.

Since the Admin Settings will continue to grow, this redesign ensures a more structured and readable layout, making future adjustments easier. No functionality has been changed, only the UI layout has been updated.

Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

This pull request updates the front-end components by restructuring the AdminSettings component and refining its layout and interactions. The component's template is reorganized with a streamlined grid layout that improves the display of server and license information. Input fields for parameters such as wotMaxDepth and wotIdVerifyLen now include enhanced error handling and clearer labels, providing more user-friendly feedback. The form submission area has been adjusted to deliver better save operation feedback. Additionally, the component’s icon import list has been updated to include the new ArrowRightIcon.

The internationalization files for both English and German have also been updated. A new translation entry for the Web of Trust section has been added, while specific existing entries related to detailed Web of Trust information have been removed, replaced with a general prompt ("Learn more." / "Erfahre mehr."), consolidating the guidance provided to users.

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

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.

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

🧹 Nitpick comments (2)
frontend/src/components/AdminSettings.vue (2)

233-238: Consider improving error message positioning.

The current absolute positioning with transforms might cause layout shifts and potential visibility issues in narrow viewports.

Consider this alternative approach:

-    <div v-if="wotMaxDepthError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%]">
-      <div class="bg-red-50 border border-red-300 text-red-900 px-2 py-1 rounded shadow-sm text-sm whitespace-nowrap">
-        {{ t('admin.webOfTrust.wotMaxDepth.error') }}
-        <div class="absolute bottom-0 left-1/2 transform translate-y-1/2 rotate-45 w-2 h-2 bg-red-50 border-r border-b border-red-300"></div>
-      </div>
-    </div>
+    <div v-if="wotMaxDepthError" class="mt-1 text-sm text-red-900">
+      {{ t('admin.webOfTrust.wotMaxDepth.error') }}
+    </div>

Also applies to: 257-262


322-326: Consider consolidating error states.

Multiple separate error ref variables could be combined into a single error state object for better maintainability.

Consider this approach:

-const onFetchError = ref<Error | null>();
-const errorOnFetchingUpdates = ref<boolean>(false);
-const onSaveError = ref<Error | null>(null);
-const wotMaxDepthError = ref<Error | null >(null);
-const wotIdVerifyLenError = ref<Error | null >(null);
+interface ErrorState {
+  fetch?: Error;
+  fetchingUpdates: boolean;
+  save?: Error;
+  wotMaxDepth?: Error;
+  wotIdVerifyLen?: Error;
+}
+const errors = ref<ErrorState>({
+  fetchingUpdates: false
+});
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12ac28e and 95b9561.

📒 Files selected for processing (3)
  • frontend/src/components/AdminSettings.vue (3 hunks)
  • frontend/src/i18n/de-DE.json (1 hunks)
  • frontend/src/i18n/en-US.json (1 hunks)
🔇 Additional comments (4)
frontend/src/components/AdminSettings.vue (2)

20-80: Well-structured server info section with improved layout!

The new grid layout with right-aligned labels and clear visual hierarchy improves readability and maintainability.


83-213: Consistent layout application in license info section!

The section maintains design consistency with the server info section while effectively handling different license states.

frontend/src/i18n/en-US.json (1)

57-57: Good consolidation of information links!

Simplifying multiple "Learn more" strings into a single, reusable translation improves maintainability.

frontend/src/i18n/de-DE.json (1)

57-57: Consistent translation changes!

The German translation changes mirror the English changes, maintaining language consistency.

Copy link
Member

@overheadhunter overheadhunter left a comment

Choose a reason for hiding this comment

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

Looks very neat!

Found just one cosmetic problem and a minor HTML structure issue

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

🧹 Nitpick comments (2)
frontend/src/components/AdminSettings.vue (2)

231-236: Consider improving error message positioning to prevent layout shifts.

The absolute positioning of error messages above input fields might cause content jumps when errors appear/disappear. Consider using a fixed-height container or positioning messages below the inputs to maintain layout stability.

-                    <div v-if="wotMaxDepthError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%]">
-                      <div class="bg-red-50 border border-red-300 text-red-900 px-2 py-1 rounded shadow-sm text-sm whitespace-nowrap">
-                        {{ t('admin.webOfTrust.wotMaxDepth.error') }}
-                        <div class="absolute bottom-0 left-1/2 transform translate-y-1/2 rotate-45 w-2 h-2 bg-red-50 border-r border-b border-red-300"></div>
-                      </div>
-                    </div>
+                    <div v-if="wotMaxDepthError" class="mt-2">
+                      <div class="bg-red-50 border border-red-300 text-red-900 px-2 py-1 rounded shadow-sm text-sm">
+                        {{ t('admin.webOfTrust.wotMaxDepth.error') }}
+                      </div>
+                    </div>

412-420: Enhance form validation logic.

The validation logic could be more robust:

  1. Consider validating wotIdVerifyLen against a maximum value like wotMaxDepth.
  2. Add type validation to ensure inputs are integers.
   if (!form.value?.checkValidity()) {
-    if (wotMaxDepth.value < 0 || wotMaxDepth.value > 9) {
+    if (!Number.isInteger(wotMaxDepth.value) || wotMaxDepth.value < 0 || wotMaxDepth.value > 9) {
       wotMaxDepthError.value = new FormValidationFailedError();
     }
-    if (wotIdVerifyLen.value < 0) {
+    if (!Number.isInteger(wotIdVerifyLen.value) || wotIdVerifyLen.value < 0 || wotIdVerifyLen.value > 9) {
       wotIdVerifyLenError.value = new FormValidationFailedError();
     }
     return;
   }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95b9561 and 1294c50.

📒 Files selected for processing (1)
  • frontend/src/components/AdminSettings.vue (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (1)
frontend/src/components/AdminSettings.vue (1)

18-27: LGTM! Well-structured layout with semantic HTML.

The layout implementation follows best practices with:

  • Proper semantic HTML using form elements
  • Consistent spacing and grid layout
  • Clear section headings and descriptions
  • Accessible form controls with proper labeling

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

🧹 Nitpick comments (3)
frontend/src/components/AdminSettings.vue (3)

226-232: Enhance accessibility for error messages.

While the error handling is well-implemented, consider adding ARIA attributes to improve accessibility for screen readers.

Add these attributes to the error message containers:

-<div v-if="wotMaxDepthError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%]">
+<div v-if="wotMaxDepthError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%]" role="alert" aria-live="polite">
-<div v-if="wotIdVerifyLenError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%]">
+<div v-if="wotIdVerifyLenError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%]" role="alert" aria-live="polite">

Also applies to: 249-255


399-431: Consider debouncing form submission.

While the form submission handling is well-implemented, it could benefit from debouncing to prevent rapid consecutive submissions.

Consider wrapping the save function with debounce:

-async function saveWebOfTrust() {
+const saveWebOfTrust = debounce(async function() {
   // ... existing implementation ...
-}
+}, 500);

312-312: Strengthen TypeScript typing for form ref.

Consider using a more specific type for the form ref to improve type safety.

-const form = ref<HTMLFormElement>();
+const form = ref<HTMLFormElement & { checkValidity: () => boolean }>();
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1294c50 and 8970e2c.

📒 Files selected for processing (1)
  • frontend/src/components/AdminSettings.vue (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (1)
frontend/src/components/AdminSettings.vue (1)

19-25: Well-structured layout with semantic HTML!

The use of semantic <section> tags with consistent headers and descriptions improves accessibility and maintainability. The layout changes align perfectly with the PR objectives.

Also applies to: 81-87, 157-166, 211-217

and improved responsiveness for `md`
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: 0

🧹 Nitpick comments (3)
frontend/src/components/AdminSettings.vue (3)

207-213: Enhance form validation accessibility.

Consider adding ARIA attributes to improve accessibility of error states:

-              <input id="wotMaxDepth" v-model="wotMaxDepth" type="number" min="0" max="9" step="1" class="focus:ring-primary focus:border-primary block w-full shadow-xs sm:text-sm border-gray-300 rounded-md disabled:bg-gray-200" :class="{ 'border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500': wotMaxDepthError instanceof FormValidationFailedError }"/>
+              <input id="wotMaxDepth" v-model="wotMaxDepth" type="number" min="0" max="9" step="1" class="focus:ring-primary focus:border-primary block w-full shadow-xs sm:text-sm border-gray-300 rounded-md disabled:bg-gray-200" :class="{ 'border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500': wotMaxDepthError instanceof FormValidationFailedError }" :aria-invalid="wotMaxDepthError ? 'true' : 'false'" :aria-errormessage="wotMaxDepthError ? 'wotMaxDepth-error' : undefined"/>
-              <div v-if="wotMaxDepthError" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%] w-5/6">
+              <div v-if="wotMaxDepthError" id="wotMaxDepth-error" role="alert" class="absolute left-1/2 -translate-x-1/2 -top-2 transform translate-y-[-100%] w-5/6">

Also applies to: 229-235


248-251: Enhance save button UX.

Consider adding a loading spinner and debouncing the save operation:

-              <button type="submit" :disabled="processing" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary hover:bg-primary-d1 focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-primary disabled:opacity-50 disabled:hover:bg-primary disabled:cursor-not-allowed">
-                <span v-if="!wotUpdated">{{ t('admin.webOfTrust.save') }}</span>
-                <span v-else>{{ t('admin.webOfTrust.saved') }}</span>
+              <button type="submit" :disabled="processing" class="inline-flex items-center justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary hover:bg-primary-d1 focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-primary disabled:opacity-50 disabled:hover:bg-primary disabled:cursor-not-allowed">
+                <span v-if="processing" class="inline-flex items-center">
+                  <svg class="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
+                    <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
+                    <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
+                  </svg>
+                  {{ t('common.saving') }}
+                </span>
+                <span v-else-if="!wotUpdated">{{ t('admin.webOfTrust.save') }}</span>
+                <span v-else>{{ t('admin.webOfTrust.saved') }}</span>
+              </button>

298-302: Improve type safety in error handling.

Consider creating a more robust error handling system:

+interface ValidationError {
+  code: string;
+  message: string;
+}
+
 class FormValidationFailedError extends Error {
+  readonly code: string;
+
   constructor() {
     super('The form is invalid.');
+    this.code = 'FORM_VALIDATION_FAILED';
   }
 }

-    onSaveError.value = error instanceof Error ? error : new Error('Unknown reason');
+    onSaveError.value = error instanceof Error ? error : new Error('UNKNOWN_ERROR');

Also applies to: 404-405

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8970e2c and a539232.

📒 Files selected for processing (1)
  • frontend/src/components/AdminSettings.vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (1)
frontend/src/components/AdminSettings.vue (1)

19-73: Well-structured layout with improved accessibility!

The implementation demonstrates excellent practices:

  • Consistent grid-based layout with right-aligned labels
  • Proper use of semantic HTML elements
  • Clear visual hierarchy with section headers and descriptions

Also applies to: 75-141, 143-191, 193-258

@overheadhunter overheadhunter added this to the 1.4.0 milestone Feb 6, 2025
@overheadhunter overheadhunter merged commit ad07aa1 into develop Feb 6, 2025
6 checks passed
@SailReal SailReal deleted the feature/admin-settings-redesign branch February 6, 2025 22:53
@iammajid iammajid self-assigned this Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants