mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
feat: add depth option to ui (#26618)
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
parent
60fed8b4ec
commit
e6b926c85e
4 changed files with 75 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import * as React from 'react';
|
||||
import {FormField} from 'argo-ui';
|
||||
import {FormField, HelpIcon} from 'argo-ui';
|
||||
import {FormApi, Text} from 'react-form';
|
||||
import {EditablePanel, EditablePanelItem} from '../../../shared/components';
|
||||
import {EditablePanel, EditablePanelItem, NumberField} from '../../../shared/components';
|
||||
import * as models from '../../../shared/models';
|
||||
import {NewHTTPSRepoParams} from '../repos-list/repos-list';
|
||||
import {AuthSettingsCtx} from '../../../shared/context';
|
||||
|
|
@ -80,6 +80,19 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
|
|||
});
|
||||
}
|
||||
|
||||
if (repository.type === 'git') {
|
||||
items.push({
|
||||
title: 'Depth (optional)',
|
||||
view: (repository.depth || 0).toString(),
|
||||
edit: (formApi: FormApi) => (
|
||||
<>
|
||||
<FormField formApi={formApi} field='depth' component={NumberField} />
|
||||
<HelpIcon title='Depth for shallow clones. Leave empty or 0 for a full clone.' />
|
||||
</>
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
|
|
@ -100,7 +113,8 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
|
|||
enableOCI: repo.enableOCI || false,
|
||||
forceHttpBasicAuth: repo.forceHttpBasicAuth || false,
|
||||
useAzureWorkloadIdentity: repo.useAzureWorkloadIdentity || false,
|
||||
insecureOCIForceHttp: repo.insecureOCIForceHttp || false
|
||||
insecureOCIForceHttp: repo.insecureOCIForceHttp || false,
|
||||
depth: repo.depth || 0
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -109,7 +123,8 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
|
|||
validate={input => ({
|
||||
username: !input.username && input.password && 'Username is required if password is given.',
|
||||
password: !input.password && input.username && 'Password is required if username is given.',
|
||||
bearerToken: input.password && input.bearerToken && 'Either the password or the bearer token must be set, but not both.'
|
||||
bearerToken: input.password && input.bearerToken && 'Either the password or the bearer token must be set, but not both.',
|
||||
depth: input.depth != undefined && input.depth < 0 && 'Depth must be a non-negative number'
|
||||
})}
|
||||
save={async input => {
|
||||
const params: NewHTTPSRepoParams = {...newRepo, write};
|
||||
|
|
@ -117,6 +132,7 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
|
|||
params.username = input.username || '';
|
||||
params.password = input.password || '';
|
||||
params.bearerToken = input.bearerToken || '';
|
||||
params.depth = input.depth || 0;
|
||||
save(params);
|
||||
}}
|
||||
title='CONNECTED REPOSITORY'
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ interface NewSSHRepoParams {
|
|||
proxy: string;
|
||||
noProxy: string;
|
||||
project?: string;
|
||||
depth?: number;
|
||||
// write should be true if saving as a write credential.
|
||||
write: boolean;
|
||||
}
|
||||
|
|
@ -42,6 +43,7 @@ export interface NewHTTPSRepoParams {
|
|||
forceHttpBasicAuth?: boolean;
|
||||
enableOCI: boolean;
|
||||
insecureOCIForceHttp: boolean;
|
||||
depth?: number;
|
||||
// write should be true if saving as a write credential.
|
||||
write: boolean;
|
||||
useAzureWorkloadIdentity: boolean;
|
||||
|
|
@ -62,6 +64,7 @@ interface NewGitHubAppRepoParams {
|
|||
proxy: string;
|
||||
noProxy: string;
|
||||
project?: string;
|
||||
depth?: number;
|
||||
// write should be true if saving as a write credential.
|
||||
write: boolean;
|
||||
}
|
||||
|
|
@ -74,6 +77,7 @@ interface NewGoogleCloudSourceRepoParams {
|
|||
proxy: string;
|
||||
noProxy: string;
|
||||
project?: string;
|
||||
depth?: number;
|
||||
// write should be true if saving as a write credential.
|
||||
write: boolean;
|
||||
}
|
||||
|
|
@ -195,7 +199,8 @@ export const ReposList = ({match, location}: RouteComponentProps) => {
|
|||
case ConnectionMethod.SSH:
|
||||
const sshValues = params as NewSSHRepoParams;
|
||||
return {
|
||||
url: !sshValues.url && 'Repository URL is required'
|
||||
url: !sshValues.url && 'Repository URL is required',
|
||||
depth: sshValues.depth != undefined && sshValues.depth < 0 && 'Depth must be a non-negative number'
|
||||
};
|
||||
case ConnectionMethod.HTTPS:
|
||||
const validURLValues = params as NewHTTPSRepoParams;
|
||||
|
|
@ -210,20 +215,23 @@ export const ReposList = ({match, location}: RouteComponentProps) => {
|
|||
tlsClientCertKey: !validURLValues.tlsClientCertKey && validURLValues.tlsClientCertData && 'TLS client cert key is required if TLS client cert is given.',
|
||||
bearerToken:
|
||||
(validURLValues.password && validURLValues.bearerToken && 'Either the password or the bearer token must be set, but not both.') ||
|
||||
(validURLValues.bearerToken && validURLValues.type != 'git' && 'Bearer token is only supported for Git BitBucket Data Center repositories.')
|
||||
(validURLValues.bearerToken && validURLValues.type != 'git' && 'Bearer token is only supported for Git BitBucket Data Center repositories.'),
|
||||
depth: validURLValues.depth != undefined && validURLValues.depth < 0 && 'Depth must be a non-negative number'
|
||||
};
|
||||
case ConnectionMethod.GITHUBAPP:
|
||||
const githubAppValues = params as NewGitHubAppRepoParams;
|
||||
return {
|
||||
url: (!githubAppValues.url && 'Repository URL is required') || (credsTemplate && !isHTTPOrHTTPSUrl(githubAppValues.url) && 'Not a valid HTTP/HTTPS URL'),
|
||||
githubAppId: !githubAppValues.githubAppId && 'GitHub App ID is required',
|
||||
githubAppPrivateKey: !githubAppValues.githubAppPrivateKey && 'GitHub App private Key is required'
|
||||
githubAppPrivateKey: !githubAppValues.githubAppPrivateKey && 'GitHub App private Key is required',
|
||||
depth: githubAppValues.depth != undefined && githubAppValues.depth < 0 && 'Depth must be a non-negative number'
|
||||
};
|
||||
case ConnectionMethod.GOOGLECLOUD:
|
||||
const googleCloudValues = params as NewGoogleCloudSourceRepoParams;
|
||||
return {
|
||||
url: (!googleCloudValues.url && 'Repo URL is required') || (credsTemplate && !isHTTPOrHTTPSUrl(googleCloudValues.url) && 'Not a valid HTTP/HTTPS URL'),
|
||||
gcpServiceAccountKey: !googleCloudValues.gcpServiceAccountKey && 'GCP service account key is required'
|
||||
gcpServiceAccountKey: !googleCloudValues.gcpServiceAccountKey && 'GCP service account key is required',
|
||||
depth: googleCloudValues.depth != undefined && googleCloudValues.depth < 0 && 'Depth must be a non-negative number'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
@ -1108,6 +1116,10 @@ export const ReposList = ({match, location}: RouteComponentProps) => {
|
|||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='NoProxy (optional)' field='noProxy' component={Text} />
|
||||
</div>
|
||||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='Depth (optional)' field='depth' component={NumberField} />
|
||||
<HelpIcon title='Depth for shallow clones. Leave empty or 0 for a full clone.' />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{method === ConnectionMethod.HTTPS && (
|
||||
|
|
@ -1206,6 +1218,12 @@ export const ReposList = ({match, location}: RouteComponentProps) => {
|
|||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='Use Azure Workload Identity' field='useAzureWorkloadIdentity' component={CheckboxField} />
|
||||
</div>
|
||||
{formApi.getFormState().values.type === 'git' && (
|
||||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='Depth (optional)' field='depth' component={NumberField} />
|
||||
<HelpIcon title='Depth for shallow clones. Leave empty or 0 for a full clone.' />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{method === ConnectionMethod.GITHUBAPP && (
|
||||
|
|
@ -1274,6 +1292,10 @@ export const ReposList = ({match, location}: RouteComponentProps) => {
|
|||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='NoProxy (optional)' field='noProxy' component={Text} />
|
||||
</div>
|
||||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='Depth (optional)' field='depth' component={NumberField} />
|
||||
<HelpIcon title='Depth for shallow clones. Leave empty or 0 for a full clone.' />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{method === ConnectionMethod.GOOGLECLOUD && (
|
||||
|
|
@ -1294,6 +1316,10 @@ export const ReposList = ({match, location}: RouteComponentProps) => {
|
|||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='NoProxy (optional)' field='noProxy' component={Text} />
|
||||
</div>
|
||||
<div className='argo-form-row'>
|
||||
<FormField formApi={formApi} label='Depth (optional)' field='depth' component={NumberField} />
|
||||
<HelpIcon title='Depth for shallow clones. Leave empty or 0 for a full clone.' />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -676,6 +676,7 @@ export interface Repository {
|
|||
insecureOCIForceHttp?: boolean;
|
||||
enableOCI: boolean;
|
||||
useAzureWorkloadIdentity: boolean;
|
||||
depth?: number;
|
||||
}
|
||||
|
||||
export interface RepositoryList extends ItemsList<Repository> {}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export interface HTTPSQuery {
|
|||
enableOCI: boolean;
|
||||
useAzureWorkloadIdentity: boolean;
|
||||
insecureOCIForceHttp: boolean;
|
||||
depth?: number;
|
||||
}
|
||||
|
||||
export interface SSHQuery {
|
||||
|
|
@ -31,6 +32,7 @@ export interface SSHQuery {
|
|||
proxy: string;
|
||||
noProxy: string;
|
||||
project?: string;
|
||||
depth?: number;
|
||||
}
|
||||
|
||||
export interface GitHubAppQuery {
|
||||
|
|
@ -48,6 +50,7 @@ export interface GitHubAppQuery {
|
|||
proxy: string;
|
||||
noProxy: string;
|
||||
project?: string;
|
||||
depth?: number;
|
||||
}
|
||||
|
||||
export interface GoogleCloudSourceQuery {
|
||||
|
|
@ -58,6 +61,7 @@ export interface GoogleCloudSourceQuery {
|
|||
proxy: string;
|
||||
noProxy: string;
|
||||
project?: string;
|
||||
depth?: number;
|
||||
}
|
||||
|
||||
export class RepositoriesService {
|
||||
|
|
@ -109,7 +113,8 @@ export class RepositoriesService {
|
|||
forceHttpBasicAuth: q.forceHttpBasicAuth,
|
||||
enableOCI: q.enableOCI,
|
||||
useAzureWorkloadIdentity: q.useAzureWorkloadIdentity,
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -134,7 +139,8 @@ export class RepositoriesService {
|
|||
forceHttpBasicAuth: q.forceHttpBasicAuth,
|
||||
enableOCI: q.enableOCI,
|
||||
useAzureWorkloadIdentity: q.useAzureWorkloadIdentity,
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -159,7 +165,8 @@ export class RepositoriesService {
|
|||
forceHttpBasicAuth: q.forceHttpBasicAuth,
|
||||
enableOCI: q.enableOCI,
|
||||
useAzureWorkloadIdentity: q.useAzureWorkloadIdentity,
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -184,7 +191,8 @@ export class RepositoriesService {
|
|||
forceHttpBasicAuth: q.forceHttpBasicAuth,
|
||||
enableOCI: q.enableOCI,
|
||||
useAzureWorkloadIdentity: q.useAzureWorkloadIdentity,
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp
|
||||
insecureOCIForceHttp: q.insecureOCIForceHttp,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -201,7 +209,8 @@ export class RepositoriesService {
|
|||
enableLfs: q.enableLfs,
|
||||
proxy: q.proxy,
|
||||
noProxy: q.noProxy,
|
||||
project: q.project
|
||||
project: q.project,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -218,7 +227,8 @@ export class RepositoriesService {
|
|||
enableLfs: q.enableLfs,
|
||||
proxy: q.proxy,
|
||||
noProxy: q.noProxy,
|
||||
project: q.project
|
||||
project: q.project,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -240,7 +250,8 @@ export class RepositoriesService {
|
|||
enableLfs: q.enableLfs,
|
||||
proxy: q.proxy,
|
||||
noProxy: q.noProxy,
|
||||
project: q.project
|
||||
project: q.project,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -262,7 +273,8 @@ export class RepositoriesService {
|
|||
enableLfs: q.enableLfs,
|
||||
proxy: q.proxy,
|
||||
noProxy: q.noProxy,
|
||||
project: q.project
|
||||
project: q.project,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -277,7 +289,8 @@ export class RepositoriesService {
|
|||
gcpServiceAccountKey: q.gcpServiceAccountKey,
|
||||
proxy: q.proxy,
|
||||
noProxy: q.noProxy,
|
||||
project: q.project
|
||||
project: q.project,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
@ -292,7 +305,8 @@ export class RepositoriesService {
|
|||
gcpServiceAccountKey: q.gcpServiceAccountKey,
|
||||
proxy: q.proxy,
|
||||
noProxy: q.noProxy,
|
||||
project: q.project
|
||||
project: q.project,
|
||||
depth: q.depth
|
||||
})
|
||||
.then(res => res.body as models.Repository);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue