mutations.js 4.0 KB
Newer Older
L
ligang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import _ from 'lodash'

export default {
21 22 23
  setProjectId (state, payload) {
    state.projectId = payload
  },
24 25 26
  setProjectCode (state, payload) {
    state.projectCode = payload
  },
L
ligang 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39
  setProjectName (state, payload) {
    state.projectName = payload
  },
  /**
   * set tasks
   * */
  setTasks (state, payload) {
    state.tasks = payload
  },
  /**
   * set locations
   * */
  setLocations (state, payload) {
40
    state.locations = payload
L
ligang 已提交
41 42 43 44 45
  },
  /**
   * add locations
   * */
  addLocations (state, payload) {
46
    state.locations = Object.assign(state.locations, {}, payload)
L
ligang 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59
  },
  /**
   * set connects
   * */
  setConnects (state, payload) {
    state.connects = payload
  },
  /**
   * set dag name
   */
  setName (state, payload) {
    state.name = payload
  },
G
gongzijian 已提交
60 61 62 63 64 65
  /**
   * set timeout
   */
  setTimeout (state, payload) {
    state.timeout = payload
  },
66
  /**
67
   * set tenantCode
68
   */
69 70
  setTenantCode (state, payload) {
    state.tenantCode = payload
71
  },
L
ligang 已提交
72 73 74 75 76 77 78
  /**
   * set global params
   */
  setGlobalParams (state, payload) {
    state.globalParams = payload
  },
  /**
B
break60 已提交
79
   * set description
L
ligang 已提交
80 81
   */
  setDesc (state, payload) {
B
break60 已提交
82
    state.description = payload
L
ligang 已提交
83
  },
84 85 86
  setReleaseState (state, payload) {
    state.releaseState = payload
  },
L
ligang 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
  /**
   * Whether to update the process definition
   */
  setSyncDefine (state, payload) {
    state.syncDefine = payload
  },
  /**
   * Whether to edit the parameters
   */
  setIsEditDag (state, payload) {
    state.isEditDag = payload
  },

  /**
   * edit state
   */
  setIsDetails (state, payload) {
    state.isDetails = payload
  },

  /**
   * reset params
   */
  resetParams (state, payload) {
111 112 113 114 115
    state.globalParams = (payload && payload.globalParams) || []
    state.tasks = (payload && payload.tasks) || []
    state.name = (payload && payload.name) || ''
    state.description = (payload && payload.description) || ''
    state.timeout = (payload && payload.timeout) || 0
116
    state.tenantCode = (payload && payload.tenantCode) || ''
117 118 119 120 121 122 123 124
    state.processListS = (payload && payload.processListS) || []
    state.resourcesListS = (payload && payload.resourcesListS) || []
    state.resourcesListJar = (payload && payload.resourcesListJar) || []
    state.projectListS = (payload && payload.projectListS) || []
    state.isDetails = (payload && payload.isDetails) || false
    state.runFlag = (payload && payload.runFlag) || ''
    state.locations = (payload && payload.locations) || {}
    state.connects = (payload && payload.connects) || []
L
ligang 已提交
125 126 127
  },
  /**
   * add task
128
   * @param {Task} task
L
ligang 已提交
129
   */
130 131
  addTask (state, task) {
    const i = _.findIndex(state.tasks, v => v.code === task.code)
L
ligang 已提交
132
    if (i !== -1) {
133
      state.tasks[i] = Object.assign(state.tasks[i], {}, task)
L
ligang 已提交
134
    } else {
135
      state.tasks.push(task)
L
ligang 已提交
136
    }
137
  },
138
  /**
139 140 141
   * remove task
   * @param {object} state
   * @param {string} code
142
   */
143 144
  removeTask (state, code) {
    state.tasks = state.tasks.filter(task => task.code !== code)
145 146 147 148 149 150 151 152 153 154 155
  },
  resetLocalParam (state, payload) {
    const tasks = state.tasks
    tasks.forEach((task, index) => {
      payload.forEach(p => {
        if (p.id === task.id) {
          tasks[index].params.localParams = p.localParam
        }
      })
    })
    state.tasks = tasks
L
ligang 已提交
156 157
  }
}