Skip to content
Snippets Groups Projects
Commit 52cf504f authored by Eric Rosenbaum's avatar Eric Rosenbaum
Browse files

Scroll to extension category when attempting to load duplicate

parent 9ee5ce49
Branches
Tags
No related merge requests found
......@@ -31,6 +31,7 @@ class Blocks extends React.Component {
bindAll(this, [
'attachVM',
'detachVM',
'handleCategorySelected',
'handlePromptStart',
'handlePromptCallback',
'handlePromptClose',
......@@ -194,6 +195,9 @@ class Blocks extends React.Component {
const toolboxXML = makeToolboxXML(dynamicBlocksXML);
this.props.onExtensionAdded(toolboxXML);
const categoryName = blocksInfo[0].json.category;
this.handleCategorySelected(categoryName);
}
handleCategorySelected (categoryName) {
this.workspace.toolbox_.setSelectedCategoryByName(categoryName);
}
setBlocks (blocks) {
......@@ -241,6 +245,7 @@ class Blocks extends React.Component {
{extensionLibraryVisible ? (
<ExtensionLibrary
vm={vm}
onCategorySelected={this.handleCategorySelected}
onRequestClose={onRequestCloseExtensionLibrary}
/>
) : null}
......
......@@ -20,9 +20,10 @@ class ExtensionLibrary extends React.PureComponent {
const url = item.extensionURL || prompt('Enter the URL of the extension');
if (url) {
if (this.props.vm.extensionManager.isExtensionLoaded(url)) {
return;
this.props.onCategorySelected(item.name);
} else {
this.props.vm.extensionManager.loadExtensionURL(url);
}
this.props.vm.extensionManager.loadExtensionURL(url);
}
}
render () {
......@@ -43,6 +44,7 @@ class ExtensionLibrary extends React.PureComponent {
}
ExtensionLibrary.propTypes = {
onCategorySelected: PropTypes.func,
onRequestClose: PropTypes.func,
visible: PropTypes.bool,
vm: PropTypes.instanceOf(VM).isRequired // eslint-disable-line react/no-unused-prop-types
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment