From 35b41d9ad559d25e325f7d0caefec538b1b27f87 Mon Sep 17 00:00:00 2001 From: yumiguan <41277086+yumiguan@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:49:21 +0800 Subject: [PATCH] feature/inspector-unselect-flow-after-save (#783) * Inspector unselect flow after save * update version * Set flow unselected when flow is not on the diaplay page --- frontend/src/store/inspector.js | 21 ++++++------- frontend/src/views/inspector/FlowList.vue | 37 +++++++++++++++++------ lyrebird/version.py | 2 +- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/frontend/src/store/inspector.js b/frontend/src/store/inspector.js index 7b0360c16..d1274ad66 100644 --- a/frontend/src/store/inspector.js +++ b/frontend/src/store/inspector.js @@ -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) { @@ -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)) { @@ -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) @@ -187,7 +186,7 @@ export default { commit('clearFocusedFlowDetail') } commit('clearSelectedId') - commit('cleaerSelectedFlows') + commit('clearSelectedFlows') bus.$emit('msg.success', selectedIdLength + ' flow deleted!') }) .catch(error => { diff --git a/frontend/src/views/inspector/FlowList.vue b/frontend/src/views/inspector/FlowList.vue index a2463f7a2..328595fdc 100644 --- a/frontend/src/views/inspector/FlowList.vue +++ b/frontend/src/views/inspector/FlowList.vue @@ -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 = [] diff --git a/lyrebird/version.py b/lyrebird/version.py index cb1ad5d5e..b1c9286e4 100644 --- a/lyrebird/version.py +++ b/lyrebird/version.py @@ -1,3 +1,3 @@ -IVERSION = (2, 19, 0) +IVERSION = (2, 19, 1) VERSION = ".".join(str(i) for i in IVERSION) LYREBIRD = "Lyrebird " + VERSION