NIFI-326:

- Enabling the Enable/Disable button whenever the selection is not empty.
- On Enable/Disable click, the components that support the desired action are filtered. The action (Enable/Disable) is then applied to the filtered selection.
This commit is contained in:
Matt Gilman 2015-02-17 12:34:01 -05:00
parent 4239797b9f
commit 0047fa4502
2 changed files with 13 additions and 10 deletions

View File

@ -349,7 +349,12 @@ nf.Actions = (function () {
enable: function () { enable: function () {
var components = d3.selectAll('g.component.selected').filter(function (d) { var components = d3.selectAll('g.component.selected').filter(function (d) {
var selected = d3.select(this); var selected = d3.select(this);
return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) && nf.CanvasUtils.supportsModification(selected); var selectedData = selected.datum();
// processors and ports that support modification and are not currently stopped
return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) &&
nf.CanvasUtils.supportsModification(selected) &&
selectedData.component.state !== 'STOPPED';
}); });
if (components.empty()) { if (components.empty()) {
nf.Dialog.showOkDialog({ nf.Dialog.showOkDialog({
@ -379,7 +384,12 @@ nf.Actions = (function () {
disable: function () { disable: function () {
var components = d3.selectAll('g.component.selected').filter(function (d) { var components = d3.selectAll('g.component.selected').filter(function (d) {
var selected = d3.select(this); var selected = d3.select(this);
return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) && nf.CanvasUtils.supportsModification(selected); var selectedData = selected.datum();
// processors and ports that support modification and are not currently disabled
return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) &&
nf.CanvasUtils.supportsModification(selected) &&
selectedData.component.state !== 'DISABLED';
}); });
if (components.empty()) { if (components.empty()) {
nf.Dialog.showOkDialog({ nf.Dialog.showOkDialog({
@ -435,7 +445,6 @@ nf.Actions = (function () {
data['running'] = true; data['running'] = true;
} }
// update the resource
updateResource(d.component.uri, data).done(function (response) { updateResource(d.component.uri, data).done(function (response) {
if (nf.CanvasUtils.isProcessor(selected)) { if (nf.CanvasUtils.isProcessor(selected)) {
nf.Processor.set(response.processor); nf.Processor.set(response.processor);

View File

@ -148,14 +148,8 @@ nf.CanvasToolbar = (function () {
actions['fill'].disable(); actions['fill'].disable();
} }
// determine if there are any selected components that support enable/disable
var supportsEnable = selection.filter(function(d) {
var selected = d3.select(this);
return nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected);
});
// ensure the entire selection supports enable/disable // ensure the entire selection supports enable/disable
if (!supportsEnable.empty() && supportsEnable.size() === selection.size()) { if (!selection.empty()) {
actions['enable'].enable(); actions['enable'].enable();
actions['disable'].enable(); actions['disable'].enable();
} else { } else {