Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): [KDL6-196] validate newproject inputs #1085

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { FC } from 'react';
import styles from './CapabilitiesSelector.module.scss';
import { useReactiveVar } from '@apollo/client';
import { selectedCapabilities } from 'Graphql/client/cache';
import { BottomComponentProps } from '../Breadcrumbs/components/Crumb/Crumb';
import { GetCapabilities_capabilities } from 'Graphql/queries/types/GetCapabilities';
import CapabilitiesItem from './CapabilitiesItem/CapabilitiesItem';
Expand All @@ -10,10 +8,6 @@ type Props = {
capabilities: GetCapabilities_capabilities[] | undefined;
};

function sortCapability(capability1: GetCapabilities_capabilities) {
return capability1.default ? 1 : -1;
}

const CapabilitiesSelector: FC<Props & BottomComponentProps> = ({ capabilities, ...props }) => {
return (
<div className={styles.container}>
Expand Down
1 change: 0 additions & 1 deletion app/ui/src/Graphql/client/hooks/useNewProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function useNewProject(section: keyof NewProject) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
newState[section].errors[key] = value;

newProject(newState);
}

Expand Down
3 changes: 1 addition & 2 deletions app/ui/src/Pages/NewProject/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function NewProject() {
const type = data.repository.values.type;

const stepsWithData: (StepNames.INFORMATION | StepNames.EXTERNAL)[] = useMemo(() => {
return [StepNames.INFORMATION, repoTypeToStepName[type || '']];
return [StepNames.INFORMATION, StepNames.EXTERNAL, repoTypeToStepName[type || '']];
}, [type]);

// We want to execute this on on component mount and unmount
Expand Down Expand Up @@ -151,7 +151,6 @@ function NewProject() {

const values = Object.values(actStepData.values).filter((v) => typeof v !== 'boolean');
const completed = values && values.every((v) => !!v) && !error;

updateState(completed, error);
return !error;
} else if (!hasData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Props = {

const authMethods = [RepositoryAuthMethod.PASSWORD, RepositoryAuthMethod.TOKEN];

let authOk = false;

function ExternalRepository({ showErrors }: Props) {
const project = useReactiveVar(newProject);
const { updateValue, updateError, clearError } = useNewProject('externalRepository');
Expand All @@ -26,6 +28,16 @@ function ExternalRepository({ showErrors }: Props) {
errors: { url: urlError, credential: credentialError, username: usernameError, authMethod: authMethodError },
} = project.externalRepository;

React.useEffect(() => {
if (authMethod == 'PASSWORD' || authMethod == 'TOKEN') {
updateValue('authMethod', '');
authOk = false;
} else {
authOk = true;
}
//eslint-disable-next-line
}, []);

return (
<div className={styles.container}>
<h3 className={styles.title}>Your external repository</h3>
Expand Down Expand Up @@ -69,16 +81,18 @@ function ExternalRepository({ showErrors }: Props) {
whiteColor={false}
showSelectAllOption={false}
shouldSort={true}
defaultOption=""
onChange={(value: string) => {
updateValue('authMethod', value);
clearError('authMethod');
authOk = true;
}}
formSelectedOption={authMethod ?? undefined}
formSelectedOption={authMethod}
className={styles.authMethod}
error={showErrors ? authMethodError : ''}
/>

{authMethod && (
{authOk && (
<TextInput
label={authMethod}
onChange={(value: string) => {
Expand Down
Loading