debian-mirror-gitlab/app/assets/javascripts/observability/components/observability_app.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1 KiB
Vue
Raw Normal View History

2023-01-13 00:05:48 +05:30
<script>
export default {
props: {
observabilityIframeSrc: {
type: String,
required: true,
},
},
mounted() {
window.addEventListener('message', this.messageHandler);
},
methods: {
messageHandler(e) {
const isExpectedOrigin = e.origin === new URL(this.observabilityIframeSrc)?.origin;
const isNewObservabilityPath = this.$route?.query?.observability_path !== e.data?.url;
const shouldNotHandleMessage = !isExpectedOrigin || !e.data.url || !isNewObservabilityPath;
if (shouldNotHandleMessage) {
return;
}
// this will update the `observability_path` query param on each route change inside Observability UI
this.$router.replace({
name: this.$route.pathname,
query: { ...this.$route.query, observability_path: e.data.url },
});
},
},
};
</script>
<template>
<iframe
id="observability-ui-iframe"
data-testid="observability-ui-iframe"
frameborder="0"
height="100%"
:src="observabilityIframeSrc"
></iframe>
</template>