Skip to content

Commit

Permalink
fix: [IDP-3201]: Fix URL case for harness datasource and CI/CD Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinkya-harness committed Jul 15, 2024
1 parent 32d285f commit 6ff1578
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function ExecutionList() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [env]);

const [cicd, setCicd] = useState<string>('CI');
const [pipelineIdValue, setPipelineIdValue] = useState<string>(pipelineId);
const [serviceIdValue, setServiceIdValue] = useState<string>('');

const {
status: state,
currTableData,
Expand All @@ -119,8 +123,8 @@ function ExecutionList() {
currProject: projectToUse,
pageSize,
page,
pipelineId,
serviceId,
pipelineId: pipelineIdValue,
serviceId: serviceIdValue,
env: envToUse,
backendBaseUrl,
refresh,
Expand Down Expand Up @@ -299,6 +303,42 @@ function ExecutionList() {
</FormControl>
);

const changeFunction = (event: SelectChangeEvent<string>) => {
const newValue = event.target.value as string;
setCicd(newValue);
if (newValue === 'CI') {
setServiceIdValue('');
setPipelineIdValue(pipelineId);
} else if (newValue === 'CD') {
setPipelineIdValue('');
setServiceIdValue(serviceId);
}
};

const OldUrlDropDown = (
<FormControl fullWidth>
<InputLabel
htmlFor="CI/CD"
classes={{
root: classes.label,
}}
>
CI / CD
</InputLabel>
<Select
displayEmpty
labelId="CI/CD"
id="CI/CD"
value={cicd}
onChange={changeFunction}
>
<MenuItem value="CI">CI</MenuItem>
<MenuItem value="CD">CD</MenuItem>
</Select>
<FormHelperText />
</FormControl>
);

const DropDownComponent = (
<Grid container spacing={3} marginBottom={4} marginTop={0} marginLeft={0}>
{envIds.length > 1 && !isNewAnnotationPresent ? (
Expand All @@ -316,6 +356,11 @@ function ExecutionList() {
{NewUrlDropDown}
</Grid>
) : null}
{!isNewAnnotationPresent ? (
<Grid item md={3}>
{OldUrlDropDown}
</Grid>
) : null}
</Grid>
);

Expand Down
7 changes: 3 additions & 4 deletions plugins/harness-ci-cd/src/hooks/useGetExecutionsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const useGetExecutionsList = ({
'content-type': 'application/json',
Authorization: value,
});

let body;
const identifiers: string[] = [];
if (serviceId) {
body = JSON.stringify({
filterType: 'PipelineExecution',
Expand All @@ -61,10 +63,7 @@ const useGetExecutionsList = ({
},
},
});
}

const identifiers: string[] = [];
if (pipelineId && pipelineId.trim()) {
} else if (pipelineId && pipelineId.trim()) {
pipelineId.split(',').forEach(item => {
const trimmedString = item.trim();
if (trimmedString) {
Expand Down

0 comments on commit 6ff1578

Please sign in to comment.