mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
refactor(app): migrate configmap and secret form sections [EE-6233] (#10528)
* refactor(app): migrate configmap and secret form sections [EE-6233]
This commit is contained in:
parent
391b85da41
commit
7a2412b1be
18 changed files with 631 additions and 447 deletions
|
@ -1,6 +1,9 @@
|
|||
import { KeyToPath, Pod } from 'kubernetes-types/core/v1';
|
||||
import { KeyToPath, Pod, Secret } from 'kubernetes-types/core/v1';
|
||||
import { Asterisk, Plus } from 'lucide-react';
|
||||
|
||||
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
||||
import { useSecrets } from '@/react/kubernetes/configs/secret.service';
|
||||
|
||||
import { Icon } from '@@/Icon';
|
||||
import { Link } from '@@/Link';
|
||||
|
||||
|
@ -15,6 +18,8 @@ type Props = {
|
|||
export function ApplicationVolumeConfigsTable({ namespace, app }: Props) {
|
||||
const containerVolumeConfigs = getApplicationVolumeConfigs(app);
|
||||
|
||||
const { data: secrets } = useSecrets(useEnvironmentId(), namespace);
|
||||
|
||||
if (containerVolumeConfigs.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -71,10 +76,19 @@ export function ApplicationVolumeConfigsTable({ namespace, app }: Props) {
|
|||
{!item.key && '-'}
|
||||
</td>
|
||||
<td>
|
||||
{volumeConfigName && (
|
||||
{isVolumeConfigNameFromSecret(secrets, volumeConfigName) ? (
|
||||
<Link
|
||||
className="flex items-center"
|
||||
to="kubernetes.configurations.configuration"
|
||||
to="kubernetes.secrets.secret"
|
||||
params={{ name: volumeConfigName, namespace }}
|
||||
>
|
||||
<Icon icon={Plus} className="!mr-1" />
|
||||
{volumeConfigName}
|
||||
</Link>
|
||||
) : (
|
||||
<Link
|
||||
className="flex items-center"
|
||||
to="kubernetes.configmaps.configmap"
|
||||
params={{ name: volumeConfigName, namespace }}
|
||||
>
|
||||
<Icon icon={Plus} className="!mr-1" />
|
||||
|
@ -91,6 +105,13 @@ export function ApplicationVolumeConfigsTable({ namespace, app }: Props) {
|
|||
);
|
||||
}
|
||||
|
||||
function isVolumeConfigNameFromSecret(
|
||||
secrets?: Secret[],
|
||||
volumeConfigName?: string
|
||||
) {
|
||||
return secrets?.some((secret) => secret.metadata?.name === volumeConfigName);
|
||||
}
|
||||
|
||||
// getApplicationVolumeConfigs returns a list of volume configs / secrets for each container and each item within the matching volume
|
||||
function getApplicationVolumeConfigs(app?: Application) {
|
||||
if (!app) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue