Welcome to mirror list, hosted at ThFree Co, Russian Federation.

observability_app.vue « components « observability « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4f5e27be46f0660da7a80c74ff1dfd9328a5e828 (plain)
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
<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>