mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 11:38:32 +01:00
* feat(ui): Add other session handling route and modal * feat(ui): Add dedicated update route and refactor update dialog state management * feat(ui): Add local authentication route * refactor(ui): Remove LocalAuthPasswordDialog component and clean up related code * refactor(ui): Remove OtherSessionConnectedModal component * feat(ui): Add dedicated mount route and refactor mount media dialog * refactor(ui): Simplify Escape key navigation in device route * refactor(ui): Add TODO comments for future URL-based state migration * refactor(ui): Migrate settings and update routes to dedicated routes This commit introduces a comprehensive refactoring of the UI routing and state management: - Removed sidebar-based settings view - Replaced global modal state with URL-based routing - Added dedicated routes for settings, including general, security, and update sections - Simplified modal and sidebar interactions - Improved animation and transition handling using motion library - Removed deprecated components and simplified route structure * fix(ui): Add TODO comment for modal session interaction * refactor(ui): Move USB configuration to new settings setup This commit introduces several improvements to the USB configuration workflow: - Refactored USB configuration dialog component - Simplified USB config state management - Moved USB configuration to hardware settings route - Updated JSON-RPC type definitions - Cleaned up unused imports and components - Improved error handling and notifications * refactor(ui): Replace react-router-dom navigation with custom navigation hook This commit introduces a new custom navigation hook `useDeviceUiNavigation` to replace direct usage of `useNavigate` across multiple components: - Removed direct `useNavigate` imports in various components - Added `navigateTo` method from new navigation hook - Updated navigation calls in ActionBar, MountPopover, UpdateInProgressStatusCard, and other routes - Simplified navigation logic and prepared for potential future navigation enhancements - Removed console logs and unnecessary comments * refactor(ui): Remove unused react-router-dom import Clean up unnecessary import of `useNavigate` from react-router-dom in device settings route * feat(ui): Improve mobile navigation and scrolling in device settings * refactor(ui): Reorganize device access and security settings This commit introduces several changes to the device access and security settings: - Renamed "Security" section to "Access" in settings navigation - Moved local authentication routes from security to access - Removed deprecated security settings route - Added new route for device access settings with cloud and local authentication management - Updated cloud URL and adoption logic to be part of the access settings - Simplified routing and component structure for better user experience * fix(ui): Update logout button hover state color * fix(ui): Adjust device de-registration button size to small * fix(ui): Update appearance settings section header and description * refactor(ui): Replace SectionHeader with new SettingsPageHeader and SettingsSectionHeader components This commit introduces two new header components for settings pages: - Created SettingsPageHeader for main page headers - Created SettingsSectionHeader for subsection headers - Replaced all existing SectionHeader imports with new components - Updated styling and type definitions to support more flexible header rendering * feat(ui): Add dev channel toggle to advanced settings Move dev channel update option from general settings to advanced settings - Introduced new state and handler for dev channel toggle - Removed dev channel option from general settings route - Added dev channel toggle in advanced settings with error handling
104 lines
2.9 KiB
TypeScript
104 lines
2.9 KiB
TypeScript
import React from "react";
|
|
import FieldLabel from "@/components/FieldLabel";
|
|
import clsx from "clsx";
|
|
import Card from "./Card";
|
|
import { cva } from "@/cva.config";
|
|
|
|
type SelectMenuProps = Pick<
|
|
JSX.IntrinsicElements["select"],
|
|
"disabled" | "onChange" | "name" | "value"
|
|
> & {
|
|
defaultSelection?: string;
|
|
className?: string;
|
|
options: {
|
|
label: string;
|
|
value: string;
|
|
disabled?: boolean;
|
|
}[];
|
|
size?: keyof typeof sizes;
|
|
direction?: "vertical" | "horizontal";
|
|
error?: string;
|
|
fullWidth?: boolean;
|
|
} & Partial<React.ComponentProps<typeof FieldLabel>>;
|
|
|
|
const sizes = {
|
|
XS: "h-[24.5px] pl-3 pr-8 text-xs",
|
|
SM: "h-[32px] pl-3 pr-8 text-[13px]",
|
|
MD: "h-[40px] pl-4 pr-10 text-sm",
|
|
LG: "h-[48px] pl-4 pr-10 px-5 text-base",
|
|
};
|
|
|
|
const selectMenuVariants = cva({
|
|
variants: { size: sizes },
|
|
});
|
|
|
|
export const SelectMenuBasic = React.forwardRef<HTMLSelectElement, SelectMenuProps>(
|
|
function SelectMenuBasic(
|
|
{
|
|
fullWidth,
|
|
options,
|
|
className,
|
|
direction = "vertical",
|
|
label,
|
|
size = "MD",
|
|
name,
|
|
disabled,
|
|
value,
|
|
id,
|
|
onChange,
|
|
},
|
|
ref,
|
|
) {
|
|
const classes = selectMenuVariants({ size });
|
|
return (
|
|
<div
|
|
className={clsx(
|
|
direction === "vertical" ? "space-y-1" : "flex items-center gap-x-2",
|
|
fullWidth ? "w-full" : "w-auto",
|
|
className,
|
|
"text-sm",
|
|
)}
|
|
>
|
|
{label && <FieldLabel label={label} id={id} as="span" />}
|
|
<Card className="w-auto !border border-solid !border-slate-800/30 shadow outline-0 dark:!border-slate-300/30">
|
|
<select
|
|
ref={ref}
|
|
name={name}
|
|
disabled={disabled}
|
|
className={clsx(
|
|
classes,
|
|
|
|
// General styling
|
|
"block w-full cursor-pointer rounded border-none py-0 font-medium shadow-none outline-0 transition duration-300",
|
|
|
|
// Hover
|
|
"hover:bg-blue-50/80 active:bg-blue-100/60 disabled:hover:bg-white",
|
|
|
|
// Dark mode
|
|
"dark:bg-slate-800 dark:text-white dark:hover:bg-slate-700 dark:active:bg-slate-800/60 dark:disabled:hover:bg-slate-800",
|
|
|
|
// Invalid
|
|
"invalid:ring-2 invalid:ring-red-600 invalid:ring-offset-2",
|
|
|
|
// Focus
|
|
"focus:outline-blue-600 focus:ring-2 focus:ring-blue-700 focus:ring-offset-2 dark:focus:outline-blue-500 dark:focus:ring-blue-500",
|
|
|
|
// Disabled
|
|
"disabled:pointer-events-none disabled:select-none disabled:bg-slate-50 disabled:text-slate-500/80 dark:disabled:bg-slate-800 dark:disabled:text-slate-400/80",
|
|
)}
|
|
value={value}
|
|
id={id}
|
|
onChange={onChange}
|
|
>
|
|
{options.map(x => (
|
|
<option key={x.value} value={x.value} disabled={x.disabled}>
|
|
{x.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</Card>
|
|
</div>
|
|
);
|
|
},
|
|
);
|