]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7433 Provide a visual feedback when creating a project
authorStas Vilchik <vilchiks@gmail.com>
Mon, 18 Apr 2016 12:35:57 +0000 (14:35 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 18 Apr 2016 12:35:57 +0000 (14:35 +0200)
server/sonar-web/src/main/js/apps/projects/create-view.js
server/sonar-web/src/main/js/apps/projects/templates/projects-create-form.hbs

index 9dc15b0b9f58a1cbf3fe10dc10a0196c11a48065..3f1662349bc07004f55abadcf7684fdadcdf9ad7 100644 (file)
@@ -47,11 +47,13 @@ export default ModalForm.extend({
     };
     this.disableForm();
     return createProject(data)
-        .then(() => {
+        .then(project => {
           if (this.options.refresh) {
             this.options.refresh();
           }
-          this.destroy();
+          this.enableForm();
+          this.createdProject = project;
+          this.render();
         })
         .catch(error => {
           this.enableForm();
@@ -59,5 +61,12 @@ export default ModalForm.extend({
             error.response.json().then(obj => this.showErrors([{ msg: obj.err_msg }]));
           }
         });
+  },
+
+  serializeData () {
+    return {
+      ...ModalForm.prototype.serializeData.apply(this, arguments),
+      createdProject: this.createdProject
+    };
   }
 });
index e931b66efd7cad20453c5d539e04c548509ae384..2c12406ce6dbbabcb631eac26d9019a56f8bd447 100644 (file)
@@ -4,27 +4,38 @@
   </div>
   <div class="modal-body">
     <div class="js-modal-messages"></div>
-    <div class="modal-field">
-      <label for="create-project-name">Name<em class="mandatory">*</em></label>
-      {{! keep this fake field to hack browser autofill }}
-      <input id="create-project-name-fake" name="name-fake" type="text" class="hidden">
-      <input id="create-project-name" name="name" type="text" size="50" maxlength="200" required>
-    </div>
-    <div class="modal-field">
-      <label for="create-project-branch">Branch</label>
-      {{! keep this fake field to hack browser autofill }}
-      <input id="create-project-branch-fake" name="branch-fake" type="text" class="hidden">
-      <input id="create-project-branch" name="branch" type="text" size="50" maxlength="200">
-    </div>
-    <div class="modal-field">
-      <label for="create-project-key">Key<em class="mandatory">*</em></label>
-      {{! keep this fake field to hack browser autofill }}
-      <input id="create-project-key-fake" name="key-fake" type="text" class="hidden">
-      <input id="create-project-key" name="key" type="text" size="50" maxlength="50" required>
-    </div>
+    {{#if createdProject}}
+      <div class="alert alert-success">
+        Project <a href="{{componentPermalink createdProject.k}}">{{createdProject.nm}}</a> has been successfully
+        created.
+      </div>
+    {{else}}
+      <div class="modal-field">
+        <label for="create-project-name">Name<em class="mandatory">*</em></label>
+        {{! keep this fake field to hack browser autofill }}
+        <input id="create-project-name-fake" name="name-fake" type="text" class="hidden">
+        <input id="create-project-name" name="name" type="text" size="50" maxlength="200" required>
+      </div>
+      <div class="modal-field">
+        <label for="create-project-branch">Branch</label>
+        {{! keep this fake field to hack browser autofill }}
+        <input id="create-project-branch-fake" name="branch-fake" type="text" class="hidden">
+        <input id="create-project-branch" name="branch" type="text" size="50" maxlength="200">
+      </div>
+      <div class="modal-field">
+        <label for="create-project-key">Key<em class="mandatory">*</em></label>
+        {{! keep this fake field to hack browser autofill }}
+        <input id="create-project-key-fake" name="key-fake" type="text" class="hidden">
+        <input id="create-project-key" name="key" type="text" size="50" maxlength="50" required>
+      </div>
+    {{/if}}
   </div>
   <div class="modal-foot">
-    <button id="create-project-submit">Create</button>
-    <a href="#" class="js-modal-close" id="create-project-cancel">Cancel</a>
+    {{#if createdProject}}
+      <a href="#" class="js-modal-close">{{t 'close'}}</a>
+    {{else}}
+      <button id="create-project-submit">Create</button>
+      <a href="#" class="js-modal-close" id="create-project-cancel">Cancel</a>
+    {{/if}}
   </div>
 </form>