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
4 changes: 2 additions & 2 deletions hub/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@
"regions_description": "Select regions to run workflows and store artifacts",
"regions_placeholder": "Select regions",
"storage_backend": {
"type": "Type",
"type_description": "Type of backend storage",
"type": "Storage",
"type_description": "Backend storage",
"type_placeholder": "Select type",
"credentials": {
"access_key_id": "Access key ID",
Expand Down
4 changes: 2 additions & 2 deletions hub/src/pages/Project/Details/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useDeleteProjectsMutation, useGetProjectQuery, useUpdateProjectMembersM
import { selectAuthToken, selectUserData } from 'App/slice';

import { ProjectMembers } from '../../Members';
import { getProjectRoleByUserName } from '../../utils';
import { getLambdaStorageTypeLabel, getProjectRoleByUserName } from '../../utils';

import { BackendTypesEnum } from '../../Form/types';

Expand Down Expand Up @@ -189,7 +189,7 @@ export const ProjectSettings: React.FC = () => {

<div>
<Box variant="awsui-key-label">{t('projects.edit.lambda.storage_backend.type')}</Box>
<div>{data.backend.storage_backend.type}</div>
<div>{getLambdaStorageTypeLabel(data.backend.storage_backend.type)}</div>
</div>

<div>
Expand Down
4 changes: 4 additions & 0 deletions hub/src/pages/Project/Form/AWS/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export const AWSBackend: React.FC<IProps> = ({ loading }) => {

changeFormHandler().catch(console.log);
isFirstRender.current = false;

return () => {
if (requestRef.current) requestRef.current.abort();
};
}, []);

const debouncedChangeFormHandler = useCallback(debounce(changeFormHandler, 1000), []);
Expand Down
4 changes: 4 additions & 0 deletions hub/src/pages/Project/Form/Azure/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export const AzureBackend: React.FC<IProps> = ({ loading }) => {

changeFormHandler().catch(console.log);
isFirstRender.current = false;

return () => {
if (requestRef.current) requestRef.current.abort();
};
}, []);

const debouncedChangeFormHandler = useCallback(debounce(changeFormHandler, 1000), []);
Expand Down
4 changes: 4 additions & 0 deletions hub/src/pages/Project/Form/GCP/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ export const GCPBackend: React.FC<IProps> = ({ loading }) => {
const file = new File([''], fileName, { type: 'text/plain' });
setFiles([file]);
}

return () => {
if (requestRef.current) requestRef.current.abort();
};
}, []);

const onChangeFormField = () => {
Expand Down
13 changes: 12 additions & 1 deletion hub/src/pages/Project/Form/Lambda/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { debounce } from 'lodash';
import { debounce, get as _get } from 'lodash';

import {
FormInput,
Expand Down Expand Up @@ -49,6 +49,13 @@ export const LambdaBackend: React.FC<IProps> = ({ loading }) => {
return;
}

if (
backendFormValues?.storage_backend?.credentials &&
!_get(backendFormValues, FIELD_NAMES.STORAGE_BACKEND.CREDENTIALS.ACCESS_KEY) &&
!_get(backendFormValues, FIELD_NAMES.STORAGE_BACKEND.CREDENTIALS.SECRET_KEY)
)
backendFormValues.storage_backend.credentials = null;

clearErrors('backend');

try {
Expand Down Expand Up @@ -117,6 +124,10 @@ export const LambdaBackend: React.FC<IProps> = ({ loading }) => {

changeFormHandler().catch(console.log);
isFirstRender.current = false;

return () => {
if (requestRef.current) requestRef.current.abort();
};
}, []);

const debouncedChangeFormHandler = useCallback(debounce(changeFormHandler, 1000), []);
Expand Down
5 changes: 5 additions & 0 deletions hub/src/pages/Project/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const ProjectForm: React.FC<IProps> = ({ initialValues, onCancel, loading
const { handleSubmit, control, watch, setError, reset, clearErrors } = formMethods;

const backendType = watch('backend.type');
const backendTemp = watch('backend');
const projectNameValue = watch('project_name');

const backendOptions: TBackendOption[] = useMemo(() => {
Expand Down Expand Up @@ -113,8 +114,12 @@ export const ProjectForm: React.FC<IProps> = ({ initialValues, onCancel, loading
type: value as TProjectBackendType,
},
});

console.log('Reset');
};

console.log('backendTemp', backendTemp);

const renderUnsupportedBackedMessage = (backendName: string, backendTypeName: BackendTypesEnum) => {
return (
<Grid gridDefinition={[{ colspan: 8 }]}>
Expand Down
25 changes: 20 additions & 5 deletions hub/src/pages/Project/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ import { useBreadcrumbs, useCollection } from 'hooks';
import { ROUTES } from 'routes';
import { useGetProjectsQuery } from 'services/project';

import { BackendTypesEnum } from '../Form/types';

interface IProjectSettingsNodeProps {
settingsKey: string;
settingsValue: string;
}

export const ProjectSettingsNode: React.FC<IProjectSettingsNodeProps> = ({ settingsKey, settingsValue }) => {
return (
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>{settingsKey}:</div> {settingsValue}
<div style={{ display: 'flex', justifyContent: 'space-between', gap: '10px' }}>
<div>{settingsKey}:</div>{' '}
<span style={{ whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' }} title={settingsValue}>
{settingsValue}
</span>
</div>
);
};
Expand Down Expand Up @@ -70,27 +75,37 @@ export const ProjectList: React.FC = () => {

const getProjectSettings = (project: IProject) => {
switch (project.backend.type) {
case 'aws':
case BackendTypesEnum.AWS:
return (
<div>
<ProjectSettingsNode settingsKey="Region" settingsValue={project.backend.region_name_title} />
<ProjectSettingsNode settingsKey="Bucket" settingsValue={project.backend.s3_bucket_name} />
</div>
);
case 'azure':

case BackendTypesEnum.AZURE:
return (
<div>
<ProjectSettingsNode settingsKey="Location" settingsValue={project.backend.location} />
<ProjectSettingsNode settingsKey="Storage account" settingsValue={project.backend.storage_account} />
</div>
);
case 'gcp':

case BackendTypesEnum.GCP:
return (
<div>
<ProjectSettingsNode settingsKey="Region" settingsValue={project.backend.region} />
<ProjectSettingsNode settingsKey="Bucket" settingsValue={project.backend.bucket_name} />
</div>
);

case BackendTypesEnum.LAMBDA:
return (
<div>
<ProjectSettingsNode settingsKey="Regions" settingsValue={project.backend.regions.join(', ')} />
<ProjectSettingsNode settingsKey="Bucket" settingsValue={project.backend.storage_backend.bucket_name} />
</div>
);
case 'local':
return '-';
}
Expand Down
4 changes: 4 additions & 0 deletions hub/src/pages/Project/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const getProjectRoleByUserName = (project: IProject, userName: IProjectMember['user_name']): TProjectRole | null => {
return project.members.find((m) => m.user_name === userName)?.project_role ?? null;
};

export const getLambdaStorageTypeLabel = (type: TProjectBackendLambda['storage_backend']['type']) => {
return { aws: 'AWS S3' }[type];
};
1 change: 0 additions & 1 deletion hub/src/types/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ declare interface IProjectLambdaBackendValues {
bucket_name: null | {
selected?: string,
values: { value: string, label: string}[]
// values: TAwsBucket[]
}
},
}
Expand Down