Skip to content

Commit

Permalink
feat(ui): rename external repository components to just repository (#…
Browse files Browse the repository at this point in the history
…1092)

- renamed components
- updated tests
- upgraded lint
  • Loading branch information
alexrodfe committed Dec 20, 2024
1 parent 4d29eca commit 5c9281a
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 482 deletions.
6 changes: 3 additions & 3 deletions app/ui/cypress/integration/newProject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ const createProject = (name: string, id: string, customResponse?: Object) => {
// Go to the next step
cy.getByTestId('nextButton').click();

cy.getByTestId('externalRepositoryInputs').find('input').eq(0).type('http://test.com');
cy.getByTestId('externalRepositoryInputs').find('input').eq(1).type('username-test');
cy.getByTestId('repositoryDetailsInputs').find('input').eq(0).type('http://test.com');
cy.getByTestId('repositoryDetailsInputs').find('input').eq(1).type('username-test');
cy.contains('TOKEN').click();

cy.getByTestId('externalRepositoryInputs').find('input').eq(2).type('token-test');
cy.getByTestId('repositoryDetailsInputs').find('input').eq(2).type('token-test');

// Go to the next step
cy.getByTestId('nextButton').click();
Expand Down
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
4 changes: 2 additions & 2 deletions app/ui/src/Pages/NewProject/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import useUnloadPrompt from 'Hooks/useUnloadPrompt/useUnloadPrompt';
import { newProject } from 'Graphql/client/cache';
import SidebarTop from 'Components/Layout/Page/DefaultPage/SidebarTop';
import SidebarInformation from './pages/SidebarComponents/Information/SidebarInformation';
import SidebarExternalRepository from './pages/SidebarComponents/SidebarExternalRepository/SidebarExternalRepository';
import SidebarRepository from './pages/SidebarComponents/SidebarRepository/SidebarRepository';
import useNewProject from 'Graphql/client/hooks/useNewProject';

enum Steps {
Expand Down Expand Up @@ -155,7 +155,7 @@ function NewProject() {
case StepNames.INFORMATION:
return <SidebarInformation />;
case StepNames.DETAILS:
return <SidebarExternalRepository />;
return <SidebarRepository />;
default:
return <></>;
}
Expand Down

This file was deleted.

40 changes: 0 additions & 40 deletions app/ui/src/Pages/NewProject/pages/Repository/Repository.tsx

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { validateMandatoryField, validateUrl } from './ExternalRepositoryUtils';
import { validateMandatoryField, validateUrl } from './RepositoryDetailsUtils';

describe('ExternalRepositoryUtils', () => {
describe('RepositoryDetailsUtils', () => {
describe('validateUrl', () => {
it.each`
url | expected
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,67 @@
import * as React from 'react';
import Repository from './components/ExternalRepository/ExternalRepository';
import { SpinnerCircular, TextInput, Select } from 'kwc';

Check warning on line 2 in app/ui/src/Pages/NewProject/pages/RepositoryDetails/RepositoryDetails.tsx

View workflow job for this annotation

GitHub Actions / quality-checks

'Select' is defined but never used
import IconLink from '@material-ui/icons/Link';
import styles from './RepositoryDetails.module.scss';
import useNewProject from 'Graphql/client/hooks/useNewProject';
import { useReactiveVar } from '@apollo/client';
import { newProject } from 'Graphql/client/cache';
import { validateMandatoryField, validateUrl } from './RepositoryDetailsUtils';
import { getErrorMsg } from 'Utils/string';

type Props = {
showErrors: boolean;
};

function RepositoryDetails({ showErrors }: Props) {
const project = useReactiveVar(newProject);
const { updateValue, updateError, clearError } = useNewProject('repository');

if (!project) return <SpinnerCircular />;

const {
values: { url, username },
errors: { url: urlError, username: usernameError },
} = project.repository;

return (
<div>
<Repository showErrors={showErrors} />
<div className={styles.container}>
<h3 className={styles.title}>Your repository</h3>
<div className={styles.formContainer} data-testid={'repositoryDetailsInputs'}>
<TextInput
label="url"
onChange={(value: string) => {
updateValue('url', value);
clearError('url');
}}
onBlur={() => {
const isValidUrl = validateUrl(url);
updateError('url', getErrorMsg(isValidUrl));
}}
error={showErrors ? urlError : ''}
customClassname={styles.form}
formValue={url}
Icon={IconLink}
showClearButton
helpText="The HTTP(S) or GIT 'clone' URL of an existing repository."
/>
<TextInput
label="username"
onChange={(value: string) => {
updateValue('username', value);
clearError('username');
}}
onBlur={() => {
const isValidUsername = validateMandatoryField(username);
updateError('username', getErrorMsg(isValidUsername));
}}
error={showErrors ? usernameError : ''}
customClassname={styles.form}
formValue={username}
showClearButton
/>
</div>
</div>
</div>
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Props = {
size?: SIZE;
shouldAnimate?: boolean;
};
function RepositoryTypeComponent({ squareLocation, size = SIZE.MEDIUM, customSize, shouldAnimate = true }: Props) {
function RepositoryIcon({ squareLocation, size = SIZE.MEDIUM, customSize, shouldAnimate = true }: Props) {
const side = customSize ? customSize : sizePixels[size];
return (
<div
Expand All @@ -42,4 +42,4 @@ function RepositoryTypeComponent({ squareLocation, size = SIZE.MEDIUM, customSiz
);
}

export default memo(RepositoryTypeComponent);
export default memo(RepositoryIcon);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import styles from '../SidebarComponents.module.scss';

const SidebarExternalRepository = () => (
const SidebarRepository = () => (
<div className={styles.sidebar}>
<p className={styles.line}>In this page you can set up the external repository information.</p>
<p className={styles.line}>
Expand All @@ -15,4 +15,4 @@ const SidebarExternalRepository = () => (
</div>
);

export default SidebarExternalRepository;
export default SidebarRepository;
Loading

0 comments on commit 5c9281a

Please sign in to comment.