1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00
portainer/app/react/kubernetes/DeployView/StackName/StackName.tsx
Ali 56ae19c5ab
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
fix(stacks): add app form stacks input [EE-6693] (#11104)
2024-02-14 09:00:51 +13:00

103 lines
2.7 KiB
TypeScript

import { useMemo } from 'react';
import { useCurrentUser } from '@/react/hooks/useUser';
import { InsightsBox } from '@@/InsightsBox';
import { Link } from '@@/Link';
import { TextTip } from '@@/Tip/TextTip';
import { Tooltip } from '@@/Tip/Tooltip';
import { AutocompleteSelect } from '@@/form-components/AutocompleteSelect';
type Props = {
stackName: string;
setStackName: (name: string) => void;
stacks?: string[];
inputClassName?: string;
textTip?: string;
};
export function StackName({
stackName,
setStackName,
stacks = [],
inputClassName,
textTip = "Enter or select a 'stack' name to group multiple deployments together, or else leave empty to ignore.",
}: Props) {
const { isAdmin } = useCurrentUser();
const stackResults = useMemo(
() => stacks.filter((stack) => stack.includes(stackName ?? '')),
[stacks, stackName]
);
const tooltip = (
<>
You may specify a stack name to label resources that you want to group.
This includes Deployments, DaemonSets, StatefulSets and Pods.
{isAdmin && (
<>
<br />
You can leave the stack name empty, or even turn off Kubernetes Stacks
functionality entirely via{' '}
<Link to="portainer.settings" target="_blank">
Kubernetes Settings
</Link>
.
</>
)}
</>
);
const insightsBoxContent = (
<>
The stack field below was previously labelled &apos;Name&apos; but, in
fact, it&apos;s always been the stack name (hence the relabelling).
{isAdmin && (
<>
<br />
Kubernetes Stacks functionality can be turned off entirely via{' '}
<Link to="portainer.settings" target="_blank">
Kubernetes Settings
</Link>
.
</>
)}
</>
);
return (
<>
<div className="w-fit mb-4">
<InsightsBox
type="slim"
header="Stack"
content={insightsBoxContent}
insightCloseId="k8s-stacks-name"
/>
</div>
<TextTip className="mb-4" color="blue">
{textTip}
</TextTip>
<div className="form-group">
<label
htmlFor="stack_name"
className="col-lg-2 col-sm-3 control-label text-left"
>
Stack
<Tooltip message={tooltip} setHtmlMessage />
</label>
<div className={inputClassName || 'col-sm-8'}>
<AutocompleteSelect
searchResults={stackResults?.map((result) => ({
value: result,
label: result,
}))}
value={stackName ?? ''}
onChange={setStackName}
placeholder="e.g. myStack"
inputId="stack_name"
/>
</div>
</div>
</>
);
}