Skip to content

Commit

Permalink
feature/inspector-unselect-flow-after-save (#783)
Browse files Browse the repository at this point in the history
* Inspector unselect flow after save

* update version

* Set flow unselected when flow is not on the diaplay page
  • Loading branch information
yumiguan authored Sep 7, 2023
1 parent 3a53db4 commit 35b41d9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
21 changes: 10 additions & 11 deletions frontend/src/store/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export default {
setSelectedFlows (state, selectedFlows) {
state.selectedFlows = selectedFlows
},
cleaerSelectedFlows (state) {
removeSelectedFlowsByIndex (state, index) {
state.selectedFlows.splice(index, 1)
},
clearSelectedFlows (state) {
state.selectedFlows = []
},
addSelectedFlow (state, flow) {
Expand Down Expand Up @@ -130,12 +133,6 @@ export default {
loadFlowList ({ state, commit }) {
api.searchFlowList(state.selectedFlowFilter)
.then(response => {
// selected
for (const flow of response.data) {
if (state.selectedIds.includes(flow.id)) {
flow['_checked'] = true
}
}
// highlight
for (const flow of response.data) {
if (flow.id === (state.focusedFlow && state.focusedFlow.id)) {
Expand All @@ -159,18 +156,20 @@ export default {
api.deleteAllFlow()
.then(response => {
commit('clearSelectedId')
commit('cleaerSelectedFlows')
commit('clearSelectedFlows')
}).catch(error => {
bus.$emit('msg.error', 'Clear flow error: ' + error.data.message)
return
})
bus.$emit('msg.success', 'Clear Inspector success!')
},
saveSelectedFlow ({ state, dispatch }) {
saveSelectedFlow ({ state, commit, dispatch }) {
api.saveSelectedFlow(state.selectedIds)
.then(response => {
dispatch('loadDataMap')
bus.$emit('msg.success', state.selectedIds.length + ' flow saved!')
dispatch('loadDataMap')
commit('clearSelectedFlows')
commit('clearSelectedId')
})
.catch(error => {
bus.$emit('msg.error', 'Save flow error: ' + error.data.message)
Expand All @@ -187,7 +186,7 @@ export default {
commit('clearFocusedFlowDetail')
}
commit('clearSelectedId')
commit('cleaerSelectedFlows')
commit('clearSelectedFlows')
bus.$emit('msg.success', selectedIdLength + ' flow deleted!')
})
.catch(error => {
Expand Down
37 changes: 28 additions & 9 deletions frontend/src/views/inspector/FlowList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -353,24 +353,43 @@ export default {
refreshFlowList () {
let displayFlowList = []
let searchStr = typeof(this.searchStr) === 'string' ? this.searchStr.trim() : ''
// Search
if(!searchStr){
displayFlowList = this.originFlowList
} else {
// Split searchStr by one or more (spaces, |)
let searchStrList = searchStr.split(/\|+/)
for(const idx in searchStrList){
searchStrList[idx] = searchStrList[idx].trim()
searchStrList[idx] = searchStrList[idx].split(/\s+/)
}
for (const flow of this.originFlowList) {
this.isMatch(flow.request.url, searchStrList) ? displayFlowList.push(flow) : null
}
}
// Split searchStr by one or more (spaces, |)
let searchStrList = searchStr.split(/\|+/)
for(const idx in searchStrList){
searchStrList[idx] = searchStrList[idx].trim()
searchStrList[idx] = searchStrList[idx].split(/\s+/)
}
for (const flow of this.originFlowList) {
this.isMatch(flow.request.url, searchStrList) ? displayFlowList.push(flow) : null
}
// Page
this.displayFlowCount = displayFlowList.length
this.pageCount = Math.max(Math.ceil(this.displayFlowCount / this.pageSize), 1)
this.currentPage = this.pageCount && (this.currentPage > this.pageCount) ? this.pageCount : this.currentPage
const startIndex = (this.currentPage - 1) * this.pageSize
const endIndex = startIndex + this.pageSize
this.flowList = displayFlowList.slice(startIndex, endIndex)
// Select
let displayFlowSelectedIdSet = new Set()
for (const flow of this.flowList) {
if (this.$store.state.inspector.selectedIds.includes(flow.id)) {
flow['_checked'] = true
displayFlowSelectedIdSet.add(flow.id)
}
}
for (const i in this.selectedFlows) {
if (!displayFlowSelectedIdSet.has(this.selectedFlows[i].id)) {
this.$store.commit('removeSelectedFlowsByIndex', i)
}
}
},
getRequestEditors (row) {
let displayRowAction = []
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (2, 19, 0)
IVERSION = (2, 19, 1)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 35b41d9

Please sign in to comment.