mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-03 19:54:44 -07:00
more consistent switch, show current config name in tray icon context menu
This commit is contained in:
parent
3d62d9d00c
commit
f657b7375a
6 changed files with 30 additions and 8 deletions
11
src/components/Switch.tsx
Normal file
11
src/components/Switch.tsx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { Switch as MantineSwitch, type SwitchProps } from '@mantine/core';
|
||||
|
||||
export const Switch = (props: SwitchProps) => (
|
||||
<MantineSwitch
|
||||
{...props}
|
||||
styles={{
|
||||
track: { transition: 'none' },
|
||||
thumb: { transition: 'none' },
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
|
@ -5,6 +5,7 @@ import type { ConfigFile } from '@/types';
|
|||
import { CreateConfigModal } from './CreateConfigModal';
|
||||
import { DeleteConfigModal } from './DeleteConfigModal';
|
||||
import { Select } from '@/components/Select';
|
||||
import { stripFileExtension } from '@/utils/format';
|
||||
|
||||
interface ConfigFileManagerProps {
|
||||
configFiles: ConfigFile[];
|
||||
|
|
@ -29,10 +30,9 @@ export const ConfigFileManager = ({
|
|||
const [deleteModalOpened, setDeleteModalOpened] = useState(false);
|
||||
const [configToDelete, setConfigToDelete] = useState<string | null>(null);
|
||||
|
||||
const existingConfigNames = configFiles.map((file) => {
|
||||
const extension = file.name.split('.').pop() || '';
|
||||
return file.name.replace(`.${extension}`, '').toLowerCase();
|
||||
});
|
||||
const existingConfigNames = configFiles.map((file) =>
|
||||
stripFileExtension(file.name).toLowerCase()
|
||||
);
|
||||
|
||||
const handleOpenConfigModal = () => {
|
||||
setConfigModalOpened(true);
|
||||
|
|
@ -78,7 +78,7 @@ export const ConfigFileManager = ({
|
|||
|
||||
const selectData = configFiles.map((file) => {
|
||||
const extension = file.name.split('.').pop() || '';
|
||||
const nameWithoutExtension = file.name.replace(`.${extension}`, '');
|
||||
const nameWithoutExtension = stripFileExtension(file.name);
|
||||
|
||||
return {
|
||||
value: file.name,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Text, Group, Button, Stack } from '@mantine/core';
|
||||
import { Modal } from '@/components/Modal';
|
||||
import { stripFileExtension } from '@/utils/format';
|
||||
|
||||
interface DeleteConfigModalProps {
|
||||
opened: boolean;
|
||||
|
|
@ -14,7 +15,7 @@ export const DeleteConfigModal = ({
|
|||
onConfirm,
|
||||
configName,
|
||||
}: DeleteConfigModalProps) => {
|
||||
const displayName = configName?.replace(/\.[^/.]+$/, '') || '';
|
||||
const displayName = configName ? stripFileExtension(configName) : '';
|
||||
|
||||
return (
|
||||
<Modal opened={opened} onClose={onClose} title="Delete Configuration">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
import { Stack, Text, Switch } from '@mantine/core';
|
||||
import { Stack, Text } from '@mantine/core';
|
||||
import { usePreferencesStore } from '@/stores/preferences';
|
||||
import { Switch } from '@/components/Switch';
|
||||
|
||||
export const GeneralTab = () => {
|
||||
const [enableSystemTray, setEnableSystemTray] = useState(false);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { join } from 'path';
|
|||
import { platform, resourcesPath } from 'process';
|
||||
import { getEnableSystemTray } from './config';
|
||||
import { getMainWindow } from './window';
|
||||
import { stripFileExtension } from '@/utils/format';
|
||||
import type { CpuMetrics, MemoryMetrics, GpuMetrics } from './monitoring';
|
||||
import type { Screen } from '@/types';
|
||||
import { PRODUCT_NAME } from '@/constants';
|
||||
|
|
@ -142,8 +143,13 @@ function buildContextMenu() {
|
|||
menuTemplate.push({ type: 'separator' });
|
||||
|
||||
if (appState.currentScreen === 'launch' && !appState.isLaunched) {
|
||||
const configDisplayName = appState.currentConfig
|
||||
? stripFileExtension(appState.currentConfig)
|
||||
: null;
|
||||
menuTemplate.push({
|
||||
label: 'Launch with Current Config',
|
||||
label: configDisplayName
|
||||
? `Launch: ${configDisplayName}`
|
||||
: 'Launch with Current Config',
|
||||
enabled: !!appState.currentConfig,
|
||||
click: () => {
|
||||
const mainWindow = getMainWindow();
|
||||
|
|
|
|||
|
|
@ -45,3 +45,6 @@ export const formatDeviceName = (deviceName: string) =>
|
|||
.replace(/\s*\d+-core\s*/gi, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
export const stripFileExtension = (filename: string) =>
|
||||
filename.replace(/\.[^/.]+$/, '');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue