mirror of
https://github.com/portainer/portainer.git
synced 2025-07-31 11:19:40 +02:00
feat(docker/services): show port ranges [EE-4012] (#10657)
Some checks failed
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
Some checks failed
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
This commit is contained in:
parent
4ca6292805
commit
d336a14e50
37 changed files with 1406 additions and 148 deletions
81
app/react/docker/services/ItemView/ServiceWidget.tsx
Normal file
81
app/react/docker/services/ItemView/ServiceWidget.tsx
Normal file
|
@ -0,0 +1,81 @@
|
|||
import { Plus, ChevronDown } from 'lucide-react';
|
||||
import { ComponentProps, PropsWithChildren } from 'react';
|
||||
import { Menu, MenuButton, MenuItem, MenuPopover } from '@reach/menu-button';
|
||||
import { positionRight } from '@reach/popover';
|
||||
|
||||
import { Authorized } from '@/react/hooks/useUser';
|
||||
|
||||
import { Widget } from '@@/Widget';
|
||||
import { Button, ButtonGroup } from '@@/buttons';
|
||||
import { ButtonWithRef } from '@@/buttons/Button';
|
||||
|
||||
/**
|
||||
* used for wrapping widget in the service item view
|
||||
*/
|
||||
export function ServiceWidget({
|
||||
titleIcon,
|
||||
title,
|
||||
children,
|
||||
onAdd,
|
||||
hasChanges,
|
||||
onReset,
|
||||
onSubmit,
|
||||
labelForAddButton,
|
||||
isValid,
|
||||
}: PropsWithChildren<{
|
||||
titleIcon: ComponentProps<typeof Widget.Title>['icon'];
|
||||
title: string;
|
||||
onAdd(): void;
|
||||
hasChanges: boolean;
|
||||
onReset(all?: boolean): void;
|
||||
onSubmit(): void;
|
||||
labelForAddButton: string;
|
||||
isValid?: boolean;
|
||||
}>) {
|
||||
return (
|
||||
<Widget aria-label={title}>
|
||||
<Widget.Title icon={titleIcon} title={title}>
|
||||
<Authorized authorizations="DockerServiceUpdate">
|
||||
<Button color="secondary" size="small" onClick={onAdd} icon={Plus}>
|
||||
{labelForAddButton}
|
||||
</Button>
|
||||
</Authorized>
|
||||
</Widget.Title>
|
||||
|
||||
<Widget.Body className="!p-0">{children}</Widget.Body>
|
||||
|
||||
<Authorized authorizations="DockerServiceUpdate">
|
||||
<Widget.Footer>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={onSubmit}
|
||||
disabled={!hasChanges || !isValid}
|
||||
>
|
||||
Apply changes
|
||||
</Button>
|
||||
|
||||
<Menu>
|
||||
<MenuButton
|
||||
as={ButtonWithRef}
|
||||
size="small"
|
||||
color="default"
|
||||
icon={ChevronDown}
|
||||
>
|
||||
<span className="sr-only">Toggle Dropdown</span>
|
||||
</MenuButton>
|
||||
<MenuPopover position={positionRight}>
|
||||
<div className="mt-3 bg-white th-highcontrast:bg-black th-dark:bg-black">
|
||||
<MenuItem onSelect={() => onReset()}>Reset changes</MenuItem>
|
||||
<MenuItem onSelect={() => onReset(true)}>
|
||||
Reset all changes
|
||||
</MenuItem>
|
||||
</div>
|
||||
</MenuPopover>
|
||||
</Menu>
|
||||
</ButtonGroup>
|
||||
</Widget.Footer>
|
||||
</Authorized>
|
||||
</Widget>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue