Skip to content

Commit 605470d

Browse files
authored
inspector show flow mock id (#891)
1 parent 8ffee27 commit 605470d

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

frontend/src/views/inspector/FlowList.vue

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@
2828
color="#fff1f0"
2929
text-color="#f5222d"
3030
>kill</v-chip>
31-
<v-chip label small
32-
v-else-if="item.response.mock === 'mock'"
33-
class="flow-list-item-tag"
34-
color="primaryBrightest"
35-
text-color="primary"
36-
>mock</v-chip>
31+
<v-tooltip top v-else-if="item.response.mock === 'mock'">
32+
<template v-slot:activator="{ on, attrs }">
33+
<v-chip label small
34+
class="flow-list-item-tag"
35+
color="primaryBrightest"
36+
text-color="primary"
37+
@click = "copyMockId(item)"
38+
v-bind="attrs"
39+
v-on="on"
40+
>mock</v-chip>
41+
</template>
42+
<span> {{ getMockId(item) ? 'Mock by: '+getMockId(item)+' (Click copy)' : 'MockId Not Found' }} </span>
43+
</v-tooltip>
3744
<v-chip label small
3845
v-else-if="item.response.mock === 'proxy'"
3946
color="border"
@@ -556,6 +563,20 @@ export default {
556563
onUrlCopyError (e) {
557564
this.$bus.$emit('msg.error', 'Copy url error:' + e)
558565
},
566+
getMockId (item) {
567+
for (const action of item.action) {
568+
if (action.hasOwnProperty('mock_id')) {
569+
return action.mock_id;
570+
}
571+
}
572+
return '';
573+
},
574+
copyMockId (item) {
575+
let mock_id = this.getMockId(item)
576+
if (mock_id) {
577+
this.$bus.$emit('clipboard', mock_id)
578+
}
579+
},
559580
showPopup(event, item) {
560581
event.preventDefault();
561582
this.currentItem = item;

0 commit comments

Comments
 (0)