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

confirm_unsaved_changes_dialog.vue « ui « components « pipeline_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc076fbe349e3685f8cecaf4b448e159b41fc7a3 (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
<script>
export default {
  props: {
    hasUnsavedChanges: {
      type: Boolean,
      required: true,
    },
  },
  created() {
    window.addEventListener('beforeunload', this.confirmChanges);
  },
  destroyed() {
    window.removeEventListener('beforeunload', this.confirmChanges);
  },
  methods: {
    confirmChanges(e = {}) {
      if (this.hasUnsavedChanges) {
        e.preventDefault();
        // eslint-disable-next-line no-param-reassign
        e.returnValue = ''; // Chrome requires returnValue to be set
      }
    },
  },
  render: () => null,
};
</script>