Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/781 #783

Merged
merged 3 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions actions/generals.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export const instanceAdded = instance => ({
data: instance
});

export const instanceDeleted = (type, instance) => ({
export const instanceDeleted = (type, id) => ({
type: type,
data: instance
data: id
});

export const instanceSelected = instance => ({
Expand Down
5 changes: 5 additions & 0 deletions components/VFBMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,11 @@ class VFBMain extends React.Component {
GEPPETTO.on(GEPPETTO.Events.Instance_added, function (instance) {
that.props.instanceAdded(instance);
});

GEPPETTO.on(GEPPETTO.Events.Instance_deleted, function (instancePath) {
let id = instancePath.split(".")[0];
that.props.instanceDeleted(ACTIONS.INSTANCE_DELETED, id);
});

GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idsFinalList);
Expand Down
8 changes: 2 additions & 6 deletions components/interface/VFBListViewer/ListViewerControlsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from "react";
import Menu from "@geppettoengine/geppetto-ui/menu/Menu";
import { connect } from 'react-redux';
import { SliderPicker } from 'react-color';
import { setTermInfo, SHOW_LIST_VIEWER, INSTANCE_DELETED } from './../../../actions/generals';
import { setTermInfo, SHOW_LIST_VIEWER } from './../../../actions/generals';

const controlsConfiguration = require('../../configuration/VFBListViewer/controlsMenuConfiguration').default;
const ACTIONS = controlsConfiguration.actions;
Expand Down Expand Up @@ -62,7 +62,6 @@ class ListViewerControlsMenu extends Component {
break;
case ACTIONS.DELETE:
this.props.instance.delete();
this.props.instanceDeleted(INSTANCE_DELETED, this.props.instance);
break;
case ACTIONS.INFO:
var self = this;
Expand Down Expand Up @@ -247,10 +246,7 @@ function mapStateToProps (state) {
}

function mapDispatchToProps (dispatch) {
return {
setTermInfo: (instance, visible) => dispatch(setTermInfo(instance, visible )),
instanceDeleted : ( type, instance ) => dispatch({ type : type , instance : instance })
}
return { setTermInfo: (instance, visible) => dispatch(setTermInfo(instance, visible )) }
}

export default connect(mapStateToProps, mapDispatchToProps)(ListViewerControlsMenu);
2 changes: 2 additions & 0 deletions containers/VFBMainContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
vfbUIUpdated,
instanceAdded,
instanceSelected,
instanceDeleted,
instanceVisibilityChanged,
setTermInfo,
vfbGraph,
Expand All @@ -22,6 +23,7 @@ const mapDispatchToProps = dispatch => ({
vfbCircuitBrowser: (type, path, visible) => dispatch (vfbCircuitBrowser(type, path, visible)),
instanceAdded: instance => dispatch(instanceAdded(instance)),
instanceSelected : instance => dispatch(instanceSelected(instance)),
instanceDeleted : (type, instanceID) => dispatch(instanceDeleted(type, instanceID)),
instanceVisibilityChanged : instance => dispatch(instanceVisibilityChanged(instance)),
setTermInfo: (instance, visible) => dispatch (setTermInfo(instance, visible))
});
Expand Down
10 changes: 7 additions & 3 deletions reducers/generals.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,13 @@ function generalReducer (state, action) {
}
case INSTANCE_DELETED:
var newMap = [ ...state.idsList ];
var index = newMap.indexOf(action.instance.id);
if ( index > -1 ) {
newMap.splice(index, 1);
var id = action.data;
// Delete all matching instances, e.g. instances of same name endign in obj, meta, swc
for ( var i = 0; i < newMap.length; i++ ){
if ( newMap[i].includes(id) ) {
newMap.splice(i, 1);
i--;
}
}
ui.canvas.instanceDeleted = action.instance;
return {
Expand Down