Skip to content

Commit

Permalink
✨ : add delete module button
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Aug 12, 2022
1 parent b6513f3 commit a4766ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/client/app/pages/modules/module.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@
>
<font-awesome-icon icon="save" /> Save
</b-button>
<b-button
variant="danger"
class="ml-1"
@click="deleteModule"
>
<font-awesome-icon icon="save" /> Delete
</b-button>
</form>
</div>
</div>
Expand All @@ -160,6 +167,7 @@
import AppModuleVariable from '@/pages/modules/module-variable.vue';
import AppTerraformImageInput from '@/pages/modules/terraform-image-input.vue';
import {
deleteModule,
getModule,
refreshModule,
updateModule,
Expand Down Expand Up @@ -222,6 +230,19 @@
.then(() => displayNotification(this, { message: 'Module saved', variant: 'success' }))
.catch(({ error, message }) => displayNotification(this, { title: error, message, variant: 'danger' }));
},
async deleteModule() {
const confirmMessage = 'This will delete the module. '
+ 'Continue ?';
if (await displayConfirmDialog(this, { title: 'Delete Module', message: confirmMessage })) {
try {
this.module = await deleteModule(this.module.id);
displayNotification(this, { message: 'Module deleted', variant: 'success' });
this.$router.push({ name: 'modules' });
} catch ({ error, message }) {
displayNotification(this, { title: error, message, variant: 'danger' });
}
}
},
removeVar(variable) {
this.module.variables.splice(this.module.variables.findIndex((v) => v.name === variable.name), 1);
},
Expand Down
2 changes: 2 additions & 0 deletions src/main/client/app/shared/api/modules-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export const refreshModule = async (moduleId) => axios.post(`/api/modules/${modu
export const updateModule = async (module) => axios.put(`/api/modules/${module.id}`, module);

export const createModule = async (module) => axios.post('/api/modules', module);

export const deleteModule = async (moduleId) => axios.delete(`/api/modules/${moduleId}`);

0 comments on commit a4766ea

Please sign in to comment.