|
| 1 | +<template> |
| 2 | + <div |
| 3 | + v-show="this.$store.state.model.model.cloneRepository" |
| 4 | + class="model--medium" |
| 5 | + > |
| 6 | + <div v-if="!cloning"> |
| 7 | + <div class="model__section model__header"> |
| 8 | + <h6 class="model__header__title"> |
| 9 | + Clone a repository |
| 10 | + </h6> |
| 11 | + <div |
| 12 | + class="model__header__close" |
| 13 | + @click="closeModel" |
| 14 | + > |
| 15 | + <closeIcon /> |
| 16 | + </div> |
| 17 | + </div> |
| 18 | + <div class="model__section model__body flex-column"> |
| 19 | + <inputTextLabel |
| 20 | + v-model="repositoryName" |
| 21 | + name="repositoryName" |
| 22 | + label="Name" |
| 23 | + placeholder="Name of repository" |
| 24 | + margin-bottom=".8rem" |
| 25 | + /> |
| 26 | + <inputTextLabel |
| 27 | + v-model="remoteUrl" |
| 28 | + name="remoteUrl" |
| 29 | + label="Remote url" |
| 30 | + placeholder="Paste remote url" |
| 31 | + margin-bottom=".8rem" |
| 32 | + /> |
| 33 | + <div style="display: flex; align-items: flex-end"> |
| 34 | + <inputTextLabel |
| 35 | + v-model="repositoryLocation" |
| 36 | + name="repositoryLocation" |
| 37 | + label="Path" |
| 38 | + placeholder="Repository path" |
| 39 | + style="flex-grow: 2" |
| 40 | + /> |
| 41 | + <input |
| 42 | + ref="folderSelector" |
| 43 | + type="file" |
| 44 | + name="folderSelector" |
| 45 | + webkitdirectory |
| 46 | + style="display: none" |
| 47 | + @change="folderSelectorInput" |
| 48 | + > |
| 49 | + <Button |
| 50 | + text="Select" |
| 51 | + appearance="primary" |
| 52 | + margin-left=".4rem" |
| 53 | + @click.native="$refs.folderSelector.click()" |
| 54 | + /> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + <div class="model__section model__footer"> |
| 58 | + <Button |
| 59 | + margin-left="auto" |
| 60 | + text="Clone" |
| 61 | + appearance="primary" |
| 62 | + @click.native="cloneRepository" |
| 63 | + /> |
| 64 | + <Button |
| 65 | + text="Cancel" |
| 66 | + appearance="outline" |
| 67 | + margin-left=".5rem" |
| 68 | + @click.native="closeModel" |
| 69 | + /> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + <div |
| 73 | + v-else |
| 74 | + class="clone__progress" |
| 75 | + > |
| 76 | + <h1>Cloning the repository</h1> |
| 77 | + <progressBar |
| 78 | + :value="cloneProgress" |
| 79 | + margin-top="2rem" |
| 80 | + /> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | +</template> |
| 84 | + |
| 85 | +<script> |
| 86 | +import inputTextLabel from "../input/inputTextLabel"; |
| 87 | +import closeIcon from "../icon/close"; |
| 88 | +import Button from "../buttons/Button"; |
| 89 | +import progressBar from "../progress/progressBar"; |
| 90 | +import gitClone from "../../git/clone"; |
| 91 | +import addRepository from "../../mixins/addRepository"; |
| 92 | +
|
| 93 | +export default { |
| 94 | + name: "CloneRepository", |
| 95 | + components: { |
| 96 | + inputTextLabel, |
| 97 | + Button, |
| 98 | + progressBar, |
| 99 | + closeIcon |
| 100 | + }, |
| 101 | + mixins: [addRepository], |
| 102 | + data() { |
| 103 | + return { |
| 104 | + repositoryName: "", |
| 105 | + remoteUrl: "", |
| 106 | + repositoryLocation: "", |
| 107 | + cloning: false, |
| 108 | + cloneProgress: 0 |
| 109 | + }; |
| 110 | + }, |
| 111 | + methods: { |
| 112 | + folderSelectorInput() { |
| 113 | + this.repositoryLocation = event.target.files[0].path |
| 114 | + .split("\\") |
| 115 | + .join("/"); |
| 116 | + }, |
| 117 | + cloneRepository() { |
| 118 | + const repositoryPath = |
| 119 | + this.repositoryLocation + "/" + this.repositoryName; |
| 120 | + this.cloning = true; |
| 121 | + gitClone(this.remoteUrl, repositoryPath) |
| 122 | + .then(result => { |
| 123 | + if (result) { |
| 124 | + this.cloning = false; |
| 125 | + this.closeModel(); |
| 126 | + } |
| 127 | + this.addRepository(repositoryPath); |
| 128 | + }); |
| 129 | + }, |
| 130 | + addRepository(path) { |
| 131 | + this.localRepository(path); |
| 132 | + }, |
| 133 | + closeModel() { |
| 134 | + this.$store.dispatch("model/showCloneRepository"); |
| 135 | + } |
| 136 | + } |
| 137 | +}; |
| 138 | +</script> |
| 139 | + |
| 140 | +<style lang='sass' scoped> |
| 141 | +.clone__progress |
| 142 | + padding: 3rem |
| 143 | + text-align: center |
| 144 | +</style> |
0 commit comments