2022-12-04 21:19:40 +01:00
|
|
|
import { Group, Space, Stack, Text, UnstyledButton } from '@mantine/core';
|
2022-12-22 11:30:50 +09:00
|
|
|
import { IconBox, IconStack } from '@tabler/icons';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
|
|
import { ReactNode } from 'react';
|
|
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
|
import { openContextModalGeneric } from '../../../../../../tools/mantineModalManagerExtensions';
|
2022-12-18 22:27:01 +01:00
|
|
|
import { AppType } from '../../../../../../types/app';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { useStyles } from '../Shared/styles';
|
|
|
|
|
|
|
|
|
|
interface AvailableElementTypesProps {
|
|
|
|
|
onOpenIntegrations: () => void;
|
|
|
|
|
onOpenStaticElements: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AvailableElementTypes = ({
|
2022-12-19 19:01:29 +01:00
|
|
|
onOpenIntegrations: onOpenWidgets,
|
2022-12-04 21:19:40 +01:00
|
|
|
onOpenStaticElements,
|
|
|
|
|
}: AvailableElementTypesProps) => {
|
|
|
|
|
const { t } = useTranslation('layout/element-selector/selector');
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Text color="dimmed">{t('modal.text')}</Text>
|
|
|
|
|
<Space h="lg" />
|
|
|
|
|
<Group spacing="md" grow>
|
|
|
|
|
<ElementItem
|
2022-12-18 22:27:01 +01:00
|
|
|
name="Apps"
|
2022-12-04 21:19:40 +01:00
|
|
|
icon={<IconBox size={40} strokeWidth={1.3} />}
|
|
|
|
|
onClick={() => {
|
2022-12-19 19:01:29 +01:00
|
|
|
openContextModalGeneric<{ app: AppType; allowAppNamePropagation: boolean }>({
|
|
|
|
|
modal: 'editApp',
|
|
|
|
|
innerProps: {
|
|
|
|
|
app: {
|
|
|
|
|
id: uuidv4(),
|
|
|
|
|
name: 'Your app',
|
|
|
|
|
url: 'https://homarr.dev',
|
|
|
|
|
appearance: {
|
|
|
|
|
iconUrl: '/imgs/logo/logo.png',
|
|
|
|
|
},
|
|
|
|
|
network: {
|
|
|
|
|
enabledStatusChecker: false,
|
|
|
|
|
okStatus: [],
|
|
|
|
|
},
|
|
|
|
|
behaviour: {
|
|
|
|
|
isOpeningNewTab: true,
|
2022-12-22 11:29:51 +09:00
|
|
|
externalUrl: '',
|
2022-12-19 19:01:29 +01:00
|
|
|
},
|
|
|
|
|
area: {
|
|
|
|
|
type: 'sidebar',
|
|
|
|
|
properties: {
|
|
|
|
|
location: 'right',
|
2022-12-04 22:02:10 +01:00
|
|
|
},
|
2022-12-19 19:01:29 +01:00
|
|
|
},
|
|
|
|
|
shape: {
|
|
|
|
|
location: {
|
|
|
|
|
x: 0,
|
|
|
|
|
y: 0,
|
2022-12-04 22:02:10 +01:00
|
|
|
},
|
2022-12-19 19:01:29 +01:00
|
|
|
size: {
|
|
|
|
|
height: 1,
|
|
|
|
|
width: 1,
|
2022-12-12 22:09:17 +01:00
|
|
|
},
|
2022-12-04 21:19:40 +01:00
|
|
|
},
|
2022-12-19 19:01:29 +01:00
|
|
|
integration: {
|
|
|
|
|
type: null,
|
|
|
|
|
properties: [],
|
|
|
|
|
},
|
2022-12-04 21:19:40 +01:00
|
|
|
},
|
2022-12-19 19:01:29 +01:00
|
|
|
allowAppNamePropagation: true,
|
|
|
|
|
},
|
|
|
|
|
size: 'xl',
|
|
|
|
|
});
|
2022-12-04 21:19:40 +01:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<ElementItem
|
2022-12-19 19:01:29 +01:00
|
|
|
name="Widgets"
|
|
|
|
|
icon={<IconStack size={40} strokeWidth={1.3} />}
|
|
|
|
|
onClick={onOpenWidgets}
|
2022-12-04 21:19:40 +01:00
|
|
|
/>
|
2022-12-20 07:50:01 +01:00
|
|
|
{/*<ElementItem
|
2022-12-04 21:19:40 +01:00
|
|
|
name="Static Element"
|
|
|
|
|
icon={<IconTextResize size={40} strokeWidth={1.3} />}
|
|
|
|
|
onClick={onOpenStaticElements}
|
2022-12-20 07:50:01 +01:00
|
|
|
/>*/}
|
2022-12-04 21:19:40 +01:00
|
|
|
</Group>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface ElementItemProps {
|
|
|
|
|
icon: ReactNode;
|
|
|
|
|
name: string;
|
|
|
|
|
onClick: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ElementItem = ({ name, icon, onClick }: ElementItemProps) => {
|
|
|
|
|
const { classes, cx } = useStyles();
|
|
|
|
|
return (
|
|
|
|
|
<UnstyledButton
|
|
|
|
|
className={cx(classes.elementButton, classes.styledButton)}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
py="md"
|
|
|
|
|
>
|
|
|
|
|
<Stack className={classes.elementStack} align="center" spacing={5}>
|
|
|
|
|
{icon}
|
|
|
|
|
<Text className={classes.elementName} weight={500} size="sm">
|
|
|
|
|
{name}
|
|
|
|
|
</Text>
|
|
|
|
|
</Stack>
|
|
|
|
|
</UnstyledButton>
|
|
|
|
|
);
|
|
|
|
|
};
|