ide.vue 2.3 KB
Newer Older
1
<script>
F
Filipa Lacerda 已提交
2 3 4 5 6 7 8 9
  import { mapState, mapGetters } from 'vuex';
  import ideSidebar from './ide_side_bar.vue';
  import ideContextbar from './ide_context_bar.vue';
  import repoTabs from './repo_tabs.vue';
  import repoFileButtons from './repo_file_buttons.vue';
  import ideStatusBar from './ide_status_bar.vue';
  import repoPreview from './repo_preview.vue';
  import repoEditor from './repo_editor.vue';
10

F
Filipa Lacerda 已提交
11 12 13 14 15 16 17 18 19
  export default {
    components: {
      ideSidebar,
      ideContextbar,
      repoTabs,
      repoFileButtons,
      ideStatusBar,
      repoEditor,
      repoPreview,
20
    },
F
Filipa Lacerda 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    props: {
      emptyStateSvgPath: {
        type: String,
        required: true,
      },
    },
    computed: {
      ...mapState([
        'currentBlobView',
        'selectedFile',
      ]),
      ...mapGetters([
        'changedFiles',
        'activeFile',
      ]),
    },
    mounted() {
      const returnValue = 'Are you sure you want to lose unsaved changes?';
      window.onbeforeunload = (e) => {
        if (!this.changedFiles.length) return undefined;
41

F
Filipa Lacerda 已提交
42 43 44 45 46 47 48
        Object.assign(e, {
          returnValue,
        });
        return returnValue;
      };
    },
  };
49 50 51
</script>

<template>
F
Filipa Lacerda 已提交
52
  <div
53 54
    class="ide-view"
  >
F
Filipa Lacerda 已提交
55
    <ide-sidebar />
56 57 58 59
    <div
      class="multi-file-edit-pane"
    >
      <template
F
Filipa Lacerda 已提交
60 61
        v-if="activeFile"
      >
62 63 64 65 66
        <repo-tabs/>
        <component
          class="multi-file-edit-pane-content"
          :is="currentBlobView"
        />
F
Filipa Lacerda 已提交
67
        <repo-file-buttons />
68
        <ide-status-bar
F
Filipa Lacerda 已提交
69 70
          :file="selectedFile"
        />
71 72
      </template>
      <template
F
Filipa Lacerda 已提交
73 74
        v-else
      >
75
        <div class="ide-empty-state">
76 77 78
          <div class="row js-empty-state">
            <div class="col-xs-12">
              <div class="svg-content svg-250">
F
Filipa Lacerda 已提交
79
                <img :src="emptyStateSvgPath" />
80 81 82 83 84 85 86 87
              </div>
            </div>
            <div class="col-xs-12">
              <div class="text-content text-center">
                <h4>
                  Welcome to the GitLab IDE
                </h4>
                <p>
F
Filipa Lacerda 已提交
88 89
                  You can select a file in the left sidebar to begin
                  editing and use the right sidebar to commit your changes.
90 91 92 93
                </p>
              </div>
            </div>
          </div>
94 95 96 97 98 99
        </div>
      </template>
    </div>
    <ide-contextbar/>
  </div>
</template>