Skip to content

Commit 662b7a0

Browse files
authored
Merge pull request #16 from buggregator/issue/#12-var-dump-string-brackets
Issue/#12 var dump string brackets
2 parents c864f72 + adfdacc commit 662b7a0

File tree

5 files changed

+76
-10
lines changed

5 files changed

+76
-10
lines changed

components/ValueDump/ValueDump.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<template>
22
<div class="dump-preview">
3-
<CodeSnippet v-if="isBooleanValue" language="php" :code="value === 1" />
4-
<div
5-
v-if="!isBooleanValue"
6-
class="var-dump-preview__html"
7-
v-html="dumpBody"
8-
/>
3+
<div v-if="!isString" class="var-dump-preview__html" v-html="dumpBody" />
4+
5+
<CodeSnippet v-if="isString" language="php" :code="dumpBody" />
96
</div>
107
</template>
118

129
<script lang="ts">
1310
import { defineComponent } from "vue";
14-
import CodeSnippet from "~/components/CodeSnippet/CodeSnippet.vue";
1511
import { useNuxtApp } from "#app";
12+
import CodeSnippet from "~/components/CodeSnippet/CodeSnippet.vue";
1613
1714
export default defineComponent({
1815
components: {
@@ -34,8 +31,8 @@ export default defineComponent({
3431
};
3532
},
3633
computed: {
37-
isBooleanValue(): boolean {
38-
return typeof this.value === "boolean" || this.type === "boolean";
34+
isString() {
35+
return typeof this.value === "string" && this.type === "string";
3936
},
4037
dumpId(): string | null {
4138
if (!this.value) {
@@ -51,6 +48,10 @@ export default defineComponent({
5148
);
5249
}
5350
51+
if (this.isString) {
52+
return `"${this.value}"`;
53+
}
54+
5455
return this.value;
5556
},
5657
},

components/VarDumpPreview/VarDumpPreview.stories.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { normalizeVarDumpEvent } from "~/utils/normalize-event";
44
import varDumpObjectEventMock from '~/mocks/var-dump-object.json'
55
import varDumpNumberEventMock from '~/mocks/var-dump-number.json'
66
import varDumpStringEventMock from '~/mocks/var-dump-string.json'
7+
import varDumpStringEmptyEventMock from '~/mocks/var-dump-string-empty.json'
78
import varDumpArrayEventMock from '~/mocks/var-dump-array.json'
9+
import varDumpBoolEventMock from '~/mocks/var-dump-boolean.json'
810
import VarDumpPreview from '~/components/VarDumpPreview/VarDumpPreview.vue';
911

1012
export default {
@@ -40,6 +42,19 @@ String.args = {
4042
event: normalizeVarDumpEvent(varDumpStringEventMock),
4143
};
4244

45+
export const StringEmpty = Template.bind({});
46+
47+
StringEmpty.args = {
48+
event: normalizeVarDumpEvent(varDumpStringEmptyEventMock),
49+
};
50+
51+
export const Boolean = Template.bind({});
52+
53+
Boolean.args = {
54+
event: normalizeVarDumpEvent(varDumpBoolEventMock),
55+
};
56+
57+
4358
export const Array = Template.bind({});
4459

4560
Array.args = {

config/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface Sentry {
142142
export interface VarDump {
143143
payload: {
144144
type: string,
145-
value: string
145+
value: string | number | boolean
146146
},
147147
context: {
148148
timestamp: number,

mocks/var-dump-boolean.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"uuid": "49c77954-d17e-471d-9d5e-bf0aa856f90c",
3+
"type": "var-dump",
4+
"payload": {
5+
"payload": {
6+
"type": "boolean",
7+
"value": true
8+
},
9+
"context": {
10+
"timestamp": 1678271981.325951,
11+
"cli": {
12+
"command_line": "app.php",
13+
"identifier": "799f2007"
14+
},
15+
"source": {
16+
"name": "HomeController.php",
17+
"file": "/root/repos/spiral-apps/filters-bridge/app/src/Controller/HomeController.php",
18+
"line": 48,
19+
"file_excerpt": false
20+
}
21+
}
22+
},
23+
"timestamp": 1678271981,
24+
"project_id": null
25+
}

mocks/var-dump-string-empty.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"uuid": "49c77954-d17e-471d-9d5e-bf0aa856f90c",
3+
"type": "var-dump",
4+
"payload": {
5+
"payload": {
6+
"type": "string",
7+
"value": "\t "
8+
},
9+
"context": {
10+
"timestamp": 1678271981.325951,
11+
"cli": {
12+
"command_line": "app.php",
13+
"identifier": "799f2007"
14+
},
15+
"source": {
16+
"name": "HomeController.php",
17+
"file": "/root/repos/spiral-apps/filters-bridge/app/src/Controller/HomeController.php",
18+
"line": 48,
19+
"file_excerpt": false
20+
}
21+
}
22+
},
23+
"timestamp": 1678271981,
24+
"project_id": null
25+
}

0 commit comments

Comments
 (0)