-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathOutput.vue
116 lines (106 loc) · 3.01 KB
/
Output.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
<div class="pt2">
<div v-if="output.test && (output.test instanceof Error || output.test.error)"
class="output-log lh-copy bg-red white"
v-html="parseData(`${output.test instanceof Error ? output.test : output.test.error}`)"
/>
<div
v-if="output.test.fail"
class="output-log lh-copy bg-red white"
v-html="parseData(output.test.fail)"
data-cy="output-fail"
/>
<div class="lh-copy bg-green white" v-if="output.test.success && lessonPassed">
<span class="output-log" data-cy="output-success" v-html="parseData(output.test.success)" />
<span v-if="output.test.cid">
<a
class="link fw7 underline-hover dib ph2 mh2 white"
target="_blank"
:href="exploreIpldUrl"
@click="onClickTrackIPLD"
>
View in IPLD Explorer
</a>
<a
class="link fw7 underline-hover dib ph2 mh2 white"
target="_blank"
:href="inspectCidUrl"
@click="onClickTrackCID"
>
View in CID Inspector
</a>
</span>
</div>
<div v-if="output.test.log">
<div v-if="isFileLesson" class="f5 fw7 mt4 mb2">Step 3: Inspect results</div>
<div v-else class="f5 fw7 mt4 mb2">Inspect results</div>
<div v-if="output.test.logDesc" class="lh-copy" v-html="parseData(output.test.logDesc)" />
<highlight-code class="code-highlight" lang="json" >{{output.test.log}}</highlight-code>
</div>
</div>
</template>
<script>
import countly from '../utils/countly'
export default {
props: {
output: Object,
isFileLesson: Boolean,
lessonPassed: Boolean,
parseData: Function,
trackingData: Object
},
computed: {
Error: () => Error,
exploreIpldUrl: function () {
let cid = this.output.test && this.output.test.cid && this.output.test.cid.toString()
return `https://explore.ipld.io/#/explore/${cid || ''}`
},
inspectCidUrl: function () {
let cid = this.output.test && this.output.test.cid && this.output.test.cid.toString()
return `https://cid.ipfs.tech/#${cid || ''}`
}
},
methods: {
onClickTrackIPLD: function () {
countly.trackEvent(countly.events.LINK_CLICK_IPLD_EXPLORER, {
...this.trackingData,
href: this.exploreIpldUrl,
type: 'IPLD Explorer'
})
},
onClickTrackCID: function () {
countly.trackEvent(countly.events.LINK_CLICK_CID_INSPECTOR, {
...this.trackingData,
href: this.inspectCidUrl,
type: 'CID Inspector'
})
}
}
}
</script>
<style> /* We need this unscoped to override the hljs styles. */
.output-log p {
word-break: break-word;
display: inline-block;
margin: .5rem 1rem;
}
.output-log code {
background-color: rgba(0, 0, 0, 0.2);
}
.output-code {
margin: 1rem 0 0 0;
}
.output-code code {
margin: 0;
padding: 1rem;
background: white;
}
pre.code-highlight {
border-radius: 3px;
}
pre.code-highlight,
pre.code-highlight > code.hljs {
background: #ffffff;
padding: 0.6em;
}
</style>