]> source.dussan.org Git - archiva.git/commitdiff
implements merging repositories in the new ui
authorOlivier Lamy <olamy@apache.org>
Thu, 20 Sep 2012 19:43:45 +0000 (19:43 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 20 Sep 2012 19:43:45 +0000 (19:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1388178 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java
archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html

index 26cc07c54e546e93ad6522e0864a24d835092448..d309c9889ac493a13b6357a9b0a42d7daf98c7ef 100644 (file)
@@ -50,6 +50,8 @@ public class DefaultMergeRepositoriesService
     implements MergeRepositoriesService
 {
 
+    // FIXME check archiva-merge-repository to sourceRepoId
+
     @Inject
     @Named ( value = "repositoryMerger#maven2" )
     private Maven2RepositoryMerger repositoryMerger;
index 45c6ce5e877c801a7ebbc21f009baae81bc9399c..2848daa5739f6d9d657dba9912728807e44ce485 100644 (file)
@@ -98,6 +98,8 @@ skipPackedIndexCreation=Skip Packed Index creation
 skipPackedIndexCreation.help.title=Skip Packed Index creation
 skipPackedIndexCreation.help.content=Will prevent creating packed and incremental indexes which are consumed by remote repositories manager and/or IDE.
 managedrepository.actions=Actions
+managedrepository.repomerge.dialog.header=Choose a target repository for merging
+managedrepository.mergerepo=Merge this repository
 
 # remote repositories screen
 remoterepository.downloadremoteindex.now=Download Remote Index Now
index 236f0a11779535f0bdb2c308b1620ad6d8daaf6f..132031560e981b71a5d80dbc39857522272e38be 100644 (file)
@@ -526,8 +526,108 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery
 
     }
 
+    mergeRepo=function(managedRepository){
+      $("#user-messages" ).html(mediumSpinnerImg());
+      // is there any artifacts to merge ?
+      var artifactsNumberUrl = "restServices/archivaServices/browseService/artifacts/"+encodeURIComponent(managedRepository.id());
+      $.ajax(artifactsNumberUrl,{
+            type: "GET",
+            dataType: 'json',
+            success: function(data){
+              var artifacts=mapArtifacts(data);
+              $.log("artifactsNumber for '" + managedRepository.id() + "': " + artifacts.length);
+
+              if (artifacts<1){
+                displayWarningMessage($.i18n.prop("managedrepository.merge.noartifacts", managedRepository.id()));
+                return;
+              }
+
+              $.log("merge repo open dialog");
+              var dialogMergeRepo=$("#dialog-modal-merge-repo");
+              if (window.modalMergeRepoDialog==null) {
+                window.modalMergeRepoDialog = dialogMergeRepo.modal();
+
+              }
+
+              loadManagedRepositories(function(data){
+
+                var managedRepositories = $.map(mapManagedRepositories(data), function(item) {
+                    return item.id()==managedRepository.id()?null:item;
+                });
+                $("#dialog-modal-merge-repo-body-text").html($("#merge-repo-dialog-content" )
+                                                                  .tmpl({sourceRepoId:managedRepository.id(),repositories:managedRepositories}));
+                window.modalMergeRepoDialog.modal('show');
+              });
+
+            },
+            complete: function(){
+              $.log("complete removeMediumSpinnerImg");
+              removeMediumSpinnerImg("#user-messages");
+            }
+        }
+      );
+
 
 
+    }
+
+
+  }
+
+
+  mergeRepositories=function(sourceRepository,targetRepository){
+    $.log("mergeRepositories:"+sourceRepository+":"+targetRepository);
+
+    var mergeRepoDialogBodyId="dialog-modal-merge-repo-body-text";
+    var mergeRepoDialogBody=$("#"+mergeRepoDialogBodyId);
+    mergeRepoDialogBody.html(mediumSpinnerImg());
+
+    // check conflicts
+    var url = "restServices/archivaServices/mergeRepositoriesService/mergeConflictedArtifacts/"+encodeURIComponent(sourceRepository);
+    url+="/"+encodeURIComponent(targetRepository);
+    $.ajax(url, {
+        type: "GET",
+        dataType: 'json',
+        success: function(data){
+          var artifacts=mapArtifacts(data);
+          if (artifacts && artifacts.length){
+            // we have conflicts ask to skip or not
+            $.log("conflicts:"+artifacts.length);
+            displayWarningMessage($.i18n.prop("managedrepository.merge.conflicts", artifacts.length),"dialog-modal-merge-repo-body-text");
+            $.tmpl($("#merge-repo-skip-conflicts").html(),
+                { artifacts:artifacts, sourceRepository: sourceRepository, targetRepository:targetRepository })
+                .appendTo( "#dialog-modal-merge-repo-body-text" );
+          } else {
+            doMerge(sourceRepository,targetRepository,false);
+          }
+        },
+        complete: function(){
+          $.log("complete removeMediumSpinnerImg");
+          removeMediumSpinnerImg("#dialog-modal-merge-repo-body-text");
+        }
+    });
+
+
+
+  }
+
+  doMerge=function(sourceRepository,targetRepository,skipConflicts){
+    $.log("doMerge:"+sourceRepository+" to " + targetRepository + ", skipConflicts: " + skipConflicts);
+    window.modalMergeRepoDialog.modal('hide');
+    $("#user-messages" ).html(mediumSpinnerImg());
+    var url = "restServices/archivaServices/mergeRepositoriesService/mergeRepositories/"+encodeURIComponent(sourceRepository);
+    url+="/"+encodeURIComponent(targetRepository);
+    url+="/"+skipConflicts;
+    $.ajax(url, {
+        type: "GET",
+        dataType: 'json',
+        success: function(data){
+          displaySuccessMessage($.i18n.prop("managedrepository.merge.success", sourceRepository,targetRepository));
+        },
+        complete: function(){
+          removeMediumSpinnerImg("#user-messages");
+        }
+    });
   }
 
   activateManagedRepositoriesGridTab=function(){
index 890d1abf295fd609be782c41901913d7bfe846d7..e447e9a44cbe87078a0202428e781528764d0fd3 100644 (file)
     <a class="btn secondary" id="dialog-confirm-modal-cancel" href="#">${$.i18n.prop('cancel')}</a>
     <a class="btn primary" id="dialog-confirm-modal-ok" href="#">${$.i18n.prop('ok')}</a>
   </div>
+</div>
+
+<div id="dialog-modal-merge-repo" class="modal hide fade" style="display: block;">
+    <div class="modal-header">
+      <a class="close" href="#" data-dismiss="modal">&#215;</a>
+      <h3 id="dialog-modal-merge-repo-header-title">${$.i18n.prop('managedrepository.repomerge.dialog.header')}</h3>
+    </div>
+    <div class="modal-body" id="dialog-modal-merge-repo-body-text">>
+    </div>
+
 </div>
\ No newline at end of file
index 957c8cea53f5599badbc89720876550a69db5177..2b52399d9768fb9d71751b1145a0271d32aed097 100644 (file)
                             ${$.i18n.prop('managedrepository.pomsnippet')}
                         </a>
                     </li>
+                    <li>
+                      {{if row.stageRepoNeeded()}}
+                        stage
+                      {{/if}}
+                    </li>
+                    <li>
+                        <!-- todo check archiva-merge-repository operation -->
+                        <a href="#" data-bind="click: function(){ mergeRepo(row) }">
+                            <span class="btn btn-info">
+                              <i class="icon-repeat icon-white"></i>
+                            </span>
+                            ${$.i18n.prop('managedrepository.mergerepo')}
+                        </a>
+                    </li>
                   </ul>
                 </div>
               </td>
     <div>
       <span class="label label-warning">${$.i18n.prop('warning.not.undone.operation')}</span>
     </div>
+</script>
+
+
+<script id="merge-repo-dialog-content" type="text/html">
+    <div class="btn-group btn-group-vertical">
+      {{each(i, repository) repositories}}
+        <button class="btn" type="button" onclick="mergeRepositories(encodeURIComponent('${sourceRepoId}'),encodeURIComponent('${repository.id()}'))">${repository.name()}</button>
+      {{/each}}
+    </div>
+</script>
+
+<script id="merge-repo-skip-conflicts"  type="text/html">
+  <div>
+    <ul>
+      {{each(i, artifact) artifacts}}
+        <li>${artifact.groupId}:${artifact.artifactId}:${artifact.version}</li>
+      {{/each}}
+    </ul>
+  </div>
+  <div>
+    <button class="btn btn-success" onclick="doMerge(encodeURIComponent('${sourceRepository}'),encodeURIComponent('${targetRepository}'),false);" type="button">${$.i18n.prop('managedrepository.merge.domerge')}</button>
+    {{if artifacts.length > 0}}
+      <button class="btn btn-warning" onclick="doMerge(encodeURIComponent('${sourceRepository}'),encodeURIComponent('${targetRepository}'),true);" type="button">${$.i18n.prop('managedrepository.merge.domerge.skipconflicts')}</button>
+    {{/if}}
+  </div>
 </script>
\ No newline at end of file