-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: b=master,r=eafdd59328222f7829cb98f42a67e3315d4a08a2,t=2019-…
…01-06-1232-49871
- Loading branch information
1 parent
34ec772
commit 13a2f9c
Showing
30 changed files
with
849 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* 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. | ||
*/ | ||
|
||
var TestClasses = {}; | ||
|
||
var Ext = { | ||
define: function(className, implementationObject) { | ||
TestClasses[className] = implementationObject; | ||
} | ||
}; | ||
|
||
function MockComponent(properties) { | ||
this.properties = properties; | ||
} | ||
MockComponent.prototype.get = function(propertyName) { | ||
return this.properties[propertyName]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
components/nexus-rapture/src/main/baseapp/sass/src/NX/view/info/DependencySnippetPanel.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @class NX.view.info.DependencySnippetPanel | ||
*/ | ||
|
||
.nx-info-dependency-snippet-panel { | ||
.description { | ||
color: $color-charcoal; | ||
margin: 10px 2px 0 2px; | ||
} | ||
.snippet-text { | ||
background-color: $color-light-smoke; | ||
margin: 5px 0 0 0; | ||
overflow: auto; | ||
padding: 10px 5px; | ||
width: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
components/nexus-rapture/src/main/resources/static/rapture/NX/util/Clipboard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* 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 Ext, NX*/ | ||
|
||
/** | ||
* Clipboard related utils. | ||
* | ||
* @since 3.next | ||
*/ | ||
Ext.define('NX.util.Clipboard', { | ||
singleton: true, | ||
|
||
/** | ||
* Copy specified text to clipboard | ||
* | ||
* @public | ||
* @param {String} text | ||
*/ | ||
copyToClipboard: function(text) { | ||
var textarea; | ||
if (navigator.clipboard) { | ||
navigator.clipboard.writeText(text); | ||
} else if (window.clipboardData && window.clipboardData.setData) { | ||
window.clipboardData.setData("Text", text); | ||
} else { | ||
textarea = document.createElement("textarea"); | ||
textarea.value = text; | ||
textarea.style.position = 'fixed'; | ||
textarea.style.left = '-99999px'; | ||
textarea.style.height = '1em'; | ||
textarea.style.width = '1em'; | ||
document.body.appendChild(textarea); | ||
textarea.select(); | ||
|
||
try { | ||
document.execCommand('copy'); | ||
} catch (err) { | ||
console.error('Unable to copy text to clipboard: ', err); | ||
} | ||
|
||
document.body.removeChild(textarea); | ||
} | ||
} | ||
}); |
175 changes: 175 additions & 0 deletions
175
...ts/nexus-rapture/src/main/resources/static/rapture/NX/view/info/DependencySnippetPanel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* 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 Ext*/ | ||
|
||
/** | ||
* Dependency snippet info panel. | ||
* | ||
* @since 3.next | ||
*/ | ||
Ext.define('NX.view.info.DependencySnippetPanel', { | ||
extend: 'Ext.panel.Panel', | ||
alias: 'widget.nx-info-dependency-snippet-panel', | ||
|
||
requires: [ | ||
'NX.I18n', | ||
'NX.util.Clipboard' | ||
], | ||
|
||
cls: 'nx-info-dependency-snippet-panel', | ||
|
||
framed: true, | ||
scrollable: true, | ||
header: false, | ||
|
||
/** | ||
* @private | ||
*/ | ||
initComponent: function() { | ||
this.items = { | ||
xtype: 'panel', | ||
ui: 'nx-inset', | ||
title: NX.I18n.get('DependencySnippetPanel_Title'), | ||
collapsible: this.collapsible === undefined ? true : this.collapsible, | ||
|
||
items: { | ||
xtype: 'panel', | ||
ui: 'nx-subsection', | ||
frame: true, | ||
layout: 'vbox', | ||
items: [ | ||
{ | ||
xtype: 'container', | ||
layout: 'hbox', | ||
flex: 1, | ||
height: "auto", | ||
width: "100%", | ||
items: [ | ||
{ | ||
xtype: 'combo', | ||
name: 'toolCombo', | ||
editable: false, | ||
store: [], | ||
queryMode: 'local', | ||
flex: 1, | ||
listeners: { | ||
change: this.showSnippetText.bind(this) | ||
} | ||
}, { | ||
xtype: 'button', | ||
margin: '0 0 0 24px', | ||
tooltip: NX.I18n.get('DependencySnippetPanel_Copy_Button_Tooltip'), | ||
glyph: 'xf0c5@FontAwesome' /* fa-copy */, | ||
listeners: { | ||
click: this.onCopyClick.bind(this) | ||
} | ||
} | ||
] | ||
}, { | ||
xtype: 'component', | ||
name: 'snippet', | ||
editable: false, | ||
layout: 'vbox', | ||
flex: 2, | ||
tpl: '<p class="description">{description}</p>' + | ||
'<pre class="snippet-text">{snippetText}</pre>', | ||
data: {text: ''}, | ||
width: "100%" | ||
} | ||
] | ||
} | ||
}; | ||
|
||
this.callParent(); | ||
}, | ||
|
||
getSnippetComponent: function() { | ||
return this.down('component[name="snippet"]'); | ||
}, | ||
|
||
getStorageKey: function(format) { | ||
return 'dependency-snippet-panel-' + format + '-tool-displayName'; | ||
}, | ||
|
||
getToolComboBox: function() { | ||
return this.down('combo[name="toolCombo"]'); | ||
}, | ||
|
||
setDependencySnippets: function(format, dependencySnippets) { | ||
var storedDisplayName = Ext.state.Manager.get(this.getStorageKey(format)), | ||
toolCombo = this.getToolComboBox(); | ||
|
||
this.format = format; | ||
this.dependencySnippetMap = {}; | ||
|
||
if (dependencySnippets && dependencySnippets.length > 0) { | ||
dependencySnippets.forEach(function(snippet) { | ||
this.dependencySnippetMap[snippet.displayName] = { | ||
snippetText: snippet.snippetText, | ||
description: snippet.description | ||
}; | ||
}, this); | ||
this.updateSnippetDisplayNames(dependencySnippets); | ||
if (storedDisplayName && toolCombo.store.findRecord("field1", storedDisplayName)) { | ||
this.selectSnippet(storedDisplayName); | ||
} else { | ||
this.selectSnippet(dependencySnippets[0].displayName); | ||
} | ||
} else { | ||
toolCombo.setStore([]); | ||
this.getSnippetComponent().update({ | ||
snippetText: '', | ||
description: '' | ||
}); | ||
} | ||
}, | ||
|
||
selectSnippet: function(displayName) { | ||
var toolCombo = this.getToolComboBox(), | ||
toolComboSelection = toolCombo.getSelection(), | ||
selectedDisplayName = toolComboSelection && toolComboSelection.get('field1'); | ||
|
||
if (selectedDisplayName === displayName) { | ||
// change event won't get fired so explicitly trigger text update | ||
this.showSnippetText(toolCombo, displayName); | ||
} else { | ||
toolCombo.select(displayName); | ||
} | ||
}, | ||
|
||
showSnippetText: function(toolCombo, selectedDisplayName) { | ||
var snippet = this.dependencySnippetMap[selectedDisplayName]; | ||
|
||
if (snippet) { | ||
this.getSnippetComponent().update({ | ||
snippetText: Ext.htmlEncode(snippet.snippetText), | ||
description: Ext.htmlEncode(snippet.description) | ||
}); | ||
Ext.state.Manager.set(this.getStorageKey(this.format), selectedDisplayName); | ||
} | ||
}, | ||
|
||
updateSnippetDisplayNames: function(dependencySnippets) { | ||
var toolCombo = this.getToolComboBox(), | ||
displayNames = dependencySnippets.map(function(snippet) { | ||
return snippet.displayName; | ||
}); | ||
|
||
toolCombo.setStore(displayNames); | ||
}, | ||
|
||
onCopyClick: function() { | ||
var text = this.getSnippetComponent().getData().snippetText; | ||
NX.util.Clipboard.copyToClipboard(Ext.htmlDecode(text)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
components/nexus-rapture/src/main/resources/static/rapture/resources/baseapp-prod_3.css
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.