mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
refactor: impove about homarr modal
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import Image from 'next/image';
|
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Badge,
|
Badge,
|
||||||
@@ -18,7 +17,9 @@ import {
|
|||||||
IconVocabulary,
|
IconVocabulary,
|
||||||
IconWorldWww,
|
IconWorldWww,
|
||||||
} from '@tabler/icons';
|
} from '@tabler/icons';
|
||||||
|
import { InitOptions } from 'i18next';
|
||||||
import { i18n } from 'next-i18next';
|
import { i18n } from 'next-i18next';
|
||||||
|
import Image from 'next/image';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { CURRENT_VERSION } from '../../../data/constants';
|
import { CURRENT_VERSION } from '../../../data/constants';
|
||||||
import { usePrimaryGradient } from '../layout/useGradient';
|
import { usePrimaryGradient } from '../layout/useGradient';
|
||||||
@@ -118,13 +119,44 @@ interface InformationTableItem {
|
|||||||
content: ReactNode;
|
content: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ExtendedInitOptions extends InitOptions {
|
||||||
|
locales: string[];
|
||||||
|
}
|
||||||
|
|
||||||
const useInformationTableItems = (): InformationTableItem[] => {
|
const useInformationTableItems = (): InformationTableItem[] => {
|
||||||
const colorGradiant = usePrimaryGradient();
|
const colorGradiant = usePrimaryGradient();
|
||||||
|
|
||||||
const usedI18nNamespaces = i18n?.reportNamespaces?.getUsedNamespaces();
|
let items: InformationTableItem[] = [];
|
||||||
const configuredi18nLocales: string[] = i18n?.options.locales;
|
|
||||||
|
|
||||||
return [
|
if (i18n !== null) {
|
||||||
|
const usedI18nNamespaces = i18n.reportNamespaces.getUsedNamespaces();
|
||||||
|
const initOptions = i18n.options as ExtendedInitOptions;
|
||||||
|
|
||||||
|
items = [
|
||||||
|
...items,
|
||||||
|
{
|
||||||
|
icon: <IconLanguage size={20} />,
|
||||||
|
label: 'Loaded I18n translation namespaces',
|
||||||
|
content: (
|
||||||
|
<Badge variant="gradient" gradient={colorGradiant}>
|
||||||
|
{usedI18nNamespaces.length}
|
||||||
|
</Badge>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: <IconVocabulary size={20} />,
|
||||||
|
label: 'Configured I18n locales',
|
||||||
|
content: (
|
||||||
|
<Badge variant="gradient" gradient={colorGradiant}>
|
||||||
|
{initOptions.locales.length}
|
||||||
|
</Badge>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
items = [
|
||||||
|
...items,
|
||||||
{
|
{
|
||||||
icon: <IconVersions size={20} />,
|
icon: <IconVersions size={20} />,
|
||||||
label: 'Homarr version',
|
label: 'Homarr version',
|
||||||
@@ -134,25 +166,9 @@ const useInformationTableItems = (): InformationTableItem[] => {
|
|||||||
</Badge>
|
</Badge>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
icon: <IconLanguage size={20} />,
|
|
||||||
label: 'Loaded I18n translation namespaces',
|
|
||||||
content: (
|
|
||||||
<Badge variant="gradient" gradient={colorGradiant}>
|
|
||||||
{usedI18nNamespaces?.length ?? 'loading'}
|
|
||||||
</Badge>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: <IconVocabulary size={20} />,
|
|
||||||
label: 'Configured I18n locales',
|
|
||||||
content: (
|
|
||||||
<Badge variant="gradient" gradient={colorGradiant}>
|
|
||||||
{configuredi18nLocales?.length ?? 'loading'}
|
|
||||||
</Badge>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useStyles = createStyles(() => ({
|
const useStyles = createStyles(() => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user