Skip to content

Commit

Permalink
♻️ : move stack creation route to stack pages
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit authored and cdubuisson committed Apr 9, 2020
1 parent 941b11f commit b2b28a3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
9 changes: 0 additions & 9 deletions src/main/client/app/pages/modules/modules-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ const modulesRoutes = [
breadcrumb: [{ text: 'Modules', to: { name: 'modules' } }, { text: 'Module description' }],
},
},
{
path: '/modules/:moduleId/run',
name: 'module-run',
component: () => import(/* webpackChunkName: "chunk-modules" */ '@/pages/stacks/stack-creation.vue'),
meta: {
authorities: ['ROLE_USER'],
breadcrumb: [{ text: 'Modules', to: { name: 'modules' } }, { text: 'Stack creation' }],
},
},
];

export default modulesRoutes;
16 changes: 15 additions & 1 deletion src/main/client/app/pages/modules/modules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
</b-button>

<b-button
:to="'/modules/'+module.id+'/run'"
title="Run this module"
variant="primary"
class="mr-1"
@click="createStack(module.id)"
>
<font-awesome-icon icon="rocket" />
</b-button>
Expand All @@ -66,6 +66,8 @@
import axios from 'axios';
import { AppCliBadge } from '@/shared/components';
import { v4 as uuidv4 } from 'uuid';
export default {
name: 'AppModules',
Expand All @@ -84,5 +86,17 @@
this.modules = response.data;
},
methods: {
async createStack(moduleId) {
await this.$router.push({
name: 'stack_creation',
params: {
stackId: uuidv4(),
moduleId,
},
});
},
},
};
</script>
14 changes: 13 additions & 1 deletion src/main/client/app/pages/stacks/stack-creation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@
AppStackVariable,
},
props: {
moduleId: {
type: String,
required: true,
},
stackId: {
type: String,
required: true,
},
},
data() {
return {
module: null,
Expand All @@ -116,10 +127,11 @@
},
async created() {
const result = await axios.get(`/api/modules/${this.$route.params.moduleId}`);
const result = await axios.get(`/api/modules/${this.moduleId}`);
this.module = result.data;
this.stack = {};
this.stack.id = this.stackId;
this.stack.moduleId = this.module.id;
this.stack.variableValues = {};
this.stack.variables = this.module.variables.map((variable) => ({
Expand Down
5 changes: 1 addition & 4 deletions src/main/client/app/pages/stacks/stack.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<div>
<p>This is not the final stack {{ $route.params.stackId }} page xD</p>
<router-view />
</div>
<router-view />
</template>

<script>
Expand Down
10 changes: 10 additions & 0 deletions src/main/client/app/pages/stacks/stacks-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ const stacksRoutes = [
breadcrumb: [{ text: 'Stacks', to: { name: 'stacks' } }, { text: 'Stack' }],
},
children: [
{
path: 'add',
name: 'stack_creation',
component: () => import(/* webpackChunkName: "chunk-stacks" */ '@/pages/stacks/stack-creation.vue'),
props: true,
meta: {
authorities: ['ROLE_USER'],
breadcrumb: [{ text: 'Stacks', to: { name: 'stacks' } }, { text: 'Stack creation' }],
},
},
{
path: 'edit',
name: 'stack_edition',
Expand Down

0 comments on commit b2b28a3

Please sign in to comment.