Skip to content

Commit

Permalink
Bugfix/fix v2 bug (#843)
Browse files Browse the repository at this point in the history
* fix,inspector request miss data

* fix v2 bug
  • Loading branch information
echoyang7 authored Apr 24, 2024
1 parent 19e2d71 commit ae49c0f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/DocumentTreeDialogDelete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default {
} else {
for (const item of this.deleteItem) {
this.groupListToDelete.push(item.id)
if (!item.type === 'group') {
if (item.type !== 'group') {
this.dataListToDelete.push(item.id)
}
}
Expand All @@ -173,6 +173,8 @@ export default {
}
this.$store.dispatch('deleteByQuery', payload)
this.$store.commit('setIsSelectableStatus', false)
this.dataListToDelete = []
this.groupListToDelete = []
}
this.isShown = false
},
Expand Down
31 changes: 25 additions & 6 deletions lyrebird/mock/dm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self):

self.add_group_ignore_keys = set(['id', 'type', 'children'])
self.update_group_ignore_keys = set(['id', 'parent_id', 'type', 'children'])
self.supported_data_type = ['data', 'json', 'config']
self.supported_data_type = self.get_supported_data_type()
self.virtual_node_data_type = set(['config']) # TODO Next is `super``

self.virtual_base_config_id = None
Expand Down Expand Up @@ -69,6 +69,12 @@ def snapshot_workspace(self):
def snapshot_workspace(self, workspace):
self._snapshot_workspace = workspace

def get_supported_data_type(self):
supported_data_type = ['data', 'json']
if application.config.get(CONFIG_TREE_SHOW_CONFIG):
supported_data_type.append('config')
return supported_data_type

def get_default_root(self):
return {
'id': str(uuid.uuid4()),
Expand Down Expand Up @@ -1202,7 +1208,9 @@ def _delete_remove_from_parent(self, id_):

# batch action
def delete_by_query(self, query):
all_id_list = query.get('id') or []
node_delete_group_ids = query.get('data', [])
node_delete_data_ids = query.get('groups', [])
all_id_list = list(set(node_delete_group_ids + node_delete_data_ids))

times = math.ceil(len(all_id_list) / self.DELETE_STEP)
for index in range(times):
Expand All @@ -1215,9 +1223,6 @@ def delete_by_query(self, query):
'state': 'process'
})

type_map = self._get_type_hashmap(id_list)
node_delete_group_ids = type_map['group'] + type_map['data'] + type_map['json'] + type_map['config']
node_delete_data_ids = type_map['data'] + type_map['json'] + type_map['config']

for id_ in id_list:
# Delete from parent
Expand Down Expand Up @@ -1289,9 +1294,23 @@ def reset(self):

def _get_group_children(self, group_id):
result = self._adapter._get_group_children(group_id)
self.handle_group_config(result, group_id)
self.add_open_node(group_id)
return result


def handle_group_config(self, node_list, node_id):
has_config_index = -1
for index, node in enumerate(node_list):
if node['type'] == 'config':
has_config_index = index
break

is_show_config = application.config.get(CONFIG_TREE_SHOW_CONFIG)
has_config = has_config_index != -1
if has_config and not is_show_config:
del node_list[has_config_index]
return

def get_group(self, _id):
return self._adapter._load_group(_id)

Expand Down
6 changes: 1 addition & 5 deletions lyrebird/mock/dm/file_data_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,7 @@ def _activate(self, search_id):
for node in node_list:
node_in_map = self.context.id_map.get(node.get('id'))
if node_in_map['type'] == 'config':
try:
config = json.loads(node['json'])
break
except Exception:
logger.error(f'Load config {node["id"]} error! \n {traceback.format_exc()}')
config = node
return {
'config': config,
'flows': node_list,
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (2, 26, 1)
IVERSION = (2, 26, 2)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION
2 changes: 1 addition & 1 deletion tests/test_dm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def data_manager(root, tmpdir):
application._cm = ConfigManager()
lyrebird.mock.context.application.socket_io = FakeSocketio()
application.encoders_decoders = EncoderDecoder()
_dm = dm.DataManager()
_dm = dm.DataManagerV2()
_dm.snapshot_workspace = tmpdir
_dm.set_adapter(data_adapter)
_dm.set_root(root)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from .utils import FakeEvnetServer
from .utils import FakeEvnetServer, FakeBackgroundTaskServer
from lyrebird.mock.mock_server import LyrebirdMockServer
from lyrebird import application
from lyrebird.plugins import PluginManager
Expand Down Expand Up @@ -119,6 +119,7 @@ def mock_server():
application._cm = ConfigManager()
application._cm.config = copy.deepcopy(conf)
server = LyrebirdMockServer()
application.server['task'] = FakeBackgroundTaskServer()
application.server['mock'] = server
yield server
del server
Expand Down

0 comments on commit ae49c0f

Please sign in to comment.