%PDF- %PDF-
| Direktori : /data/old/home/stash/atlassian/stash/3.7.1/atlassian-stash/static/stash/api/util/ |
| Current File : //data/old/home/stash/atlassian/stash/3.7.1/atlassian-stash/static/stash/api/util/navbuilder-min.js |
define("stash/api/util/navbuilder",["aui","jquery","lib/jsuri","lodash","util/deprecation","model/page-state","model/path","exports"],function(AF,Ab,f,AD,Am,R,AT,w){function d(Ap,Aq,Ao){this.components=(AD.isString(Ap)?[Ap]:Ap)||[];this.params=Aq||{};this.anchor=Ao||undefined}d.prototype.buildRelNoContext=function(){var Ap="/"+AD.map(this.components,encodeURIComponent).join("/");var Aq=AD.reduce(this.params,function(As,Ar,At){if(!(AD.isArray(Ar))){Ar=[Ar]}AD.forEach(Ar,function(Au){As.push({key:At,value:Au})});return As},[]);var Ao=AD.map(Aq,function(As){var Ar=encodeURIComponent(As.value);return encodeURIComponent(As.key)+(Ar?"="+Ar:"")}).join("&");return Ap+(Ao?"?"+Ao:"")+(this.anchor?"#"+this.anchor:"")};d.prototype.buildRelative=function(){return AF.contextPath()+this.buildRelNoContext()};d.prototype.buildAbsolute=function(){return location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")+this.buildRelative()};d.prototype.toString=function(){return this.buildRelative()};d.prototype.addParams=function(Ap){var Ao=new d(this.components,AD.extend({},this.params));if(AD.isString(Ap)){Ao.params[Ap]=""}else{if(Ap){if(Ap.hasOwnProperty("queryParams")){Ao.params=AD.extend(Ao.params,Ap.queryParams)}else{if(!Ap.hasOwnProperty("urlMode")){Ao.params=AD.extend(Ao.params,Ap)}}}}return Ao};d.prototype.withFragment=function(Ao){return new d(this.components,this.params,Ao)};d.prototype.pushComponents=function(){var Ao=new d(this.components.slice(0),this.params);AD.each(AD.toArray(arguments).slice(0),function(Ap){if(Ap!==""){Ao.components.push(Ap)}});return Ao};d.prototype.makeBuilder=function(Ao){var Ap=this;return AD.extend({_path:function(){return Ap},build:function(){return Ap.buildRelative()},buildAbsolute:function(){return Ap.buildAbsolute()},parse:function(){return AS(this.build())},withParams:function(Aq){return Ap.addParams(Aq).makeBuilder(Ao)},withFragment:function(Aq){return Ap.withFragment(Aq).makeBuilder(Ao)},addPathComponents:function(){return Ap.pushComponents.apply(Ap,arguments).makeBuilder(Ao)}},Ao)};function An(Ao){if(typeof (Ao)==="string"){return Ao}else{if(!Ao){throw new Error(AF.I18n.getText("stash.web.error.no.project"))}}return Ao.getKey?Ao.getKey():Ao.key}function Ac(){if(R.getProject()){return R.getProject()}throw new Error(AF.I18n.getText("stash.web.error.no.project.context"))}function AI(Ao){if(typeof (Ao)==="string"){return Ao}else{if(!Ao){throw new Error(AF.I18n.getText("stash.web.error.no.repo"))}}return Ao.getSlug?Ao.getSlug():Ao.slug}function Al(Ao){if(typeof (Ao)==="string"){return Ao}else{if(!Ao){throw new Error(AF.I18n.getText("stash.web.error.no.hook.key"))}}return Ao.getDetails().getKey()}function u(){if(R.getRepository()){return R.getRepository()}throw new Error(AF.I18n.getText("stash.web.error.no.repo.context"))}function j(Ao){if(Ao!==0&&!Ao){throw new Error(AF.I18n.getText("stash.web.error.no.pull-request.id"))}if(typeof Ao in {string:1,number:1}){return Ao}return Ao.getId?Ao.getId():Ao.id}function g(){if(R.getPullRequest()){return R.getPullRequest()}throw new Error(AF.I18n.getText("stash.web.error.no.pull-request.context"))}function AB(Ar){var Aq=Ar.components[1];var Ap=/~(.*)/;var Ao=Ap.exec(Aq);if(Ao){return new d(["users",Ao[1].toLowerCase()])}else{return Ar}}function D(Ao){if(Ao.length===1){if(Ao[0]&&Ao[0].components){return Ao[0].components}else{if(Ao[0]&&Ao[0].getComponents){return Ao[0].getComponents()}else{if(Ab.isArray(Ao[0])){return Ao[0]}}}}return AD.toArray(Ao)}function AX(){return new d("login").makeBuilder({next:Y})}function Y(Ap){if(typeof Ap!=="string"){var Ao=AF.contextPath();var Aq=location.pathname;if(Ao.length>0){Aq=Aq.substring(Aq.indexOf(Ao)+Ao.length)}Ap=Aq+location.search+location.hash}return this._path().addParams({next:Ap}).makeBuilder()}function M(){return new d("tmp").makeBuilder({avatars:function Ao(){return this._path().pushComponents("avatars").makeBuilder()}})}function J(){return AO()}function AO(){return new d("getting-started").makeBuilder({next:Y})}function h(){return new d("admin").makeBuilder({permissions:e,users:S,groups:F,licensing:function Ao(){return this._path().pushComponents("license").makeBuilder({edit:function Ar(){return this._path().addParams({edit:""}).makeBuilder()}})},mailServer:function Aq(){return this._path().pushComponents("mail-server").makeBuilder()},db:function Ap(){return this._path().pushComponents("db").makeBuilder()}})}function AA(){return new d("projects").makeBuilder()}function AL(){return new d("repos").makeBuilder({visibility:function Ao(Ap){return this._path().addParams({visibility:Ap}).makeBuilder()}})}function Af(){return new d("captcha").addParams({ts:new Date().getTime().toString()}).makeBuilder()}function Ad(At){var As=new d(["projects",An(At)]);return AB(As).makeBuilder({allRepos:Ai,repo:H,createRepo:function Ap(){return AB(this._path()).pushComponents("repos").addParams("create").makeBuilder()},settings:function Aq(){return this._path().pushComponents("settings").makeBuilder()},permissions:e,remove:function Ao(){return this._path().makeBuilder()},users:S,groups:F,avatar:function Ar(Av){var Au=this._path().pushComponents("avatar.png");if(Av){Au=Au.addParams({s:Av})}return Au.makeBuilder()}})}function AY(){return Ad(Ac())}function v(){return new d("projects").addParams("create").makeBuilder()}function AJ(At,Ap){At=At||"api";Ap=Ap||"latest";return new d(["rest",At,Ap]).makeBuilder({project:b,currentProject:X,currentRepo:O,currentPullRequest:AH,markup:function Ao(){return this._path().pushComponents("markup").makeBuilder({preview:function Av(){return this._path().pushComponents("preview").makeBuilder()}})},profile:function Ar(){return this._path().pushComponents("profile").makeBuilder({recent:function Av(){return this._path().pushComponents("recent").makeBuilder({repos:function Aw(){return this._path().pushComponents("repos").makeBuilder()}})}})},users:function Aq(Aw){var Av=this._path().pushComponents("users");if(Aw){return Av.pushComponents(Aw).makeBuilder({avatar:G})}return Av.makeBuilder()},groups:function Au(){return this._path().pushComponents("groups").makeBuilder()},hooks:T,allRepos:Ai,admin:function As(){return this._path().pushComponents("admin").makeBuilder({users:function Av(){return this._path().pushComponents("users").makeBuilder()}})}})}function Aj(){return new d(["plugins","servlet","upm"]).makeBuilder({requests:function Ao(){return this._path().pushComponents("requests","popular").makeBuilder({category:function(Ap){return this._path().addParams({category:Ap}).makeBuilder()}})}})}function B(){return new d(["plugins","servlet"]).makeBuilder({path:function Ao(){var Ap=this._path();return Ap.pushComponents.apply(Ap,D(arguments)).makeBuilder()}})}function e(){return this._path().pushComponents("permissions").makeBuilder({permission:V,users:S,groups:F})}function V(Ao){return this._path().pushComponents(Ao).makeBuilder({users:function Aq(){return this._path().pushComponents("users").makeBuilder()},groups:function Ar(){return this._path().pushComponents("groups").makeBuilder()},all:function Ap(){return this._path().pushComponents("all").makeBuilder()}})}function S(){return this._path().pushComponents("users").makeBuilder({create:A,deleteUser:AU,captcha:function Ao(Ap){return this._path().pushComponents("captcha").addParams({name:Ap}).makeBuilder()},view:Ah,filter:AC,deleteSuccess:Ak,permissions:e,none:AG})}function F(){return this._path().pushComponents("groups").makeBuilder({create:A,deleteGroup:AU,view:Ah,filter:AC,deleteSuccess:Ak,permissions:e,none:AG})}function AG(){return this._path().pushComponents("none").makeBuilder()}function Ai(){return AB(this._path()).pushComponents("repos").makeBuilder()}function x(Ao){return new d(["users",Ao]).makeBuilder({avatar:G})}function A(){return this._path().addParams({create:""}).makeBuilder()}function AU(Ao){return this._path().addParams({name:Ao}).makeBuilder()}function Ah(Ao){return this._path().pushComponents("view").addParams({name:Ao}).makeBuilder()}function AC(Ao){return this._path().addParams({filter:Ao}).makeBuilder()}function Ak(Ao){return this._path().addParams({deleted:Ao}).makeBuilder()}function H(Av){return AB(this._path()).pushComponents("repos",AI(Av)).makeBuilder({browse:function At(){return this._path().pushComponents("browse").makeBuilder(k)},diff:U,commits:function Ao(){return this._path().pushComponents("commits").makeBuilder({until:function A0(A2){var A1=this._path();if(A2&&!A2.isDefault){if(typeof A2!=="string"){A2=A2.displayId||A2}A1=A1.addParams({until:A2})}return A1.makeBuilder()}})},branches:function Aq(A1){var A0=this._path().pushComponents("branches");if(A1&&!A1.isDefault){if(typeof A1!=="string"){A1=A1.displayId||A1.id||A1}A0=A0.addParams({base:A1})}return A0.makeBuilder()},changeset:r,commit:r,compare:function Az(){function A0(A1){return function(){return this._path().pushComponents(A1).makeBuilder(t)}}return this._path().pushComponents("compare").makeBuilder(AD.extend({commits:A0("commits"),diff:A0("diff")},E))},settings:function Aw(){return this._path().pushComponents("settings").makeBuilder()},permissions:e,hooks:Aa,clone:function As(A1){var A3=this._path(),A0=A3.components[1].toLowerCase(),A2=A3.components[3].toLowerCase();if(A3.components[0]==="users"){A0="~"+A0}return new d(["scm",A0,A2+"."+A1],A3.params).makeBuilder()},fork:function Au(){return this._path().addParams("fork").makeBuilder()},allPullRequests:function Ar(){return this._path().pushComponents("pull-requests").makeBuilder()},createPullRequest:function Ay(){return this._path().pushComponents("pull-requests").addParams("create").makeBuilder(t)},pullRequest:AK,attachments:function Ap(){return this._path().pushComponents("attachments").makeBuilder()},sizes:function Ax(){return this._path().pushComponents("sizes").makeBuilder()},build:function(){return this._path().pushComponents("browse").toString()}})}function I(){return AY().repo(R.getRepository())}var i={at:function y(Ap){var Ao=this._path();if(Ap){if(typeof Ap!=="string"){Ap=Ap.displayId||Ap}Ao=Ao.addParams({at:Ap})}return Ao.makeBuilder(i)},until:function AM(Ao){return this._path().addParams({until:Ao}).makeBuilder(i)},raw:function P(){return this._path().addParams({raw:""}).makeBuilder(i)}};var k={path:function AQ(){var Ao=this._path();return Ao.pushComponents.apply(Ao,D(arguments)).makeBuilder(i)},at:i.at};function U(Ap){var Aq=this._path(),Au;var At=(Ap.getCommitRange&&Ap.getPath&&Ap.getSrcPath);var As=(Ap.commitRange&&Ap.path&&Ap.srcPath);var Ao;if(At||As){Ao=Ap.toJSON?Ap.toJSON():Ap}if(Ao){var Ar=Ao.commitRange;Au=Ao.path;if(Ar.pullRequest){Aq=Aq.pushComponents("pull-requests",Ar.pullRequest.id)}else{Aq=Aq.addParams(Ab.extend({},{until:Ar.untilRevision&&Ar.untilRevision.id||undefined,since:Ar.sinceRevision&&Ar.sinceRevision.id||undefined}))}}else{Au=Ap}Aq=Aq.pushComponents("diff");Aq=Aq.pushComponents.apply(Aq,Au&&D([Au]));Aq=Aq.addParams(Ab.extend({},{srcPath:Ao&&Ao.srcPath||undefined}));return Aq.makeBuilder(i)}function r(Ao){return this._path().pushComponents("commits",Ao).makeBuilder({comment:function Ap(Aq){return this._path().addParams({commentId:Aq}).makeBuilder()}})}function Aa(){return this._path().pushComponents("settings","hooks").makeBuilder()}var t={_builder:null,sourceBranch:function N(Ao){return this._path().addParams({sourceBranch:Ao}).makeBuilder(this._builder)},targetBranch:function l(Ao){return this._path().addParams({targetBranch:Ao}).makeBuilder(this._builder)},targetRepo:function AZ(Ao){return this._path().addParams({targetRepoId:Ao}).makeBuilder(this._builder)}};t._builder=t;var E=AD.extend({build:function(){return this._path().pushComponents("commits").toString()}},t);E._builder=E;function AK(Aq){return this._path().pushComponents("pull-requests",j(Aq)).makeBuilder({unwatch:function At(){return this._path().pushComponents("unwatch").makeBuilder()},changeset:function Ao(Au){return this._path().pushComponents("commits",Au).makeBuilder()},overview:function As(){return this._path().pushComponents("overview").makeBuilder({comment:function Av(Aw){return this._path().addParams({commentId:Aw}).makeBuilder()},activity:function Au(Aw){return this._path().addParams({activityId:Aw}).makeBuilder()}})},diff:function Ar(){return this._path().pushComponents("diff").makeBuilder({change:function(Au){return this._path().withFragment(Au).makeBuilder()}})},commits:function Ap(){return this._path().pushComponents("commits").makeBuilder()},build:function(){return this._path().pushComponents("overview").toString()}})}function n(){return I.call(this).pullRequest(g())}function b(Aq){var Ao=An(Aq);return this._path().pushComponents("projects",Ao).makeBuilder({allRepos:function Ap(){return this._path().pushComponents("repos").makeBuilder()},repo:AE,permissions:a})}function X(){return b.call(this,Ac())}function O(){return X.call(this).repo(u())}function Q(Ar){var Ap=Al(Ar);return this._path().pushComponents("settings").pushComponents("hooks",Ap).makeBuilder({enabled:function Ao(){return this._path().pushComponents("enabled").makeBuilder()},settings:function Aq(){return this._path().pushComponents("settings").makeBuilder()}})}function AE(Au){var Ar=AI(Au);return this._path().pushComponents("repos",Ar).makeBuilder({tags:function Aq(){return this._path().pushComponents("tags").makeBuilder()},branches:function Ap(){return this._path().pushComponents("branches").makeBuilder()},commits:function Aw(){return this._path().pushComponents("commits").makeBuilder()},commit:o,compare:function As(){var Ay=function(A1,A2){var A3={};A3[A1]=A2;return this._path().addParams(A3).makeBuilder(Az)};var A0=function(A1){return function(){return this._path().pushComponents(A1).makeBuilder(Az)}};var Az={from:AD.partial(Ay,"from"),to:AD.partial(Ay,"to"),fromRepo:AD.partial(Ay,"fromRepo")};return this._path().pushComponents("compare").makeBuilder({changes:A0("changes"),commits:A0("commits"),diff:function(A1){return q.call(this,A1,Az)}})},changeset:o,changes:function Ax(Ay){Ay=Ay.toJSON?Ay.toJSON():Ay;if(Ay.pullRequest){return this.pullRequest(Ay.pullRequest).changes()}else{if(Ay.untilRevision){return this.changeset(Ay).changes()}else{throw new Error("A valid commit-range is required to retrieve changes")}}},browse:function Av(){return this._path().pushComponents("browse").makeBuilder(k)},files:Z,related:function Ao(){return this._path().pushComponents("related").makeBuilder()},pullRequest:AR,allPullRequests:function At(){return this._path().pushComponents("pull-requests").makeBuilder()},hooks:Aa,hook:Q})}function AR(Av){var Ao=j(Av);return this._path().pushComponents("pull-requests",Ao).makeBuilder({activities:function(){return this._path().pushComponents("activities").makeBuilder()},approve:function Ap(){return this._path().pushComponents("approve").makeBuilder()},comment:function Ar(Ax){return this._path().pushComponents("comments",Ax).makeBuilder({comment:Ar})},comments:function(){return this._path().pushComponents("comments").makeBuilder()},changes:function As(){return this._path().pushComponents("changes").makeBuilder()},diff:AV,watch:function At(){return this._path().pushComponents("watch").makeBuilder()},merge:function Au(){return this._path().pushComponents("merge").makeBuilder()},reopen:function Aq(){return this._path().pushComponents("reopen").makeBuilder()},decline:function Aw(){return this._path().pushComponents("decline").makeBuilder()}})}function AH(){return O.call(this).pullRequest(g())}function o(Aq){Aq=Aq.toJSON?Aq.toJSON():Aq;var At=this._path().pushComponents("commits");if(typeof Aq==="string"){At=At.pushComponents(Aq)}else{if(Aq.untilRevision){At=At.pushComponents(Aq.untilRevision.id);var Ar=Aq.sinceRevision&&Aq.sinceRevision.id;if(Ar){At=At.addParams({since:Ar})}}else{throw new Error(AF.I18n.getText("stash.web.error.no.commit.or.commitRange"))}}return At.makeBuilder({diff:AV,changes:function Ap(){return this._path().pushComponents("changes").makeBuilder(C)},comments:function As(){return this._path().pushComponents("comments").makeBuilder(C)},watch:function Ao(){return this._path().pushComponents("watch").makeBuilder()}})}var C={path:function L(Ao){return this._path().addParams({path:Ao.toString()}).makeBuilder()}};function q(Ap,Ar){var Ao=Ap.toJSON?Ap.toJSON():Ap;var Aq=this._path();Aq=Aq.pushComponents("diff");Aq=Aq.pushComponents.apply(Aq,D([Ao.path]));if(Ao.srcPath){Aq=Aq.addParams({srcPath:new AT(Ao.srcPath).toString()})}return Aq.makeBuilder(Ar)}function AV(Ao){return q.call(this,Ao)}function Ae(){return this._path().pushComponents("browse").makeBuilder(k)}var c={at:i.at};var W={path:function m(){var Ao=this._path();return Ao.pushComponents.apply(Ao,D(arguments)).makeBuilder(c)},at:c.at};function Z(){return this._path().pushComponents("files").makeBuilder(Ab.extend({all:Am.fn(K,"nav.rest().{currentRepo()|project().repo()}.files().all()",null,"3.0","4.0")},W))}function K(){return this._path().addParams({limit:100000}).makeBuilder(W)}function a(){return this._path().pushComponents("permissions").makeBuilder({projectRead:function Ap(){return this._path().pushComponents("project-read").makeBuilder({all:AN,anon:function Aq(){return this._path().pushComponents("anon").makeBuilder(p)}})},projectWrite:function Ao(){return this._path().pushComponents("project-write").makeBuilder({all:AN})}})}var p={allow:AW};function AN(){return this._path().pushComponents("all").makeBuilder(p)}function AW(Ao){return this._path().addParams({allow:Ao}).makeBuilder()}function T(){return this._path().pushComponents("hooks").makeBuilder({hook:function Ao(Ap){return this._path().pushComponents(Ap).makeBuilder({avatar:function Aq(Ar){return this._path().pushComponents("avatar").addParams({version:Ar}).makeBuilder()}})}})}function G(Ap){var Ao=this._path().pushComponents("avatar.png");if(Ap){Ao=Ao.addParams({s:Ap})}return Ao.makeBuilder()}var Ag=/(default-avatar-)\d+(\.png)/;function z(Ao,Ap){return{build:function(){var Aq=AS(Ao.avatarUrl);if(Aq.getQueryParamValue("s")){Aq.replaceQueryParam("s",Ap)}return Aq.toString().replace(Ag,"$1"+Ap+"$2")}}}function AS(Ao){return new f(Ao)}function AP(Ao){return new Query(Ao)}function s(Ao,Ap){return new d(Ao,Ap).makeBuilder()}w._avatarUrl=z;w.addons=Aj;w.admin=h;w.allProjects=AA;w.allRepos=AL;w.captcha=Af;w.createProject=v;w.currentProject=AY;w.currentPullRequest=n;w.currentRepo=I;w.login=AX;w.newBuilder=s;w.parse=AS;w.parseQuery=AP;w.pluginServlets=B;w.project=Ad;w.rest=AJ;w.tmp=M;w.user=x;w.welcome=J;w.gettingStarted=AO});