Skip to content

Commit

Permalink
feat: added syncproject button
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Oct 23, 2023
1 parent d2a60ee commit f9ae8ba
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ember/app/components/project-detailed/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { dropTask } from 'ember-concurrency';

export default class ProjectDetailedComponent extends Component {
@service notification;
@service store;
@service fetch;

syncProject = dropTask(async () => {
try {
// post request to the api endpoint to sync the project
const request = await this.fetch.fetch(
`/api/projects/${this.args.project.id}/sync`,
{
method: 'POST',
}
);
if (request.ok) {
this.notification.success('Project synced successfully');
} else if (request.status === 404) {
this.notification.danger('Project not found');
} else if (request.status === 500) {
this.notification.danger('An error occurred while syncing the project');
}
} catch (e) {
this.notification.danger(e);
}
this.store.findRecord('project', this.args.project.id);
});
}
5 changes: 5 additions & 0 deletions ember/app/components/project-detailed/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@

<hr class='seperator' />
<DependencyTable @versionedDependencies={{@project.versionedDependencies}} />
<UkButton
@label='Sync'
@loading={{this.syncProject.isRunning}}
@onClick={{perform this.syncProject}}
/>
</div>

0 comments on commit f9ae8ba

Please sign in to comment.