Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[NEXUS-5360] Cleanup JS

  • Loading branch information...
commit 9d6a3a5feddac27443aa9a12753733f20fd7eb15 1 parent 7dd152c
@nabcos nabcos authored cstamas committed
View
2  nexus/nexus-webapp/src/main/webapp/js/nexus/ext/formpanel.js
@@ -341,5 +341,7 @@ Ext.extend(Nexus.ext.FormPanel, Ext.FormPanel, {
Sonatype.ext.FormPanel = Nexus.ext.FormPanel;
+return Nexus.ext.FormPanel;
+
});
View
12 nexus/nexus-webapp/src/main/webapp/js/repoServer/ConfigViewPanel.js
@@ -10,15 +10,15 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
+
+/*global define*/
+
/*
* View Nexus serer XML configuration file
*/
-
-define('repoServer/ConfigViewPanel',['sonatype/all'], function(){
-Sonatype.repoServer.ConfigViewPanel = function(config) {
- var config = config || {};
- var defaultConfig = {};
- Ext.apply(this, config, defaultConfig);
+define('repoServer/ConfigViewPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
+Sonatype.repoServer.ConfigViewPanel = function(cfg) {
+ Ext.apply(this, cfg || {});
this.listeners = {
// note: this isn't pre-render dependent, we just need an early event to
View
51 nexus/nexus-webapp/src/main/webapp/js/repoServer/GroupsEditPanel.js
@@ -10,14 +10,15 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
+/*global define*/
/*
* Repository Groups Edit/Create panel layout and controller
*/
-
-define('repoServer/GroupsEditPanel',['sonatype/all', 'nexus/ext/formpanel'], function(){
+define('repoServer/GroupsEditPanel', ['extjs', 'sonatype/all', 'nexus/ext/formpanel'], function(Ext, Sonatype, FormPanel){
Sonatype.repoServer.RepositoryGroupEditor = function(config) {
- var config = config || {};
- var defaultConfig = {
+ var
+ ht = Sonatype.repoServer.resources.help.groups,
+ defaultConfig = {
dataModifiers : {
load : {
repositories : this.loadRepositories.createDelegate(this),
@@ -34,9 +35,7 @@ Sonatype.repoServer.RepositoryGroupEditor = function(config) {
referenceData : Sonatype.repoServer.referenceData.group,
uri : Sonatype.config.repos.urls.groups
};
- Ext.apply(this, config, defaultConfig);
-
- var ht = Sonatype.repoServer.resources.help.groups;
+ Ext.apply(this, config || {}, defaultConfig);
this.tfStore = new Ext.data.SimpleStore({
fields : ['value'],
@@ -181,7 +180,7 @@ Sonatype.repoServer.RepositoryGroupEditor = function(config) {
});
};
-Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
+Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, FormPanel, {
isValid : function() {
if (!this.form.isValid())
@@ -197,18 +196,17 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
},
loadRepositories : function(arr, srcObject, fpanel) {
- var repoBox = fpanel.find('name', 'repositories')[0];
+ var i, repoBox = fpanel.find('name', 'repositories')[0];
this.repoStore.filterBy(function(rec, id) {
- var contentClass = this.contentClassStore.getById( rec.data.format );
+ var compatibleClasses, contentClass = this.contentClassStore.getById( rec.data.format );
// if we have the content class
// and the content class is compatible with the repo type
- if ( contentClass
- && rec.data.id != srcObject.id ) {
- var compatibleClasses = contentClass.get( 'compatibleTypes' );
+ if ( contentClass && rec.data.id !== srcObject.id ) {
+ compatibleClasses = contentClass.get( 'compatibleTypes' );
- for ( var i = 0 ; i < compatibleClasses.length ; i++ ) {
- if ( compatibleClasses[i] == srcObject.format ) {
+ for ( i = 0 ; i < compatibleClasses.length ; i+=1 ) {
+ if ( compatibleClasses[i] === srcObject.format ) {
return true;
}
}
@@ -225,11 +223,12 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
},
saveRepositories : function(value, fpanel) {
- var repoBox = fpanel.find('name', 'repositories')[0];
- var repoIds = repoBox.getValue();
+ var
+ i, response = [],
+ repoBox = fpanel.find('name', 'repositories')[0],
+ repoIds = repoBox.getValue();
- var response = [];
- for (var i = 0; i < repoIds.length; i++)
+ for (i = 0; i < repoIds.length; i+=1)
{
response.push({
id : repoIds[i]
@@ -263,11 +262,11 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
// @override
addSorted : function(store, rec) {
- var insertIndex;
- for (var i = 0; i < store.getCount(); i++)
+ var i, insertIndex, tempRec;
+ for (i = 0; i < store.getCount(); i+=1)
{
- var tempRec = store.getAt(i);
- if (tempRec.get('repoType') != 'group')
+ tempRec = store.getAt(i);
+ if (tempRec.get('repoType') !== 'group')
{
insertIndex = i;
break;
@@ -288,12 +287,12 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
});
Sonatype.Events.addListener('repositoryViewInit', function(cardPanel, rec) {
- var sp = Sonatype.lib.Permissions;
+ var sp = Sonatype.lib.Permissions, editor;
- if (rec.data.repoType == 'group' && rec.data.userManaged && sp.checkPermission('nexus:repogroups', sp.READ) && (sp.checkPermission('nexus:repogroups', sp.CREATE) || sp.checkPermission('nexus:repogroups', sp.EDIT)))
+ if (rec.data.repoType === 'group' && rec.data.userManaged && sp.checkPermission('nexus:repogroups', sp.READ) && (sp.checkPermission('nexus:repogroups', sp.CREATE) || sp.checkPermission('nexus:repogroups', sp.EDIT)))
{
- var editor = new Sonatype.repoServer.RepositoryGroupEditor({
+ editor = new Sonatype.repoServer.RepositoryGroupEditor({
tabTitle : 'Configuration',
name : 'configuration',
payload : rec
View
4 nexus/nexus-webapp/src/main/webapp/js/repoServer/LogEditPanel.js
@@ -10,9 +10,9 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
+/*global define*/
-define('repoServer/LogEditPanel',['sonatype/all'], function(){
-/*global Ext, Sonatype*/
+define('repoServer/LogEditPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
Sonatype.repoServer.LogEditPanel = function(cfg) {
var
config = cfg || {},
View
156 nexus/nexus-webapp/src/main/webapp/js/repoServer/LogsViewPanel.js
@@ -10,13 +10,11 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
+/*global define*/
-define('repoServer/LogsViewPanel',['sonatype/all'], function(){
-/*global Ext,Sonatype,Nexus*/
+define('repoServer/LogsViewPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
Sonatype.repoServer.LogsViewPanel = function(cfg) {
- var config = cfg || {}, defaultConfig = {};
-
- Ext.apply(this, config, defaultConfig);
+ Ext.apply(this, cfg || {});
this.currentLogUrl = null;
this.currentContentType = null;
@@ -219,30 +217,37 @@ Sonatype.repoServer.LogsViewPanel = function(cfg) {
Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
renderLogList : function(options, success, response) {
- if (success)
+ if (!success)
+ {
+ Sonatype.MessageBox.alert('Failed to get file list from server.');
+ }
+ else
{
- var resp = Ext.decode(response.responseText);
- var myMenu = Ext.menu.MenuMgr.get('log-menu');
+ var
+ i, name, size, text, uri, existingItem,
+ resp = Ext.decode(response.responseText),
+ myMenu = Ext.menu.MenuMgr.get('log-menu'),
+ list = resp.data,
+ sameUri = function(o) {
+ return o.logUri === uri;
+ };
- var list = resp.data;
this.sortFileListByName(list);
- for (var i = 0; i < list.length; i++)
+ for (i = 0; i < list.length; i+=1)
{
- var name = list[i].name;
- var size = list[i].size;
- var text = name + ' (' + this.printKb(size) + ')';
- var uri = list[i].resourceURI;
+ name = list[i].name;
+ size = list[i].size;
+ text = name + ' (' + this.printKb(size) + ')';
+ uri = list[i].resourceURI;
- var existingItem = myMenu.items.find(function(o) {
- return o.logUri == uri;
- });
+ existingItem = myMenu.items.find(sameUri);
if (existingItem)
{
existingItem.setText(text);
existingItem.value = size;
- if (this.currentLogUrl == uri)
+ if (this.currentLogUrl === uri)
{
this.totalSize = size;
this.getTopToolbar().items.get(2).setText(text);
@@ -279,59 +284,60 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
this.logToShowWhenLoaded = null;
}
}
- else
- {
- Sonatype.MessageBox.alert('Failed to get file list from server.');
- }
},
renderConfigList : function(options, success, response) {
- if (success)
+ if (!success)
+ {
+ Sonatype.MessageBox.alert('Failed to get config file list from server.');
+ }
+ else
{
- var resp = Ext.decode(response.responseText);
- var myMenu = Ext.menu.MenuMgr.get('log-menu');
+ var
+ i, name, uri, existingItem,
+ resp = Ext.decode(response.responseText),
+ myMenu = Ext.menu.MenuMgr.get('log-menu'),
+ list = resp.data,
+ sameUri = function(o) {
+ return o.logUri === uri;
+ };
+
- if (resp.data.length > 0)
+ this.sortFileListByName(list);
+
+ if (list.length > 0)
{
myMenu.add('-');
}
- var list = resp.data;
- this.sortFileListByName(list);
-
- for (var i = 0; i < list.length; i++)
+ for (i = 0; i < list.length; i+=1)
{
- var name = list[i].name;
- var uri = list[i].resourceURI;
+ name = list[i].name;
+ uri = list[i].resourceURI;
- var existingItem = myMenu.items.find(function(o) {
- return o.logUri === uri;
- });
+ existingItem = myMenu.items.find(sameUri);
if (!existingItem)
{
myMenu.addMenuItem({
- id : name,
- logUri : uri,
- text : name,
- value : 0,
- checked : false,
- group : 'rp-group',
- checkHandler : this.showItem.createDelegate(this, [name, 'application/xml'], 0),
- scope : this
- });
+ id : name,
+ logUri : uri,
+ text : name,
+ value : 0,
+ checked : false,
+ group : 'rp-group',
+ checkHandler : this.showItem.createDelegate(this, [name, 'application/xml'], 0),
+ scope : this
+ });
}
}
}
- else
- {
- Sonatype.MessageBox.alert('Failed to get config file list from server.');
- }
},
showItem : function(shortLogName, contentType, mItem, pressed) {
- if (!pressed)
+ if (!pressed) {
return;
+ }
this.logTextArea.setRawValue('');
this.currentSize = 0;
this.currentOffset = 0;
@@ -356,11 +362,11 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
// check to make sure the menubar is rendered
if (this.logListLoaded)
{
- var logsAndConfMenu = Ext.menu.MenuMgr.get('log-menu');
- for (var ii = 0; ii < logsAndConfMenu.items.length; ii++)
+ var ii, logsAndConfMenu = Ext.menu.MenuMgr.get('log-menu'), tmpMenuItem;
+ for (ii = 0; ii < logsAndConfMenu.items.length; ii+=1)
{
- var tmpMenuItem = logsAndConfMenu.items.itemAt(ii);
- if (tmpMenuItem != null && tmpMenuItem.id == logName)
+ tmpMenuItem = logsAndConfMenu.items.itemAt(ii);
+ if (tmpMenuItem && tmpMenuItem.id === logName)
{
this.showItem(tmpMenuItem.logUri, 'text/plain', tmpMenuItem, true);
break;
@@ -399,9 +405,9 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
{
toFetch = Number(this.fetchMoreButton.value) * 1024;
}
- if (toFetch == 0)
+ if (toFetch === 0)
{
- if (this.tailed && this.currentOffset == 0 && this.totalSize > 102400)
+ if (this.tailed && this.currentOffset === 0 && this.totalSize > 102400)
{ // 100Kb
this.currentOffset = this.totalSize - 102400;
}
@@ -416,7 +422,7 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
count : toFetch
},
headers : {
- 'accept' : this.currentContentType ? this.currentContentType : 'text/plain'
+ 'accept' : this.currentContentType || 'text/plain'
},
url : this.currentLogUrl
});
@@ -426,15 +432,15 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
renderLog : function(options, success, response) {
if (success)
{
- var text = response.responseText;
- var newValue = this.currentSize == 0 ? text : this.logTextArea.getRawValue() + text;
-
- var logDom = this.logTextArea.getEl().dom;
- var scrollTop = logDom.scrollTop;
- var scrollHeight = logDom.scrollHeight;
- var clientHeight = logDom.clientHeight;
+ var
+ text = response.responseText,
+ newValue = this.currentSize === 0 ? text : this.logTextArea.getRawValue() + text,
+ logDom = this.logTextArea.getEl().dom,
+ scrollTop = logDom.scrollTop,
+ scrollHeight = logDom.scrollHeight,
+ clientHeight = logDom.clientHeight;
this.logTextArea.setRawValue(newValue);
- if (this.tailEnabled && (scrollTop == 0 || scrollTop + clientHeight >= scrollHeight - 20))
+ if (this.tailEnabled && (scrollTop === 0 || scrollTop + clientHeight >= scrollHeight - 20))
{
scrollTop = logDom.scrollHeight - clientHeight;
}
@@ -447,12 +453,12 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
}
else
{
- Sonatype.utils.connectionError(response, 'The file failed to load from the server.')
+ Sonatype.utils.connectionError(response, 'The file failed to load from the server.');
}
},
fetchMore : function(button, event) {
- if (button.value != this.fetchMoreButton.value)
+ if (button.value !== this.fetchMoreButton.value)
{
this.fetchMoreButton.value = button.value;
this.fetchMoreButton.setText(button.text);
@@ -470,7 +476,7 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
this.fetchMoreBar.items.removeAt(0);
this.fetchMoreBar.insertButton(0, new Ext.Toolbar.TextItem('Displaying ' + (this.tailed ? 'last ' : '') + this.printKb(this.currentSize) + ' of ' + this.printKb(this.totalSize)));
- this.tailUpdateButton.setDisabled(this.currentLogUrl == Sonatype.config.repos.urls.configCurrent);
+ this.tailUpdateButton.setDisabled(this.currentLogUrl === Sonatype.config.repos.urls.configCurrent);
this.fetchMoreButton.setDisabled(this.currentOffset >= this.totalSize);
},
@@ -509,13 +515,13 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
},
loadTailButtonHandler : function(button, event) {
- if (button.value != this.tailUpdateButton.value)
+ if (button.value !== this.tailUpdateButton.value)
{
this.tailUpdateButton.value = button.value;
this.tailUpdateButton.setText(button.text);
this.fixUpdateTask();
}
- else if (button.value == 0)
+ else if (button.value === 0)
{
this.loadTail();
}
@@ -560,19 +566,21 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
sortFileListByName : function(list) {
list.sort(function(a, b) {
- var valueA = a.name.toLowerCase();
- var valueB = b.name.toLowerCase();
+ var
+ valueA = a.name.toLowerCase(),
+ valueB = b.name.toLowerCase();
+
if (valueA < valueB)
{
return -1;
}
- else if (valueA == valueB)
+ else if (valueA > valueB)
{
- return 0;
+ return 1;
}
else
{
- return 1;
+ return 0;
}
});
}
View
98 nexus/nexus-webapp/src/main/webapp/js/repoServer/Maven2InformationPanel.js
@@ -10,13 +10,12 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
-define('repoServer/Maven2InformationPanel',['sonatype/all'], function(){
+/*global define*/
+define('repoServer/Maven2InformationPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
Sonatype.repoServer.Maven2InformationPanel = function(config) {
- var config = config || {};
- var defaultConfig = {
+ Ext.apply(this, config || {}, {
halfSize : false
- };
- Ext.apply(this, config, defaultConfig);
+ });
this.sp = Sonatype.lib.Permissions;
@@ -81,7 +80,44 @@ Ext.extend(Sonatype.repoServer.Maven2InformationPanel, Ext.form.FormPanel, {
showArtifact : function(data, artifactContainer) {
this.data = data;
- if (data == null)
+ if (data) {
+ Ext.Ajax.request({
+ url : this.data.resourceURI + '?describe=maven2&isLocal=true',
+ callback : function(options, isSuccess, response) {
+ if (isSuccess)
+ {
+ var infoResp = Ext.decode(response.responseText);
+
+ // hide classifier if empty
+ if (this.data.classifier)
+ {
+ this.find('name', 'classifier')[0].show();
+ }
+ else
+ {
+ this.find('name', 'classifier')[0].hide();
+ }
+ this.form.setValues(infoResp.data);
+ artifactContainer.showTab(this);
+ }
+ else
+ {
+ if (response.status === 404)
+ {
+ artifactContainer.hideTab(this);
+ }
+ else
+ {
+ Sonatype.utils.connectionError(response, 'Unable to retrieve Maven information.');
+ }
+ }
+ },
+ scope : this,
+ method : 'GET',
+ suppressStatus : '404'
+ });
+ }
+ else
{
this.find('name', 'groupId')[0].setRawValue(null);
this.find('name', 'artifactId')[0].setRawValue(null);
@@ -90,44 +126,6 @@ Ext.extend(Sonatype.repoServer.Maven2InformationPanel, Ext.form.FormPanel, {
this.find('name', 'extension')[0].setRawValue(null);
this.find('name', 'dependencyXmlChunk')[0].setRawValue(null);
}
- else
- {
- Ext.Ajax.request({
- url : this.data.resourceURI + '?describe=maven2&isLocal=true',
- callback : function(options, isSuccess, response) {
- if (isSuccess)
- {
- var infoResp = Ext.decode(response.responseText);
-
- // hide classifier if empty
- if (this.data.classifier)
- {
- this.find('name', 'classifier')[0].show();
- }
- else
- {
- this.find('name', 'classifier')[0].hide();
- }
- this.form.setValues(infoResp.data);
- artifactContainer.showTab(this);
- }
- else
- {
- if (response.status = 404)
- {
- artifactContainer.hideTab(this);
- }
- else
- {
- Sonatype.utils.connectionError(response, 'Unable to retrieve Maven information.');
- }
- }
- },
- scope : this,
- method : 'GET',
- suppressStatus : '404'
- });
- }
}
});
@@ -142,13 +140,13 @@ Sonatype.Events.addListener('fileContainerInit', function(items) {
Sonatype.Events.addListener('fileContainerUpdate', function(artifactContainer, data) {
var panel = artifactContainer.find('name', 'maven2InformationPanel')[0];
- if (data == null || !data.leaf)
+ if ( data && data.leaf)
{
- panel.showArtifact(null, artifactContainer);
+ panel.showArtifact(data, artifactContainer);
}
else
{
- panel.showArtifact(data, artifactContainer);
+ panel.showArtifact(null, artifactContainer);
}
});
@@ -163,13 +161,13 @@ Sonatype.Events.addListener('artifactContainerInit', function(items) {
Sonatype.Events.addListener('artifactContainerUpdate', function(artifactContainer, payload) {
var panel = artifactContainer.find('name', 'maven2InformationPanel')[0];
- if (payload == null || !payload.leaf)
+ if (payload && payload.leaf)
{
- panel.showArtifact(null, artifactContainer);
+ panel.showArtifact(payload, artifactContainer);
}
else
{
- panel.showArtifact(payload, artifactContainer);
+ panel.showArtifact(null, artifactContainer);
}
});
View
127 nexus/nexus-webapp/src/main/webapp/js/repoServer/MirrorConfigPanel.js
@@ -10,12 +10,11 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
-define('repoServer/MirrorConfigPanel',['sonatype/all'], function(){
+/*global define*/
+define('repoServer/MirrorConfigPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
var MIRROR_URL_REGEXP = /^(?:http|https):\/\//i;
Sonatype.repoServer.AbstractMirrorPanel = function(config) {
- var config = config || {};
-
this.mirrorStatusTask = {
run : function() {
Ext.Ajax.request({
@@ -82,44 +81,42 @@ Sonatype.repoServer.AbstractMirrorPanel = function(config) {
}
};
- Ext.apply(this, config, defaultConfig);
+ Ext.apply(this, config || {}, defaultConfig);
Sonatype.repoServer.AbstractMirrorPanel.superclass.constructor.call(this, {});
};
Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
addNewMirrorUrl : function() {
- var treePanel = this.find('name', 'mirror-url-list')[0];
- var urlField = this.find('name', 'mirrorUrl')[0];
- if (urlField.isValid())
+ var
+ i,
+ treePanel = this.find('name', 'mirror-url-list')[0],
+ nodes = treePanel.root.childNodes,
+ urlField = this.find('name', 'mirrorUrl')[0],
+ url = urlField.getRawValue();
+
+ if (urlField.isValid() && url)
{
- var url = urlField.getRawValue();
-
- if (url)
+ for (i = 0; i < nodes.length; i+=1)
{
- var nodes = treePanel.root.childNodes;
- for (var i = 0; i < nodes.length; i++)
+ if (url === nodes[i].attributes.payload.url)
{
- if (url == nodes[i].attributes.payload.url)
- {
- urlField.markInvalid('This URL already exists');
- return;
- }
+ urlField.markInvalid('This URL already exists');
+ return;
}
+ }
- urlField.clearInvalid();
+ urlField.clearInvalid();
- this.addUrlNode(treePanel, url, url, Sonatype.config.extPath + '/resources/images/default/tree/leaf.gif');
- urlField.setRawValue('');
- urlField.setValue('');
- }
+ this.addUrlNode(treePanel, url, url, Sonatype.config.extPath + '/resources/images/default/tree/leaf.gif');
+ urlField.setRawValue('');
+ urlField.setValue('');
}
},
addUrlNode : function(treePanel, url, id, icon) {
- var validId;
- var manualUrl;
- if (url == id)
+ var validId, manualUrl;
+ if (url === id)
{
validId = Ext.id();
manualUrl = true;
@@ -146,9 +143,10 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
},
removeMirrorUrl : function() {
- var treePanel = this.find('name', 'mirror-url-list')[0];
+ var
+ treePanel = this.find('name', 'mirror-url-list')[0],
+ selectedNode = treePanel.getSelectionModel().getSelectedNode();
- var selectedNode = treePanel.getSelectionModel().getSelectedNode();
if (selectedNode)
{
treePanel.root.removeChild(selectedNode);
@@ -156,8 +154,9 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
},
removeAllMirrorUrls : function() {
- var treePanel = this.find('name', 'mirror-url-list')[0];
- var treeRoot = treePanel.root;
+ var
+ treePanel = this.find('name', 'mirror-url-list')[0],
+ treeRoot = treePanel.root;
while (treeRoot.lastChild)
{
@@ -166,20 +165,20 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
},
loadMirrors : function(arr, srcObj, fpanel) {
- var treePanel = this.find('name', 'mirror-url-list')[0];
-
- var mirrorArray = new Array();
+ var
+ i, j, childNodes, found,
+ treePanel = this.find('name', 'mirror-url-list')[0],
+ mirrorArray = [];
- for (var i = 0; i < arr.length; i++)
+ for (i = 0; i < arr.length; i+=1)
{
- var treePanel = this.find('name', 'mirror-url-list')[0];
- var childNodes = treePanel.getRootNode().childNodes;
- var found = false;
+ childNodes = treePanel.getRootNode().childNodes;
+ found = false;
if (childNodes && childNodes.length)
{
- for (var j = 0; j < childNodes.length; j++)
+ for (j = 0; j < childNodes.length; j+=1)
{
- if (arr[i].id == childNodes[j].id)
+ if (arr[i].id === childNodes[j].id)
{
mirrorArray[i] = {
id : arr[i].id,
@@ -203,7 +202,7 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
this.removeAllMirrorUrls();
- for (var i = 0; i < arr.length; i++)
+ for (i = 0; i < arr.length; i+=1)
{
this.addUrlNode(treePanel, mirrorArray[i].url, mirrorArray[i].id, mirrorArray[i].icon);
}
@@ -212,12 +211,13 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
},
saveMirrors : function(val, fpanel) {
- var treePanel = this.find('name', 'mirror-url-list')[0];
+ var
+ i,
+ treePanel = this.find('name', 'mirror-url-list')[0],
+ outputArr = [],
+ nodes = treePanel.root.childNodes;
- var outputArr = [];
- var nodes = treePanel.root.childNodes;
-
- for (var i = 0; i < nodes.length; i++)
+ for (i = 0; i < nodes.length; i+=1)
{
outputArr[i] = nodes[i].attributes.payload;
}
@@ -236,24 +236,27 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
statusCallback : function(options, success, response) {
if (success)
{
- var statusResp = Ext.decode(response.responseText);
+ var
+ i, j, data, item,
+ statusResp = Ext.decode(response.responseText),
+ treePanel = this.find('name', 'mirror-url-list')[0],
+ childNodes = treePanel.getRootNode().childNodes;
+
if (statusResp.data)
{
- var data = statusResp.data;
+ data = statusResp.data;
if (data && data.length)
{
- for (var i = 0; i < data.length; i++)
+ for (i = 0; i < data.length; i+=1)
{
- var item = data[i];
- var treePanel = this.find('name', 'mirror-url-list')[0];
- var childNodes = treePanel.getRootNode().childNodes;
+ item = data[i];
if (childNodes && childNodes.length)
{
- for (var j = 0; j < childNodes.length; j++)
+ for (j = 0; j < childNodes.length; j+=1)
{
- if (item.id == childNodes[j].id)
+ if (item.id === childNodes[j].id)
{
- childNodes[j].getUI().getIconEl().src = item.status == 'Blacklisted' ? (Sonatype.config.extPath + '/resources/images/default/tree/drop-no.gif') : (Sonatype.config.extPath + '/resources/images/default/tree/drop-yes.gif');
+ childNodes[j].getUI().getIconEl().src = item.status === 'Blacklisted' ? (Sonatype.config.extPath + '/resources/images/default/tree/drop-no.gif') : (Sonatype.config.extPath + '/resources/images/default/tree/drop-yes.gif');
break;
}
}
@@ -280,21 +283,21 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
this.predefinedMirrorDataStore.load();
}
- if (panel.payload.data.repoType == 'proxy')
+ if (panel.payload.data.repoType === 'proxy')
{
Ext.TaskMgr.start(this.mirrorStatusTask);
}
},
deactivateHandler : function(panel) {
- if (panel.payload.data.repoType == 'proxy')
+ if (panel.payload.data.repoType === 'proxy')
{
Ext.TaskMgr.stop(this.mirrorStatusTask);
}
},
destroyHandler : function(component) {
- if (component.payload.data.repoType == 'proxy')
+ if (component.payload.data.repoType === 'proxy')
{
Ext.TaskMgr.stop(this.mirrorStatusTask);
}
@@ -302,8 +305,7 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
});
Sonatype.repoServer.ProxyMirrorEditor = function(config) {
- var config = config || {};
- Ext.apply(this, config, {});
+ Ext.apply(this, config || {}, {});
var ht = Sonatype.repoServer.resources.help.repoMirrors;
this.mirrorRecordConstructor = Ext.data.Record.create([{
@@ -432,8 +434,7 @@ Sonatype.repoServer.ProxyMirrorEditor = function(config) {
Ext.extend(Sonatype.repoServer.ProxyMirrorEditor, Sonatype.repoServer.AbstractMirrorPanel, {});
Sonatype.repoServer.HostedMirrorEditor = function(config) {
- var config = config || {};
- Ext.apply(this, config, {});
+ Ext.apply(this, config || {});
var ht = Sonatype.repoServer.resources.help.repoMirrors;
Sonatype.repoServer.HostedMirrorEditor.superclass.constructor.call(this, {
@@ -532,9 +533,9 @@ Ext.extend(Sonatype.repoServer.HostedMirrorEditor, Sonatype.repoServer.AbstractM
Sonatype.Events.addListener('repositoryViewInit', function(cardPanel, rec) {
var sp = Sonatype.lib.Permissions;
- if (rec.data.resourceURI && sp.checkPermission('nexus:repositorymirrors', sp.READ) && rec.data.userManaged == true && (rec.data.repoType == 'proxy' || rec.data.repoType == 'hosted'))
+ if (rec.data.resourceURI && sp.checkPermission('nexus:repositorymirrors', sp.READ) && rec.data.userManaged)
{
- if (rec.data.repoType == 'proxy')
+ if (rec.data.repoType === 'proxy')
{
cardPanel.add(new Sonatype.repoServer.ProxyMirrorEditor({
payload : rec,
@@ -542,7 +543,7 @@ Sonatype.Events.addListener('repositoryViewInit', function(cardPanel, rec) {
name : 'mirrors'
}));
}
- else if (rec.data.repoType == 'hosted')
+ else if (rec.data.repoType === 'hosted')
{
cardPanel.add(new Sonatype.repoServer.HostedMirrorEditor({
payload : rec,
View
73 nexus/nexus-webapp/src/main/webapp/js/repoServer/PrivilegeEditPanel.js
@@ -10,17 +10,16 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
+/*global define*/
+
/*
* Privilege Edit/Create panel layout and controller
*/
-
-define('repoServer/PrivilegeEditPanel',['sonatype/all'], function(){
+define('repoServer/PrivilegeEditPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
Sonatype.repoServer.PrivilegeEditPanel = function(config) {
- var config = config || {};
- var defaultConfig = {
+ Ext.apply(this, config || {}, {
title : 'Privileges'
- };
- Ext.apply(this, config, defaultConfig);
+ });
this.sp = Sonatype.lib.Permissions;
@@ -174,18 +173,18 @@ Sonatype.repoServer.PrivilegeEditPanel = function(config) {
Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
convertRepository : function(value, parent) {
- var targetPriv = false;
- for (var i = 0; i < parent.properties.length; i++)
+ var i, targetPriv = false;
+ for (i = 0; i < parent.properties.length; i+=1)
{
- if (parent.properties[i].key == 'repositoryId' && !Ext.isEmpty(parent.properties[i].value))
+ if (parent.properties[i].key === 'repositoryId' && !Ext.isEmpty(parent.properties[i].value))
{
return this.convertDataValue(parent.properties[i].value, this.repoStore, 'id', 'name');
}
- else if (parent.properties[i].key == 'repositoryGroupId' && !Ext.isEmpty(parent.properties[i].value))
+ else if (parent.properties[i].key === 'repositoryGroupId' && !Ext.isEmpty(parent.properties[i].value))
{
return this.convertDataValue(parent.properties[i].value, this.groupStore, 'id', 'name');
}
- else if (parent.properties[i].key == 'repositoryTargetId')
+ else if (parent.properties[i].key === 'repositoryTargetId')
{
targetPriv = true;
}
@@ -202,9 +201,10 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
},
convertTarget : function(value, parent) {
- for (var i = 0; i < parent.properties.length; i++)
+ var i;
+ for (i = 0; i < parent.properties.length; i+=1)
{
- if (parent.properties[i].key == 'repositoryTargetId' && !Ext.isEmpty(parent.properties[i].value))
+ if (parent.properties[i].key === 'repositoryTargetId' && !Ext.isEmpty(parent.properties[i].value))
{
return this.convertDataValue(parent.properties[i].value, this.targetStore, 'id', 'name');
}
@@ -217,9 +217,10 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
},
convertMethod : function(value, parent) {
- for (var i = 0; i < parent.properties.length; i++)
+ var i;
+ for (i = 0; i < parent.properties.length; i+=1)
{
- if (parent.properties[i].key == 'method' && !Ext.isEmpty(parent.properties[i].value))
+ if (parent.properties[i].key === 'method' && !Ext.isEmpty(parent.properties[i].value))
{
return parent.properties[i].value;
}
@@ -232,11 +233,12 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
},
convertRepositoryProperty : function(value, parent) {
+ var i;
if (Ext.isEmpty(value))
{
- for (var i = 0; i < parent.length; i++)
+ for (i = 0; i < parent.length; i+=1)
{
- if (parent[i].key == 'repositoryGroupId' && !Ext.isEmpty(parent[i].value))
+ if (parent[i].key === 'repositoryGroupId' && !Ext.isEmpty(parent[i].value))
{
return '';
}
@@ -308,11 +310,12 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
},
submitHandler : function(form, action, receivedData) {
+ var i, r;
if (Ext.isArray(receivedData))
{
- for (var i = 0; i < receivedData.length; i++)
+ for (i = 0; i < receivedData.length; i+=1)
{
- var r = receivedData[i];
+ r = receivedData[i];
r.sTarget = this.convertTarget(r.repositoryTargetId, r);
r.sType = this.convertType(r.type, r);
r.sRepository = this.convertRepository(r.repositoryId, r);
@@ -324,13 +327,14 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
});
Sonatype.repoServer.PrivilegeEditor = function(config) {
- var config = config || {};
- var defaultConfig = {
+ var i, items, targetStore2, typeRec,
+ ht = Sonatype.repoServer.resources.help.privileges,
+ defaultConfig = {
uri : Sonatype.config.repos.urls.privileges + '_target',
dataModifiers : {
load : {
properties : function(value, parent, fpanel) {
- for (var i = 0; i < value.length; i++)
+ for (i = 0; i < value.length; i+=1)
{
var field = fpanel.form.findField(value[i].key);
field.setValue(fpanel.propertyTypeStore.getAt(fpanel.propertyTypeStore.find('type', field.fieldConverterType)).data.converter(value[i].value, value));
@@ -346,11 +350,11 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
},
repositoryId : function(val, fpanel) {
var v = fpanel.form.findField('repositoryOrGroup').getValue();
- return v.indexOf('repo_') == 0 ? v.substring('repo_'.length) : '';
+ return v.indexOf('repo_') === 0 ? v.substring('repo_'.length) : '';
},
repositoryGroupId : function(val, fpanel) {
var v = fpanel.form.findField('repositoryOrGroup').getValue();
- return v.indexOf('group_') == 0 ? v.substring('group_'.length) : '';
+ return v.indexOf('group_') === 0 ? v.substring('group_'.length) : '';
},
type : function(val, fpanel) {
return 'target';
@@ -363,9 +367,8 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
},
referenceData : Sonatype.repoServer.referenceData.privileges.target
};
- Ext.apply(this, config, defaultConfig);
+ Ext.apply(this, config || {}, defaultConfig);
- var ht = Sonatype.repoServer.resources.help.privileges;
this.COMBO_WIDTH = 300;
this.sp = Sonatype.lib.Permissions;
@@ -390,7 +393,7 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
this.readOnly = true;
}
- var items = [{
+ items = [{
xtype : 'hidden',
name : 'id'
}, {
@@ -416,7 +419,7 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
if (this.isNew)
{
// clone the target store
- var targetStore2 = new Ext.data.JsonStore({
+ targetStore2 = new Ext.data.JsonStore({
root : 'data',
id : 'id',
fields : [{
@@ -487,11 +490,11 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
disabled : true
});
- var typeRec = this.privilegeTypeStore.getById(this.payload.data.type);
+ typeRec = this.privilegeTypeStore.getById(this.payload.data.type);
if (!Ext.isEmpty(typeRec))
{
- for (var i = 0; i < typeRec.data.properties.length; i++)
+ for (i = 0; i < typeRec.data.properties.length; i+=1)
{
items.push({
xtype : 'textfield',
@@ -514,7 +517,7 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
Ext.extend(Sonatype.repoServer.PrivilegeEditor, Sonatype.ext.FormPanel, {
initCombinedRecord : function(rec) {
- var isGroup = rec.data.repoType == null;
+ var isGroup = rec.data.repoType === null || rec.data.repoType === undefined;
return {
id : (isGroup ? 'group_' : 'repo_') + rec.data.id,
name : rec.data.name + (isGroup ? ' (Group)' : ' (Repo)'),
@@ -541,12 +544,14 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditor, Sonatype.ext.FormPanel, {
},
repositorySelectHandler : function(combo, rec, index) {
- var targetCombo = this.form.findField('repositoryTargetId');
- var previousValue = targetCombo.getValue();
+ var
+ targetCombo = this.form.findField('repositoryTargetId'),
+ previousValue = targetCombo.getValue(),
+
+ filterValue = rec.data.format;
targetCombo.setValue(null);
targetCombo.store.clearFilter();
- var filterValue = rec.data.format;
if (filterValue)
{
targetCombo.store.filter('contentClass', filterValue);
View
7 nexus/nexus-webapp/src/main/webapp/js/repoServer/helpAbout.js
@@ -10,11 +10,10 @@
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
-define('repoServer/helpAbout',['sonatype/all'], function(){
+/*global define*/
+define('repoServer/helpAbout',['extjs', 'sonatype/all'], function(Ext, Sonatype){
Sonatype.repoServer.HelpAboutPanel = function(config) {
- var config = config || {};
- var defaultConfig = {};
- Ext.apply(this, config, defaultConfig);
+ Ext.apply(this, config || {});
var helpItems = [{
//add this one by default, so existing usage will be preserved
Please sign in to comment.
Something went wrong with that request. Please try again.