Skip to content

Commit

Permalink
fix: Bug in edit support in Sources tab; Input to loader (#17588) (#1…
Browse files Browse the repository at this point in the history
…8800) (#18801)

Co-authored-by: Keith Chong <[email protected]>
  • Loading branch information
gcp-cherry-pick-bot[bot] and keithchong authored Jun 24, 2024
1 parent 16c20a8 commit 00fc93b
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export const ApplicationParameters = (props: {
</div>
</React.Fragment>
)}
<DataLoader input={app} load={application => getSourceFromSources(application, index)}>
<DataLoader input={app.spec.sources[index]} load={src => getSourceFromAppSources(src, app.metadata.name, app.spec.project, index, 0)}>
{(details: models.RepoAppDetails) => getEditablePanelForOneSource(details, index, source)}
</DataLoader>
</div>
Expand Down Expand Up @@ -986,17 +986,12 @@ function gatherDetails(
}

// For Sources field. Get one source with index i from the list
async function getSourceFromSources(app: models.Application, i: number) {
const sources: models.ApplicationSource[] = app.spec.sources;
if (sources && i < sources.length) {
const aSource = sources[i];
const repoDetail = await services.repos.appDetails(aSource, app.metadata.name, app.spec.project, i, 0).catch(() => ({
type: 'Directory' as models.AppSourceType,
path: aSource.path
}));
return repoDetail;
}
return null;
async function getSourceFromAppSources(aSource: models.ApplicationSource, name: string, project: string, index: number, version: number) {
const repoDetail = await services.repos.appDetails(aSource, name, project, index, version).catch(() => ({
type: 'Directory' as models.AppSourceType,
path: aSource.path
}));
return repoDetail;
}

// Delete when source field is removed
Expand Down

0 comments on commit 00fc93b

Please sign in to comment.