Skip to content

Commit

Permalink
Merge pull request #1852 from habitat-sh/sougata/ui_version_bug
Browse files Browse the repository at this point in the history
Fix UI version bug
  • Loading branch information
mwrock authored Oct 30, 2024
2 parents 4b009c5 + 2827264 commit fa2e40b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion components/builder-web/app/client/depot-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export function getLatest(origin: string, pkg: string, target: string) {
}

export function getLatestInChannel(origin: string, name: string, channel: string, target: string) {
const url = `${urlPrefix}/depot/channels/${origin}/${channel}/pkgs/${name}/latest?target=${target}`;
const tgt = target ? `?target=${target}` : ``;
const url = `${urlPrefix}/depot/channels/${origin}/${channel}/pkgs/${name}/latest${tgt}`;

return new Promise((resolve, reject) => {
fetch(url, opts())
Expand Down
29 changes: 18 additions & 11 deletions components/builder-web/app/package/package/package.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,22 @@ export class PackageComponent implements OnInit, OnDestroy {
// Just ensure we are on the latest page
if (!this.ident.version && !this.ident.release) {
this.fetchLatest();
this.fetchLatestStable();
if (target === undefined) {
this.fetchLatestStable('');
}
else {
this.fetchLatestStable(this.target);
}


// This check whether channel is exist in current origin
if (this.isChannelExistInOrigin(latestLTS)) {
this.fetchCurrentLts();
if (target === undefined) {
this.fetchCurrentLts('');
}
else {
this.fetchCurrentLts(this.target);
}
}
}
});
Expand Down Expand Up @@ -319,17 +330,13 @@ export class PackageComponent implements OnInit, OnDestroy {
this.store.dispatch(setCurrentPackageTarget(currentTarget));
}

private fetchLatestStable() {
// if (this.getLatestPlatform(this.target) !== undefined) {
this.store.dispatch(fetchLatestInChannel(this.origin, this.name, 'stable', this.getLatestPlatform(this.target)));
// }
private fetchLatestStable(target: string) {
this.store.dispatch(fetchLatestInChannel(this.origin, this.name, 'stable', target));
}

private fetchCurrentLts() {
if (this.getLatestPlatform(this.target) !== undefined) {
this.store.dispatch(fetchLatestInChannel(this.origin, this.name, latestLTS, this.getLatestPlatform(this.target)));
}
}
private fetchCurrentLts(target: string) {
this.store.dispatch(fetchLatestInChannel(this.origin, this.name, latestLTS, target));
}

private fetchPackageSettings() {
this.store.dispatch(fetchPackageSettings(this.origin, this.name, this.token));
Expand Down

0 comments on commit fa2e40b

Please sign in to comment.