Skip to content

Commit

Permalink
v2.12.2-fix-data-mistake-after-json-parse-and-jsonpath-shortcut-keys (#…
Browse files Browse the repository at this point in the history
…746)

* Solve the problem of long type precision loss when response data is in diff mode;Solve the problem of missing shortcut keys for copying Json path after the upgrade of Monoco Editor.

* Restore non-editable status in diff mode

* Modify variable names and add comments

* Modify the comment
  • Loading branch information
codefly67 authored Mar 7, 2023
1 parent 4e9a9b9 commit 5ee9d76
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
13 changes: 12 additions & 1 deletion frontend/src/components/CodeDiffEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@ export default {
watch: {
diffContent: function () {
console.debug("Code diff editor: content change");
if ((this.editor)) {
if (this.editor) {
this.editor.setModel({
original: monaco.editor.createModel(this.content, this.language),
modified: monaco.editor.createModel(this.diffContent, this.language)
});
}
const modifiedEditor = this.editor.getModifiedEditor()
modifiedEditor.getAction('editor.action.formatDocument').run()
// The condition of formatDocument is that the diff content is not read-only, and formatDocument is async.
// So add 1 second delay to wait for the formatting to complete, and then set the diff content to read-only.
setTimeout(() => {
modifiedEditor.updateOptions({
readOnly: true
})
}, 1000)
}
},
mounted: function () {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CodeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {
id: 'json-path',
label: 'Copy JsonPath',
keybindings: [
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_J)
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyJ)
],
precondition: "editorLangId == 'json'",
keybindingContext: "editorLangId == 'json'",
Expand Down
33 changes: 21 additions & 12 deletions frontend/src/views/datamanager/DataDetailHttpData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
class="data-detail"
:language="currentTabContentType"
:content="editorContent"
:diffContent="editorDiffContent"
:readOnly="true" />
:diffContent="editorDiffContent" />
</div>
<div
class="show-diff-btn"
Expand All @@ -37,11 +36,11 @@
class="save-btn-detail"
@click="diffButtonClick"
>
<v-icon v-if="isShowDiffButton">mdi-eye-off-outline</v-icon>
<v-icon v-else>mdi-eye-outline</v-icon>
<v-icon v-if="diffButtonStatus === 'show'">mdi-eye-outline</v-icon>
<v-icon v-else>mdi-eye-off-outline</v-icon>
</v-btn>
</template>
<span v-if="!isShowDiffButton">Show the diff</span>
<span v-if="diffButtonStatus === 'show'">Show the diff</span>
<span v-else>Hide the diff</span>
</v-tooltip>
</div>
Expand Down Expand Up @@ -94,7 +93,7 @@ export default {
resp: null,
respData: null
},
isShowDiffButton: false,
diffButtonStatus: 'show',
isEditorContentEquals: true,
isTreeNodeClicked: false,
renderedRespData: ''
Expand Down Expand Up @@ -162,7 +161,7 @@ export default {
},
isShowCodeDiffEditor () {
if (this.currentTab === 'respData') {
if (this.isShowDiffButton) {
if (this.diffButtonStatus === 'hide') {
return true
}
return false
Expand Down Expand Up @@ -233,13 +232,15 @@ export default {
.then(response => {
if (data != response.data.data) {
this.isEditorContentEquals = false
const renderedRespDataObj = JSON.parse(response.data.data)
this.renderedRespData = JSON.stringify(renderedRespDataObj, null, 4)
if (this.diffButtonStatus === 'hide'){
this.renderedRespData = response.data.data
}
} else {
this.isEditorContentEquals = true
}
if (this.isTreeNodeClicked) {
this.isShowDiffButton = false
this.diffButtonStatus = 'show'
this.resetRenderedRespData()
}
}).catch(error => {
bus.$emit('msg.error', 'Load rendered data error: ' + error.data.message)
Expand All @@ -249,20 +250,28 @@ export default {
if (this.currentTab === 'respData') {
this.isTreeNodeClicked = false
this.loadEditorDiffContent()
} else {
this.resetRenderedRespData()
}
},
diffButtonClick () {
this.isTreeNodeClicked = false
this.isShowDiffButton = !this.isShowDiffButton
if (this.isShowDiffButton) {
if (this.diffButtonStatus === 'show') {
this.diffButtonStatus = 'hide'
this.loadEditorDiffContent()
} else {
this.diffButtonStatus = 'show'
this.resetRenderedRespData()
}
},
updateDiffButtonStatus() {
if (this.currentTab === 'respData') {
this.isTreeNodeClicked = true
this.loadEditorDiffContent()
}
},
resetRenderedRespData() {
this.renderedRespData = ''
}
}
}
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, 12, 1)
IVERSION = (2, 12, 2)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 5ee9d76

Please sign in to comment.