diff --git a/src/components/createproject.vue b/src/components/createproject.vue
index b4ac3b8..26e4c0c 100644
--- a/src/components/createproject.vue
+++ b/src/components/createproject.vue
@@ -15,27 +15,49 @@
-
-
+
+
+
+
+
+
-
-
-
{{ createProjectError }}
+
+
+
Available remote repositories
+
+
+
+ {{ createProjectError }}
+
@@ -44,7 +66,8 @@
import {
fetchCurrentUser,
fetchRemoteSources,
- createProject
+ createProject,
+ userRemoteRepos
} from "@/util/data.js";
import { projectLink } from "@/util/link.js";
@@ -62,26 +85,38 @@ export default {
data() {
return {
createProjectError: null,
+ fetchRemoteReposLoading: false,
+ fetchRemoteReposLoadingTimeout: false,
createProjectLoading: false,
createProjectLoadingTimeout: null,
user: null,
remoteSources: null,
remoteRepos: [],
+ selectedRemoteSourceIndex: null,
projectName: "",
projectIsPrivate: false,
- remoteRepoPath: null,
- selectedRemoteSource: null
+ remoteRepoPath: null
};
},
computed: {
createProjectButtonEnabled: function() {
- return this.projectName.length && this.selectedRemoteSource;
+ return this.projectName.length && this.remoteRepoPath;
}
},
+ watch: {},
methods: {
resetErrors() {
this.createProjectError = null;
},
+ startFetchRemoteReposLoading() {
+ this.fetchRemoteReposLoadingTimeout = setTimeout(() => {
+ this.fetchRemoteReposLoading = true;
+ }, 300);
+ },
+ stopFetchRemoteReposLoading() {
+ clearTimeout(this.fetchRemoteReposLoadingTimeout);
+ this.fetchRemoteReposLoading = false;
+ },
startProjectLoading() {
this.createProjectLoadingTimeout = setTimeout(() => {
this.createProjectLoading = true;
@@ -91,10 +126,23 @@ export default {
clearTimeout(this.createProjectLoadingTimeout);
this.createProjectLoading = false;
},
- repoSelected(remoteSource, repoPath) {
- this.selectedRemoteSource = remoteSource;
+ repoSelected(repoPath) {
this.remoteRepoPath = repoPath;
},
+ async fetchRemoteRepos() {
+ this.remoteRepos = [];
+ this.remoteRepoPath = null;
+
+ this.startFetchRemoteReposLoading();
+ let remoteSource = this.remoteSources[this.selectedRemoteSourceIndex];
+ let { data, error } = await userRemoteRepos(remoteSource.id);
+ this.stopFetchRemoteReposLoading();
+ if (error) {
+ this.$store.dispatch("setError", error);
+ return;
+ }
+ this.remoteRepos = data;
+ },
async createProject() {
this.resetErrors();
@@ -109,12 +157,14 @@ export default {
visibility = "private";
}
+ let remoteSource = this.remoteSources[this.selectedRemoteSourceIndex];
+
this.startProjectLoading();
let { error } = await createProject(
parentref,
this.projectName,
visibility,
- this.selectedRemoteSource.name,
+ remoteSource.name,
this.remoteRepoPath
);
this.stopProjectLoading();
diff --git a/src/components/remoterepos.vue b/src/components/remoterepos.vue
index 7f86208..5b85d45 100644
--- a/src/components/remoterepos.vue
+++ b/src/components/remoterepos.vue
@@ -1,9 +1,5 @@