diff options
author | Olivier Lamy <olamy@apache.org> | 2012-09-20 19:43:45 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-09-20 19:43:45 +0000 |
commit | 95e33a55340c3315e3d7547da0ead9e22707ca74 (patch) | |
tree | 0c660865eb5aede92e8264eed13bb465c213f450 | |
parent | 30e499e3e83340875e7db29056fd138b79acfabe (diff) | |
download | archiva-95e33a55340c3315e3d7547da0ead9e22707ca74.tar.gz archiva-95e33a55340c3315e3d7547da0ead9e22707ca74.zip |
implements merging repositories in the new ui
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1388178 13f79535-47bb-0310-9956-ffa450edef68
5 files changed, 153 insertions, 0 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java index 26cc07c54..d309c9889 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java @@ -50,6 +50,8 @@ public class DefaultMergeRepositoriesService implements MergeRepositoriesService { + // FIXME check archiva-merge-repository to sourceRepoId + @Inject @Named ( value = "repositoryMerger#maven2" ) private Maven2RepositoryMerger repositoryMerger; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 45c6ce5e8..2848daa57 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -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 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js index 236f0a117..132031560 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js @@ -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(){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html index 890d1abf2..e447e9a44 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html @@ -28,4 +28,14 @@ <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">×</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 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html index 957c8cea5..2b52399d9 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html @@ -146,6 +146,20 @@ ${$.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> @@ -1177,4 +1191,29 @@ <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 |