|
|
@ -26,6 +26,8 @@ import { useCurrentUser } from '@/react/hooks/useUser';
|
|
|
|
import { useCreateGitCredentialMutation } from '@/react/portainer/account/git-credentials/git-credentials.service';
|
|
|
|
import { useCreateGitCredentialMutation } from '@/react/portainer/account/git-credentials/git-credentials.service';
|
|
|
|
import { notifyError, notifySuccess } from '@/portainer/services/notifications';
|
|
|
|
import { notifyError, notifySuccess } from '@/portainer/services/notifications';
|
|
|
|
import { EnvironmentType } from '@/react/portainer/environments/types';
|
|
|
|
import { EnvironmentType } from '@/react/portainer/environments/types';
|
|
|
|
|
|
|
|
import { Registry } from '@/react/portainer/registries/types';
|
|
|
|
|
|
|
|
import { useRegistries } from '@/react/portainer/registries/queries/useRegistries';
|
|
|
|
|
|
|
|
|
|
|
|
import { LoadingButton } from '@@/buttons';
|
|
|
|
import { LoadingButton } from '@@/buttons';
|
|
|
|
import { FormSection } from '@@/form-components/FormSection';
|
|
|
|
import { FormSection } from '@@/form-components/FormSection';
|
|
|
@ -36,8 +38,12 @@ import { EnvVar } from '@@/form-components/EnvironmentVariablesFieldset/types';
|
|
|
|
|
|
|
|
|
|
|
|
import { useValidateEnvironmentTypes } from '../useEdgeGroupHasType';
|
|
|
|
import { useValidateEnvironmentTypes } from '../useEdgeGroupHasType';
|
|
|
|
import { atLeastTwo } from '../atLeastTwo';
|
|
|
|
import { atLeastTwo } from '../atLeastTwo';
|
|
|
|
|
|
|
|
import { PrivateRegistryFieldset } from '../../../components/PrivateRegistryFieldset';
|
|
|
|
|
|
|
|
|
|
|
|
import { useUpdateEdgeStackGitMutation } from './useUpdateEdgeStackGitMutation';
|
|
|
|
import {
|
|
|
|
|
|
|
|
UpdateEdgeStackGitPayload,
|
|
|
|
|
|
|
|
useUpdateEdgeStackGitMutation,
|
|
|
|
|
|
|
|
} from './useUpdateEdgeStackGitMutation';
|
|
|
|
|
|
|
|
|
|
|
|
interface FormValues {
|
|
|
|
interface FormValues {
|
|
|
|
groupIds: EdgeGroup['Id'][];
|
|
|
|
groupIds: EdgeGroup['Id'][];
|
|
|
@ -46,6 +52,7 @@ interface FormValues {
|
|
|
|
refName: string;
|
|
|
|
refName: string;
|
|
|
|
authentication: GitAuthModel;
|
|
|
|
authentication: GitAuthModel;
|
|
|
|
envVars: EnvVar[];
|
|
|
|
envVars: EnvVar[];
|
|
|
|
|
|
|
|
privateRegistryId?: Registry['Id'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function GitForm({ stack }: { stack: EdgeStack }) {
|
|
|
|
export function GitForm({ stack }: { stack: EdgeStack }) {
|
|
|
@ -117,10 +124,10 @@ export function GitForm({ stack }: { stack: EdgeStack }) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getPayload(
|
|
|
|
function getPayload(
|
|
|
|
{ authentication, autoUpdate, ...values }: FormValues,
|
|
|
|
{ authentication, autoUpdate, privateRegistryId, ...values }: FormValues,
|
|
|
|
credentialId: number | undefined,
|
|
|
|
credentialId: number | undefined,
|
|
|
|
updateVersion: boolean
|
|
|
|
updateVersion: boolean
|
|
|
|
) {
|
|
|
|
): UpdateEdgeStackGitPayload {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
updateVersion,
|
|
|
|
updateVersion,
|
|
|
|
id: stack.Id,
|
|
|
|
id: stack.Id,
|
|
|
@ -129,6 +136,10 @@ export function GitForm({ stack }: { stack: EdgeStack }) {
|
|
|
|
RepositoryGitCredentialID: credentialId,
|
|
|
|
RepositoryGitCredentialID: credentialId,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
autoUpdate: transformAutoUpdateViewModel(autoUpdate, webhookId),
|
|
|
|
autoUpdate: transformAutoUpdateViewModel(autoUpdate, webhookId),
|
|
|
|
|
|
|
|
registries:
|
|
|
|
|
|
|
|
typeof privateRegistryId !== 'undefined'
|
|
|
|
|
|
|
|
? [privateRegistryId]
|
|
|
|
|
|
|
|
: undefined,
|
|
|
|
...values,
|
|
|
|
...values,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -173,6 +184,7 @@ function InnerForm({
|
|
|
|
onUpdateSettingsClick(): void;
|
|
|
|
onUpdateSettingsClick(): void;
|
|
|
|
webhookId: string;
|
|
|
|
webhookId: string;
|
|
|
|
}) {
|
|
|
|
}) {
|
|
|
|
|
|
|
|
const registriesQuery = useRegistries();
|
|
|
|
const { values, setFieldValue, isValid, handleSubmit, errors, dirty } =
|
|
|
|
const { values, setFieldValue, isValid, handleSubmit, errors, dirty } =
|
|
|
|
useFormikContext<FormValues>();
|
|
|
|
useFormikContext<FormValues>();
|
|
|
|
|
|
|
|
|
|
|
@ -265,6 +277,15 @@ function InnerForm({
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</FormSection>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<PrivateRegistryFieldset
|
|
|
|
|
|
|
|
value={values.privateRegistryId}
|
|
|
|
|
|
|
|
onSelect={(value) => setFieldValue('privateRegistryId', value)}
|
|
|
|
|
|
|
|
registries={registriesQuery.data ?? []}
|
|
|
|
|
|
|
|
formInvalid={!isValid}
|
|
|
|
|
|
|
|
method="repository"
|
|
|
|
|
|
|
|
errorMessage={errors.privateRegistryId}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<FormSection title="Actions">
|
|
|
|
<FormSection title="Actions">
|
|
|
|
<LoadingButton
|
|
|
|
<LoadingButton
|
|
|
|
disabled={dirty || !isValid || isLoading}
|
|
|
|
disabled={dirty || !isValid || isLoading}
|
|
|
|