Skip to content

Commit

Permalink
add duplicate function for story
Browse files Browse the repository at this point in the history
  • Loading branch information
bennfocus committed Jan 29, 2019
1 parent 27e80ae commit f05aa9a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
36 changes: 28 additions & 8 deletions admin/frontend/src/components/NewStory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<label class="label">Story Workflow:</label>
</div>

<story-graph :info="storyInfo"
<story-graph v-if="storyInfo.source !== undefined" :info="storyInfo" :showButtons="showButtons"
@save="onSaveStory"></story-graph>

</div>
Expand All @@ -46,21 +46,41 @@
export default Vue.extend({
data() {
return {
storyName: '',
storyInfo: {
source: {type: 'click to set', settings: '{}'},
sink: {type: 'click to set', settings: '{}'},
status: 'INIT',
operators: []
} as StoryInfo
storyName: this.$route.params.storyName || '',
storyInfo: {} as StoryInfo,
showButtons: false
}
},
components: {
StoryGraph
},
created() {
this.fetchData()
},
methods: {
fetchData() {
let storyName = this.storyName
if (storyName != '') {
this.storyName += '_copy'
this.showButtons = true
request.getStory(storyName)
.then(storyInfo => {
this.storyInfo = storyInfo
})
}
else {
this.storyInfo = {
source: {type: 'click to set', settings: '{}'},
sink: {type: 'click to set', settings: '{}'},
status: 'INIT',
operators: []
} as StoryInfo
}
},
onSaveStory(newStoryInfo: StoryInfo) {
let storyNameCheck = StoryUtils.checkStoryName(this.storyName)
if (storyNameCheck !== true) {
Expand Down
4 changes: 4 additions & 0 deletions admin/frontend/src/components/Stories.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import {RunnerStatus} from '../lib/runner-utils';
</h4>
</div>
<div class="column is-narrow">
<router-link class="icon" :to="{ name: 'duplicate-story', params: { 'storyName': story.name } }">
<i class="fas fa-copy"></i>
</router-link>

<a class="icon" @click.stop.prevent="onRemoveStory(story)"><i
class="fas fa-trash-alt"></i></a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions admin/frontend/src/components/StoryGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ import {OpExecPos} from "../lib/story-utils";
import ConfirmationBox from './ConfirmationBox.vue'
export default Vue.extend({
props: ['info'],
props: ['info', 'showButtons'],
data() {
return {
changed: false,
changed: this.showButtons || false,
storyInfo: StoryUtils.copyStoryInfo(this.info),
taskEditor: {show: false, title: '', action: {} as TaskEditAction},
confirmation: {
Expand Down
1 change: 1 addition & 0 deletions admin/frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const router = new VueRouter({
{path: `${URL_PREFIX}/runner/:runnerName`, component: Runner, name: 'runner'},
{path: `${URL_PREFIX}/stories`, component: Stories, name: 'stories'},
{path: `${URL_PREFIX}/newstory`, component: NewStory, name: 'newstory'},
{path: `${URL_PREFIX}/newstory/from/:storyName`, component: NewStory, name: 'duplicate-story'},
{path: `${URL_PREFIX}/story/:storyName`, component: Story, name: 'story'},
{path: `${URL_PREFIX}/story/:storyName/runner`, component: Story, name: 'story-runners'},
{path: `${URL_PREFIX}/story/:storyName/statistics`, component: Story, name: 'story-statistics'},
Expand Down

0 comments on commit f05aa9a

Please sign in to comment.