Browse Source

Merge pull request #17 from cadtoolbox/copilot/fix-admin-settings-menu-scroll

Fix admin settings menu scroll and user creation dialog validation for advanced auth
Thomas Rambach 3 months ago
parent
commit
bd8e4af39d

File diff suppressed because it is too large
+ 2070 - 162
frontend/package-lock.json


+ 3 - 0
frontend/package.json

@@ -17,6 +17,7 @@
     "@dnd-kit/core": "^6.3.1",
     "@dnd-kit/sortable": "^10.0.0",
     "@dnd-kit/utilities": "^3.2.2",
+    "@floating-ui/dom": "^1.7.5",
     "@tanstack/react-query": "^5.90.11",
     "@tiptap/extension-color": "^3.11.1",
     "@tiptap/extension-image": "^3.11.1",
@@ -31,8 +32,10 @@
     "i18next": "^25.6.3",
     "i18next-browser-languagedetector": "^8.2.0",
     "i18next-http-backend": "^3.0.2",
+    "install": "^0.13.0",
     "jszip": "^3.10.1",
     "lucide-react": "^0.555.0",
+    "npm": "^11.9.0",
     "react": "^19.2.0",
     "react-dom": "^19.2.0",
     "react-i18next": "^16.3.5",

+ 1 - 1
frontend/src/pages/SettingsPage.tsx

@@ -918,7 +918,7 @@ export function SettingsPage() {
       </div>
 
       {/* Tab Navigation */}
-      <div className="flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto">
+      <div className="flex flex-wrap gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-y-auto max-h-32">
         <button
           onClick={() => handleTabChange('general')}
           className={`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${

+ 22 - 2
frontend/src/pages/UsersPage.tsx

@@ -1,4 +1,4 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo } from 'react';
 import { useNavigate } from 'react-router-dom';
 import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
 import { useTranslation } from 'react-i18next';
@@ -123,6 +123,26 @@ export function UsersPage() {
     },
   });
 
+  // Validation for create user button
+  const isCreateButtonDisabled = useMemo(() => {
+    if (createMutation.isPending || !formData.username) {
+      return true;
+    }
+    if (advancedAuthStatus?.advanced_auth_enabled) {
+      // When advanced auth is enabled, require email (password is auto-generated)
+      return !formData.email;
+    }
+    // When advanced auth is disabled, require valid password
+    return !formData.password || formData.password !== formData.confirmPassword || formData.password.length < 6;
+  }, [
+    createMutation.isPending,
+    formData.username,
+    formData.email,
+    formData.password,
+    formData.confirmPassword,
+    advancedAuthStatus?.advanced_auth_enabled
+  ]);
+
   const handleCreate = () => {
     // Use the status from the query hook
     const advancedAuthEnabled = advancedAuthStatus?.advanced_auth_enabled || false;
@@ -527,7 +547,7 @@ export function UsersPage() {
                 </Button>
                 <Button
                   onClick={handleCreate}
-                  disabled={createMutation.isPending || !formData.username || !formData.password || formData.password !== formData.confirmPassword || formData.password.length < 6}
+                  disabled={isCreateButtonDisabled}
                 >
                   {createMutation.isPending ? (
                     <>

File diff suppressed because it is too large
+ 0 - 0
static/assets/index-962x7uln.css


File diff suppressed because it is too large
+ 0 - 0
static/assets/index-BXuLn30-.js


File diff suppressed because it is too large
+ 0 - 0
static/assets/index-e6thg2aZ.css


+ 2 - 2
static/index.html

@@ -23,8 +23,8 @@
 
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-DywTesim.js"></script>
-    <link rel="stylesheet" crossorigin href="/assets/index-962x7uln.css">
+    <script type="module" crossorigin src="/assets/index-BXuLn30-.js"></script>
+    <link rel="stylesheet" crossorigin href="/assets/index-e6thg2aZ.css">
   </head>
   <body>
     <div id="root"></div>

Some files were not shown because too many files changed in this diff