mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Added search to settings.
This commit is contained in:
parent
efd4f4ca00
commit
16f1b15dee
7 changed files with 41 additions and 21 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
export default {
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es2020": true,
|
"es2020": true,
|
||||||
|
|
@ -196,7 +196,7 @@
|
||||||
"sharp"
|
"sharp"
|
||||||
],
|
],
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@umami/react-zen": "link:C:/Users/mike/AppData/Local/pnpm/global/5/node_modules/@umami/react-zen"
|
"@umami/react-zen": "link:../../../Library/pnpm/global/5/node_modules/@umami/react-zen"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
|
|
@ -5,7 +5,7 @@ settings:
|
||||||
excludeLinksFromLockfile: false
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
'@umami/react-zen': link:C:/Users/mike/AppData/Local/pnpm/global/5/node_modules/@umami/react-zen
|
'@umami/react-zen': link:../../../Library/pnpm/global/5/node_modules/@umami/react-zen
|
||||||
|
|
||||||
importers:
|
importers:
|
||||||
|
|
||||||
|
|
@ -48,8 +48,8 @@ importers:
|
||||||
specifier: ^0.16.0
|
specifier: ^0.16.0
|
||||||
version: 0.16.0(@prisma/client@6.5.0(prisma@6.5.0(typescript@5.8.2))(typescript@5.8.2))(@prisma/extension-read-replicas@0.4.0(@prisma/client@6.5.0(prisma@6.5.0(typescript@5.8.2))(typescript@5.8.2)))
|
version: 0.16.0(@prisma/client@6.5.0(prisma@6.5.0(typescript@5.8.2))(typescript@5.8.2))(@prisma/extension-read-replicas@0.4.0(@prisma/client@6.5.0(prisma@6.5.0(typescript@5.8.2))(typescript@5.8.2)))
|
||||||
'@umami/react-zen':
|
'@umami/react-zen':
|
||||||
specifier: link:C:/Users/mike/AppData/Local/pnpm/global/5/node_modules/@umami/react-zen
|
specifier: link:../../../Library/pnpm/global/5/node_modules/@umami/react-zen
|
||||||
version: link:C:/Users/mike/AppData/Local/pnpm/global/5/node_modules/@umami/react-zen
|
version: link:../../../Library/pnpm/global/5/node_modules/@umami/react-zen
|
||||||
'@umami/redis-client':
|
'@umami/redis-client':
|
||||||
specifier: ^0.27.0
|
specifier: ^0.27.0
|
||||||
version: 0.27.0
|
version: 0.27.0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
div.menu {
|
|
||||||
max-height: 300px;
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
|
|
@ -3,13 +3,12 @@ import { Button, Select, ListItem, Flexbox } from '@umami/react-zen';
|
||||||
import { useLocale, useMessages } from '@/components/hooks';
|
import { useLocale, useMessages } from '@/components/hooks';
|
||||||
import { DEFAULT_LOCALE } from '@/lib/constants';
|
import { DEFAULT_LOCALE } from '@/lib/constants';
|
||||||
import { languages } from '@/lib/lang';
|
import { languages } from '@/lib/lang';
|
||||||
import styles from './LanguageSetting.module.css';
|
|
||||||
|
|
||||||
export function LanguageSetting() {
|
export function LanguageSetting() {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { locale, saveLocale } = useLocale();
|
const { locale, saveLocale } = useLocale();
|
||||||
const options = search
|
const items = search
|
||||||
? Object.keys(languages).filter(n => {
|
? Object.keys(languages).filter(n => {
|
||||||
return (
|
return (
|
||||||
n.toLowerCase().includes(search.toLowerCase()) ||
|
n.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
|
@ -20,16 +19,28 @@ export function LanguageSetting() {
|
||||||
|
|
||||||
const handleReset = () => saveLocale(DEFAULT_LOCALE);
|
const handleReset = () => saveLocale(DEFAULT_LOCALE);
|
||||||
|
|
||||||
console.log({ options });
|
const handleOpen = isOpen => {
|
||||||
|
if (isOpen) {
|
||||||
|
setSearch('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flexbox gap={10}>
|
<Flexbox gap={10}>
|
||||||
<Select value={locale} onChange={val => saveLocale(val as string)}>
|
<Select
|
||||||
{options.map(item => (
|
value={locale}
|
||||||
|
onChange={val => saveLocale(val as string)}
|
||||||
|
allowSearch
|
||||||
|
onSearch={setSearch}
|
||||||
|
onOpenChange={handleOpen}
|
||||||
|
listProps={{ style: { maxHeight: '300px' } }}
|
||||||
|
>
|
||||||
|
{items.map(item => (
|
||||||
<ListItem key={item} id={item}>
|
<ListItem key={item} id={item}>
|
||||||
{languages[item].label}
|
{languages[item].label}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
))}
|
||||||
|
{!items.length && <ListItem></ListItem>}
|
||||||
</Select>
|
</Select>
|
||||||
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
||||||
</Flexbox>
|
</Flexbox>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
import { Form, FormField, FormButtons, PasswordField, Button } from '@umami/react-zen';
|
import {
|
||||||
|
Form,
|
||||||
|
FormField,
|
||||||
|
FormButtons,
|
||||||
|
PasswordField,
|
||||||
|
Button,
|
||||||
|
FormSubmitButton,
|
||||||
|
} from '@umami/react-zen';
|
||||||
import { useApi, useMessages } from '@/components/hooks';
|
import { useApi, useMessages } from '@/components/hooks';
|
||||||
|
|
||||||
export function PasswordEditForm({ onSave, onClose }) {
|
export function PasswordEditForm({ onSave, onClose }) {
|
||||||
|
|
@ -55,10 +62,8 @@ export function PasswordEditForm({ onSave, onClose }) {
|
||||||
<PasswordField autoComplete="confirm-password" />
|
<PasswordField autoComplete="confirm-password" />
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormButtons>
|
<FormButtons>
|
||||||
<Button type="submit" variant="primary" isDisabled={isPending}>
|
|
||||||
{formatMessage(labels.save)}
|
|
||||||
</Button>
|
|
||||||
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
|
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
|
||||||
|
<FormSubmitButton isDisabled={isPending}>{formatMessage(labels.save)}</FormSubmitButton>
|
||||||
</FormButtons>
|
</FormButtons>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,29 @@ export function TimezoneSetting() {
|
||||||
|
|
||||||
const handleReset = () => saveTimezone(getTimezone());
|
const handleReset = () => saveTimezone(getTimezone());
|
||||||
|
|
||||||
|
const handleOpen = isOpen => {
|
||||||
|
if (isOpen) {
|
||||||
|
setSearch('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row gap="3">
|
<Row gap="3">
|
||||||
<Select
|
<Select
|
||||||
className={styles.dropdown}
|
className={styles.dropdown}
|
||||||
items={items}
|
|
||||||
value={timezone}
|
value={timezone}
|
||||||
onChange={(value: any) => saveTimezone(value)}
|
onChange={(value: any) => saveTimezone(value)}
|
||||||
allowSearch={true}
|
allowSearch={true}
|
||||||
onSearch={setSearch}
|
onSearch={setSearch}
|
||||||
|
onOpenChange={handleOpen}
|
||||||
|
listProps={{ style: { maxHeight: '300px' } }}
|
||||||
>
|
>
|
||||||
{(item: any) => (
|
{items.map((item: any) => (
|
||||||
<ListItem key={item} id={item}>
|
<ListItem key={item} id={item}>
|
||||||
{item}
|
{item}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)}
|
))}
|
||||||
|
{!items.length && <ListItem></ListItem>}
|
||||||
</Select>
|
</Select>
|
||||||
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue