Fixed portal ux issues and minor style changes (#2940)

Signed-off-by: Amit Kumar Das <amit@chaosnative.com>
This commit is contained in:
Amit Kumar Das 2021-06-25 10:25:45 +05:30 committed by GitHub
parent f693470827
commit 48c079aa85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 22 deletions

View File

@ -14,6 +14,7 @@ import useStyles from './styles';
import { getProjectID } from '../../../utils/getSearchParams'; import { getProjectID } from '../../../utils/getSearchParams';
import Loader from '../../../components/Loader'; import Loader from '../../../components/Loader';
import { constants } from '../../../constants'; import { constants } from '../../../constants';
import { validateWorkflowName } from '../../../utils/validate';
interface SaveTemplateModalProps { interface SaveTemplateModalProps {
closeTemplate: () => void; closeTemplate: () => void;
@ -89,9 +90,14 @@ const SaveTemplateModal: React.FC<SaveTemplateModalProps> = ({
label="Name of the template" label="Name of the template"
value={templateName} value={templateName}
data-cy="WorkflowName" data-cy="WorkflowName"
helperText=""
required required
onChange={(e) => setTemplateName(e.target.value)} onChange={(e) => setTemplateName(e.target.value.toLowerCase())}
helperText={
validateWorkflowName(templateName)
? t('createWorkflow.chooseWorkflow.validate')
: ''
}
variant={validateWorkflowName(templateName) ? 'error' : 'primary'}
className={classes.InputFieldTemplate} className={classes.InputFieldTemplate}
/> />
<br /> <br />
@ -133,6 +139,7 @@ const SaveTemplateModal: React.FC<SaveTemplateModalProps> = ({
cloneResult.type === constants.success || cloneResult.type === constants.success ||
templateName.trim().length === 0 || templateName.trim().length === 0 ||
templateDesc.trim().length === 0 || templateDesc.trim().length === 0 ||
validateWorkflowName(templateName) ||
!yamlValid !yamlValid
} }
> >

View File

@ -169,6 +169,7 @@ const TableData: React.FC<TableDataProps> = ({
width="60%" width="60%"
open={isTemplateModalOpen} open={isTemplateModalOpen}
onClose={handleCloseTemplate} onClose={handleCloseTemplate}
disableBackdropClick
modalActions={ modalActions={
<ButtonOutlined onClick={handleCloseTemplate}> <ButtonOutlined onClick={handleCloseTemplate}>
&#x2715; &#x2715;

View File

@ -59,8 +59,10 @@ const useStyles = makeStyles((theme) => ({
'& p': { '& p': {
fontSize: '0.8125rem', fontSize: '0.8125rem',
fontWeight: 'bold', fontWeight: 'bold',
color: theme.palette.text.hint,
}, },
'& th': { '& th': {
color: theme.palette.text.hint,
backgroundColor: theme.palette.cards.background, backgroundColor: theme.palette.cards.background,
}, },
}, },

View File

@ -78,7 +78,7 @@ const useStyles = makeStyles((theme) => ({
'& th': { '& th': {
fontWeight: 'bold', fontWeight: 'bold',
fontSize: '0.8125rem', fontSize: '0.8125rem',
color: theme.palette.text.disabled, color: theme.palette.text.hint,
backgroundColor: theme.palette.cards.background, backgroundColor: theme.palette.cards.background,
}, },
}, },

View File

@ -17,7 +17,7 @@ const SelectMyHub = () => {
const [availableHubs, setAvailableHubs] = useState<MyHubDetail[]>([]); const [availableHubs, setAvailableHubs] = useState<MyHubDetail[]>([]);
// Get all MyHubs with status // Get all MyHubs with status
const { data, loading } = useQuery<HubStatus>(GET_HUB_STATUS, { const { data } = useQuery<HubStatus>(GET_HUB_STATUS, {
variables: { data: selectedProjectID }, variables: { data: selectedProjectID },
fetchPolicy: 'cache-and-network', fetchPolicy: 'cache-and-network',
}); });
@ -38,8 +38,23 @@ const SelectMyHub = () => {
}; };
useEffect(() => { useEffect(() => {
if (data?.getHubStatus.length) { if (data?.getHubStatus !== undefined) {
setAvailableHubs([...data.getHubStatus]); if (data.getHubStatus.length) {
const hubDetails: MyHubDetail[] = [];
data.getHubStatus.forEach((hub) => {
/**
* Push only available hubs
*/
if (hub.IsAvailable) {
hubDetails.push({
id: hub.id,
HubName: hub.HubName,
RepoBranch: hub.RepoBranch,
RepoURL: hub.RepoURL,
});
}
});
setAvailableHubs(hubDetails);
data.getHubStatus.forEach((hubData) => { data.getHubStatus.forEach((hubData) => {
if (hubData.HubName.toLowerCase() === 'chaos hub') { if (hubData.HubName.toLowerCase() === 'chaos hub') {
setSelectedHub('Chaos Hub'); setSelectedHub('Chaos Hub');
@ -48,7 +63,8 @@ const SelectMyHub = () => {
} }
}); });
} }
}, [loading]); }
}, [data]);
const classes = useStyles(); const classes = useStyles();
return ( return (

View File

@ -45,7 +45,7 @@ const ChoosePreDefinedExperiments: React.FC<ChoosePreDefinedExperimentsProps> =
const [workflowList, setWorkflowlist] = useState([]); const [workflowList, setWorkflowlist] = useState([]);
// Get all MyHubs with status // Get all MyHubs with status
const { data, loading } = useQuery<HubStatus>(GET_HUB_STATUS, { const { data } = useQuery<HubStatus>(GET_HUB_STATUS, {
variables: { data: selectedProjectID }, variables: { data: selectedProjectID },
fetchPolicy: 'cache-and-network', fetchPolicy: 'cache-and-network',
}); });
@ -111,7 +111,21 @@ const ChoosePreDefinedExperiments: React.FC<ChoosePreDefinedExperimentsProps> =
useEffect(() => { useEffect(() => {
if (data?.getHubStatus !== undefined) { if (data?.getHubStatus !== undefined) {
if (data.getHubStatus.length) { if (data.getHubStatus.length) {
setAvailableHubs([...data.getHubStatus]); const hubDetails: MyHubDetail[] = [];
data.getHubStatus.forEach((hub) => {
/**
* Push only available hub
*/
if (hub.IsAvailable) {
hubDetails.push({
id: hub.id,
HubName: hub.HubName,
RepoBranch: hub.RepoBranch,
RepoURL: hub.RepoURL,
});
}
});
setAvailableHubs(hubDetails);
} }
data.getHubStatus.forEach((hubData) => { data.getHubStatus.forEach((hubData) => {
if (hubData.HubName.toLowerCase() === 'chaos hub') { if (hubData.HubName.toLowerCase() === 'chaos hub') {
@ -126,7 +140,7 @@ const ChoosePreDefinedExperiments: React.FC<ChoosePreDefinedExperimentsProps> =
} }
}); });
} }
}, [loading]); }, [data]);
return ( return (
<AccordionDetails> <AccordionDetails>

View File

@ -279,11 +279,13 @@ const TuneWorkflow = forwardRef((_, ref) => {
*/ */
const getSelectedWorkflowDetails = () => { const getSelectedWorkflowDetails = () => {
localforage.getItem('workflow').then((workflow) => { localforage.getItem('workflow').then((workflow) => {
if (workflow) {
setWorkflow({ setWorkflow({
name: (workflow as WorkflowDetailsProps).name, name: (workflow as WorkflowDetailsProps).name,
crd: (workflow as WorkflowDetailsProps).CRDLink, crd: (workflow as WorkflowDetailsProps).CRDLink,
description: (workflow as WorkflowDetailsProps).description, description: (workflow as WorkflowDetailsProps).description,
}); });
}
}); });
localforage.getItem('selectedScheduleOption').then((value) => { localforage.getItem('selectedScheduleOption').then((value) => {
/** /**