Commit f4810472 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '325824-prettify-sample-json' into 'master'

Prettify JSON of sample alert payload

See merge request gitlab-org/gitlab!58433
parents 0cc1b04b eb8769b2
...@@ -255,7 +255,7 @@ export default { ...@@ -255,7 +255,7 @@ export default {
if (this.showMappingBuilder) { if (this.showMappingBuilder) {
this.resetPayloadAndMappingConfirmed = false; this.resetPayloadAndMappingConfirmed = false;
this.parsedPayload = payloadAlertFields; this.parsedPayload = payloadAlertFields;
this.samplePayload.json = this.isValidNonEmptyJSON(payloadExample) ? payloadExample : null; this.samplePayload.json = this.getPrettifiedPayload(payloadExample);
this.updateMapping(this.getCleanMapping(payloadAttributeMappings)); this.updateMapping(this.getCleanMapping(payloadAttributeMappings));
} }
this.$el.scrollIntoView({ block: 'center' }); this.$el.scrollIntoView({ block: 'center' });
...@@ -288,6 +288,11 @@ export default { ...@@ -288,6 +288,11 @@ export default {
} }
return false; return false;
}, },
getPrettifiedPayload(payload) {
return this.isValidNonEmptyJSON(payload)
? JSON.stringify(JSON.parse(payload), null, '\t')
: null;
},
triggerValidation() { triggerValidation() {
if (this.isHttp) { if (this.isHttp) {
this.validationState.apiUrl = true; this.validationState.apiUrl = true;
......
---
title: Prettify JSON of sample alert payload
merge_request: 58433
author:
type: added
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment