Skip to content

Commit

Permalink
re-fetch app details after initial config is saved
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Donnell committed Jan 30, 2024
1 parent a050687 commit a45c26f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions web/src/features/AppConfig/components/AppConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ class AppConfig extends Component<Props, State> {
}
window.addEventListener("resize", this.determineSidebarHeight);

if (!this.props.app) {
this.getApp();
if (!app) {
this.fetchApp();
} else {
this.setState({ app });
}
this.getConfig();
}
Expand Down Expand Up @@ -204,11 +206,7 @@ class AppConfig extends Component<Props, State> {
}
};

getApp = async () => {
if (this.props.app) {
return;
}

fetchApp = async (): Promise<App | undefined> => {
try {
const { slug } = this.props.params;
const res = await fetch(`${process.env.API_ENDPOINT}/app/${slug}`, {
Expand All @@ -221,6 +219,7 @@ class AppConfig extends Component<Props, State> {
if (res.ok && res.status == 200) {
const app = await res.json();
this.setState({ app });
return app;
}
} catch (err) {
console.log(err);
Expand Down Expand Up @@ -416,7 +415,8 @@ class AppConfig extends Component<Props, State> {
}

if (fromLicenseFlow) {
const hasPreflight = this.props.app.hasPreflight;
const app = await this.fetchApp();
const hasPreflight = app?.hasPreflight;

if (hasPreflight) {
navigate(`/${slug}/preflight`, { replace: true });
Expand Down Expand Up @@ -661,6 +661,7 @@ class AppConfig extends Component<Props, State> {

render() {
const {
app,
changed,
showConfigError,
configErrorMessage,
Expand All @@ -675,7 +676,6 @@ class AppConfig extends Component<Props, State> {
showValidationError,
} = this.state;
const { fromLicenseFlow, params, isHelmManaged } = this.props;
const app = this.props.app;

if (configLoading || !app) {
return (
Expand Down

0 comments on commit a45c26f

Please sign in to comment.