Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
ui/project: force refresh after settings change
Browse files Browse the repository at this point in the history
This is rather inelegant but the [RouterService.refresh] method is
not yet available to us.

[RouterService.refresh]: emberjs/rfcs#631
  • Loading branch information
jgwhite committed Sep 2, 2021
1 parent dec58a2 commit d367796
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ui/app/components/app-form/project-repository-settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Ember from 'ember';
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import RouterService from '@ember/routing/router-service';
Expand All @@ -8,6 +9,7 @@ import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { Project, Job } from 'waypoint-pb';
import parseUrl from 'parse-url';
import { later } from '@ember/runloop';

const FORMAT = {
HCL: 0,
Expand Down Expand Up @@ -223,6 +225,16 @@ export default class AppFormProjectRepositorySettings extends Component<ProjectS
try {
await this.api.upsertProject(this.project, this.authCase);
this.flashMessages.success('Settings saved');

// Refresh project route to get the latest state of the InitOp (if any)
this.router.refresh('workspace.projects.project');

if (!Ember.testing) {
// Optimistically refresh again a few seconds later, by which time
// the InitOp is likely to have completed
later(this.router, 'refresh', 'workspace.projects.project', 3000);
}

this.router.transitionTo('workspace.projects.project', this.project.name);
} catch (err) {
this.flashMessages.error('Failed to save Settings', { content: err.message, sticky: true });
Expand Down
4 changes: 4 additions & 0 deletions ui/app/services/poll-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export default class PollModelService extends Service {
taskFor(this.poll).cancelAll();
}

expedite(): void {
this.route?.refresh();
}

@task({
restartable: true,
maxConcurrency: 1,
Expand Down

0 comments on commit d367796

Please sign in to comment.