Skip to content

Commit

Permalink
feat: image repository (#222)
Browse files Browse the repository at this point in the history
* feat: image repository

* fix: feedback

* feat: domaing dns provider

* fix: reset form issue

* feat: pagination

* feat: git auth

* feat: git auth response

* fix: subgroups validation

* feat: image repository

* fix: feedback

* feat: domaing dns provider

* fix: reset form issue

* feat: pagination

* feat: git auth

* feat: git auth response

* fix: subgroups validation

* fix: ecr default value

* fix: org pagination
  • Loading branch information
CristhianF7 authored Aug 14, 2023
1 parent 05514f4 commit 6659487
Show file tree
Hide file tree
Showing 26 changed files with 416 additions and 388 deletions.
7 changes: 6 additions & 1 deletion components/autocomplete/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ForwardedRef, FunctionComponent } from 'react';
import React, { ForwardedRef, FunctionComponent, useMemo } from 'react';
import { Autocomplete as AutocompleteMUI, CircularProgress, SxProps } from '@mui/material';
import { ControllerRenderProps, FieldValues } from 'react-hook-form';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
Expand Down Expand Up @@ -35,6 +35,9 @@ const AutocompleteComponent: FunctionComponent<IAutocompleteProps> = ({
disabled,
...props
}) => {
// Unfortunately MaterialUI doesn't not update the dom state when no options are available
const value = useMemo(() => (options.length ? props.value : ''), [options.length, props.value]);

return (
<AutocompleteMUI
loading={loading}
Expand All @@ -51,6 +54,7 @@ const AutocompleteComponent: FunctionComponent<IAutocompleteProps> = ({
},
}}
{...props}
isOptionEqualToValue={(option: string, value: string) => option === value}
renderInput={(params) => (
<TextField
ref={params.InputProps.ref}
Expand All @@ -66,6 +70,7 @@ const AutocompleteComponent: FunctionComponent<IAutocompleteProps> = ({
)}
</InputAdornmentContainer>
}
value={value}
{...params}
label={label}
/>
Expand Down
4 changes: 2 additions & 2 deletions components/clusterDetails/clusterDetails.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { Story } from '@storybook/react';

import ClusterDetails from '.';

import { ClusterInfo } from '../clusterTable/clusterTable';
import { ClusterStatus, ClusterType } from '../../types/provision';
import { InstallationType } from '../../types/redux';

import ClusterDetails from '.';

export default {
title: 'Components/ClusterDetails',
component: ClusterDetails,
Expand Down
1 change: 1 addition & 0 deletions components/controlledFields/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function ControlledAutocomplete<T extends FieldValues>({
field.onBlur();
setIsBlur(true);
}}
value={options.length ? field.value : ''}
loading={loading}
placeholder={placeholder}
disabled={disabled}
Expand Down
62 changes: 62 additions & 0 deletions components/controlledFields/Radio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';
import { FormControlLabel, FormGroup, Radio, RadioGroup } from '@mui/material';
import { Control, Controller, UseControllerProps, FieldValues } from 'react-hook-form';

import { VOLCANIC_SAND } from '../../constants/colors';
import Typography from '../typography';

export interface ControlledTextFieldProps<T extends FieldValues> extends UseControllerProps<T> {
control: Control<T>;
required?: boolean;
rules: {
required: boolean;
pattern?: RegExp;
};
options: Array<{ label: string; value: string }>;
}

function ControlledRadio<T extends FieldValues>({
defaultValue,
name,
options,
required,
...props
}: ControlledTextFieldProps<T>) {
return (
<Controller
{...props}
name={name}
render={({ field }) => (
<FormGroup>
<RadioGroup defaultValue={defaultValue} name={name}>
{options.map(({ label, value }) => (
<FormControlLabel
key={label}
value={value}
control={
<Radio
{...field}
name={name}
required={required}
inputRef={field.ref}
value={value}
onChange={(e) => {
field.onChange(e);
}}
/>
}
label={
<Typography variant="body2" color={VOLCANIC_SAND}>
{label}
</Typography>
}
/>
))}
</RadioGroup>
</FormGroup>
)}
/>
);
}

export default ControlledRadio;
2 changes: 1 addition & 1 deletion components/flow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const nodeTypes: NodeTypes = {
};

export const Flow: FunctionComponent = () => {
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
const [nodes, , onNodesChange] = useNodesState(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
const onConnect = useCallback(
(params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)),
Expand Down
5 changes: 2 additions & 3 deletions containers/clusterForms/aws/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import TerminalLogs from '../../terminalLogs';
import { FormStep } from '../../../constants/installation';
import AuthForm from '../shared/authForm';
import ClusterRunning from '../shared/clusterRunning';

import AwsSetupForm from './setupForm';
import SetupForm from '../shared/setupForm';

const AWS_FORM_FLOW = {
[FormStep.AUTHENTICATION]: AuthForm,
[FormStep.SETUP]: AwsSetupForm,
[FormStep.SETUP]: SetupForm,
[FormStep.PROVISIONING]: TerminalLogs,
[FormStep.READY]: ClusterRunning,
};
Expand Down
85 changes: 0 additions & 85 deletions containers/clusterForms/aws/setupForm/index.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions containers/clusterForms/civo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import TerminalLogs from '../../terminalLogs';
import { FormStep } from '../../../constants/installation';
import AuthForm from '../shared/authForm';
import ClusterRunning from '../shared/clusterRunning';

import SetupForm from './setupForm';
import SetupForm from '../shared/setupForm';

const CIVO_FORM_FLOW = {
[FormStep.AUTHENTICATION]: AuthForm,
Expand Down
76 changes: 0 additions & 76 deletions containers/clusterForms/civo/setupForm/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useRef } from 'react';
import { Story } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { FormProvider, useForm } from 'react-hook-form';

import ClusterCreationForm, { ClusterConfig } from '.';
Expand All @@ -22,10 +23,7 @@ const DefaultTemplate: Story = () => {

return (
<FormProvider {...methods}>
<ClusterCreationForm
ref={formRef}
onFormSubmit={(config) => console.log('the form values =>', config)}
/>
<ClusterCreationForm ref={formRef} onFormSubmit={() => action('onSubmit')} />
<button onClick={handleClick}>Submit me</button>
</FormProvider>
);
Expand Down
1 change: 1 addition & 0 deletions containers/clusterForms/clusterCreation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ControlledSelect from '../../../components/controlledFields/Select';
import NumberInput from '../../../components/numberInput';
import Row from '../../../components/row';
import Button from '../../../components/button';

import { Form } from './clusterCreation.styled';

export type ClusterConfig = {
Expand Down
5 changes: 2 additions & 3 deletions containers/clusterForms/digitalocean/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import TerminalLogs from '../../terminalLogs';
import { FormStep } from '../../../constants/installation';
import AuthForm from '../shared/authForm';
import ClusterRunning from '../shared/clusterRunning';

import DigitalOceanSetupForm from './setupForm';
import SetupForm from '../shared/setupForm';

const DIGITAL_OCEAN_FORM_FLOW = {
[FormStep.AUTHENTICATION]: AuthForm,
[FormStep.SETUP]: DigitalOceanSetupForm,
[FormStep.SETUP]: SetupForm,
[FormStep.PROVISIONING]: TerminalLogs,
[FormStep.READY]: ClusterRunning,
};
Expand Down
Loading

0 comments on commit 6659487

Please sign in to comment.