mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 00:15:48 +01:00
💄 Change UI for docker module
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { Button, Group } from '@mantine/core';
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import { Button, Group, TextInput, Title } from '@mantine/core';
|
||||
import { closeAllModals, closeModal, openModal } from '@mantine/modals';
|
||||
import { showNotification, updateNotification } from '@mantine/notifications';
|
||||
import {
|
||||
IconCheck,
|
||||
IconPlayerPlay,
|
||||
IconPlayerStop,
|
||||
IconPlus,
|
||||
IconRefresh,
|
||||
IconRotateClockwise,
|
||||
IconTrash,
|
||||
@@ -13,6 +16,9 @@ import Dockerode from 'dockerode';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useState } from 'react';
|
||||
import { TFunction } from 'react-i18next';
|
||||
import { AddAppShelfItemForm } from '../../components/AppShelf/AddAppShelfItem';
|
||||
import { tryMatchService } from '../../tools/addToHomarr';
|
||||
import { useConfig } from '../../tools/state';
|
||||
|
||||
let t: TFunction<'modules/docker', undefined>;
|
||||
|
||||
@@ -63,6 +69,8 @@ export interface ContainerActionBarProps {
|
||||
export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) {
|
||||
t = useTranslation('modules/docker').t;
|
||||
const [isLoading, setisLoading] = useState(false);
|
||||
const { config, setConfig } = useConfig();
|
||||
|
||||
return (
|
||||
<Group>
|
||||
<Button
|
||||
@@ -145,6 +153,33 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
|
||||
>
|
||||
{t('actionBar.remove.title')}
|
||||
</Button>
|
||||
<Button
|
||||
leftIcon={<IconPlus />}
|
||||
color="indigo"
|
||||
variant="light"
|
||||
radius="md"
|
||||
disabled={selected.length === 0 || selected.length > 1}
|
||||
onClick={() => {
|
||||
openModal({
|
||||
size: 'xl',
|
||||
modalId: selected.at(0)!.Id,
|
||||
radius: 'md',
|
||||
title: t('actionBar.addService.title'),
|
||||
zIndex: 500,
|
||||
children: (
|
||||
<AddAppShelfItemForm
|
||||
setConfig={setConfig}
|
||||
config={config}
|
||||
setOpened={() => closeModal(selected.at(0)!.Id)}
|
||||
message={t('actionBar.addService.message')}
|
||||
{...tryMatchService(selected.at(0)!)}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('actionBar.addToHomarr.title')}
|
||||
</Button>
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function DockerMenuButton(props: any) {
|
||||
icon: <IconX />,
|
||||
message: t('errors.integrationFailed.message'),
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 300);
|
||||
}
|
||||
const exists = config.modules?.[DockerModule.id]?.enabled ?? false;
|
||||
|
||||
@@ -7,9 +7,8 @@ import {
|
||||
ScrollArea,
|
||||
TextInput,
|
||||
Modal,
|
||||
ActionIcon,
|
||||
} from '@mantine/core';
|
||||
import { IconPlus, IconSearch } from '@tabler/icons';
|
||||
import { IconSearch } from '@tabler/icons';
|
||||
import Dockerode from 'dockerode';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useEffect, useState } from 'react';
|
||||
@@ -36,10 +35,8 @@ export default function DockerTable({
|
||||
selection: Dockerode.ContainerInfo[];
|
||||
}) {
|
||||
const [usedContainers, setContainers] = useState<Dockerode.ContainerInfo[]>(containers);
|
||||
const [rowSelected, setRowSelected] = useState<Dockerode.ContainerInfo>();
|
||||
const { classes, cx } = useStyles();
|
||||
const [search, setSearch] = useState('');
|
||||
const [opened, setOpened] = useState<boolean>(false);
|
||||
|
||||
const { t } = useTranslation('modules/docker');
|
||||
|
||||
@@ -106,38 +103,12 @@ export default function DockerTable({
|
||||
<td>
|
||||
<ContainerState state={element.State} />
|
||||
</td>
|
||||
<td>
|
||||
<ActionIcon
|
||||
color="indigo"
|
||||
variant="light"
|
||||
radius="md"
|
||||
onClick={() => {
|
||||
setRowSelected(element);
|
||||
setOpened(true);
|
||||
}}
|
||||
>
|
||||
<IconPlus />
|
||||
</ActionIcon>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<ScrollArea style={{ height: '80vh' }}>
|
||||
<Modal
|
||||
size="xl"
|
||||
radius="md"
|
||||
opened={opened}
|
||||
onClose={() => setOpened(false)}
|
||||
title={t('actionBar.addService.title')}
|
||||
>
|
||||
<AddAppShelfItemForm
|
||||
setOpened={setOpened}
|
||||
{...tryMatchService(rowSelected)}
|
||||
message={t('actionBar.addService.message')}
|
||||
/>
|
||||
</Modal>
|
||||
<TextInput
|
||||
placeholder={t('search.placeholder')}
|
||||
mt="md"
|
||||
@@ -162,7 +133,6 @@ export default function DockerTable({
|
||||
<th>{t('table.header.image')}</th>
|
||||
<th>{t('table.header.ports')}</th>
|
||||
<th>{t('table.header.state')}</th>
|
||||
<th>{t('table.header.addToHomarr')}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rows}</tbody>
|
||||
|
||||
Reference in New Issue
Block a user