Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions ui/src/app/settings/components/repo-details/repo-details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import * as React from 'react';
import {FormField} from 'argo-ui';
import {FormApi, Text} from 'react-form';
import {EditablePanel, EditablePanelItem} from '../../../shared/components';
import * as models from '../../../shared/models';
import {NewHTTPSRepoParams} from '../repos-list/repos-list';

export const RepoDetails = (props: {repo: models.Repository; save?: (params: NewHTTPSRepoParams) => Promise<void>}) => {
const {repo, save} = props;
const FormItems = (repository: models.Repository): EditablePanelItem[] => {
const items: EditablePanelItem[] = [
{
title: 'Type',
view: repository.type
},
{
title: 'Repository URL',
view: repository.repo
},
{
title: 'Username (optional)',
view: repository.username || '',
edit: (formApi: FormApi) => <FormField formApi={formApi} field='username' component={Text} />
},
{
title: 'Password (optional)',
view: repository.username ? '******' : '',
edit: (formApi: FormApi) => <FormField formApi={formApi} field='password' component={Text} componentProps={{type: 'password'}} />
}
];

if (repository.name) {
items.splice(1, 0, {
title: 'NAME',
view: repository.name
});
}

if (repository.project) {
items.splice(repository.name ? 2 : 1, 0, {
title: 'Project',
view: repository.project
});
}

if (repository.proxy) {
items.push({
title: 'Proxy (optional)',
view: repository.proxy
});
}

return items;
};

const newRepo = {
type: repo.type,
name: repo.name || '',
url: repo.repo,
username: repo.username || '',
password: repo.password || '',
tlsClientCertData: repo.tlsClientCertData || '',
tlsClientCertKey: repo.tlsClientCertKey || '',
insecure: repo.insecure || false,
enableLfs: repo.enableLfs || false,
proxy: repo.proxy || '',
project: repo.project || ''
};

return (
<EditablePanel
values={repo}
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.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case where only password is added without the username, there is no validation check and shows success box. That case can also be addressed here.

Copy link
Contributor Author

@ciiay ciiay Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I see the same thing when I wrote it but I aligned up with the current validation for the creation sliding panel. It only checks one way, so I kept it consistent. Do you think I should update both places or only the updating page?
Screen Shot 2022-06-30 at 1 23 30 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to update both places for better user experience?

})}
save={async input => {
const params: NewHTTPSRepoParams = {...newRepo};
params.username = input.username || '';
params.password = input.password || '';
save(params);
}}
title='CONNECTED REPOSITORY'
items={FormItems(repo)}
/>
);
};
7 changes: 7 additions & 0 deletions ui/src/app/settings/components/repos-list/repos-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
}

.argo-table-list {
.item-clickable {
cursor: pointer;

&:hover {
box-shadow: 1px 2px 3px rgba($argo-color-gray-9, 0.1), 0 0 0 1px rgba($argo-color-teal-5, 0.5);
}
}
.argo-dropdown {
float: right;
}
Expand Down
Loading