diff --git a/CHANGES.rst b/CHANGES.rst
index a9564160cc..b0c1701727 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -338,6 +338,9 @@ New Features
- Support for Scatter plots/markers in plot options. [#2193]
+- Allow user-loaded data to be removed from the app (in specviz and imviz)
+ so long as it is not the only user-loaded data [#2211]
+
Cubeviz
^^^^^^^
diff --git a/jdaviz/app.py b/jdaviz/app.py
index 27cd360670..324befb3a4 100644
--- a/jdaviz/app.py
+++ b/jdaviz/app.py
@@ -1968,6 +1968,10 @@ def set_data_visibility(self, viewer_reference, data_label, visible=True, replac
viewer.on_limits_change() # Trigger compass redraw
def vue_data_item_remove(self, event):
+ # Hack for disappearing subsets. Temporarily add the data back to the viewer to
+ # transfer ownership of subsets
+ self.add_data_to_viewer(event['viewer_id'], event['item_name'])
+
self.data_collection.remove(self.data_collection[event['item_name']])
def vue_close_snackbar_message(self, event):
diff --git a/jdaviz/components/tooltip.vue b/jdaviz/components/tooltip.vue
index e31cb349d4..0a71d9802e 100644
--- a/jdaviz/components/tooltip.vue
+++ b/jdaviz/components/tooltip.vue
@@ -66,7 +66,7 @@ const tooltips = {
'viewer-data-radio': 'Switch visibility to layers associated with this data entry',
'viewer-data-enable': 'Load data entry into this viewer',
'viewer-data-disable': 'Disable data within this viewer (will be hidden and unavailable from plugins until re-enabled)',
- 'viewer-data-delete': 'Remove data entry across entire app',
+ 'viewer-data-delete': 'Remove data entry across entire app (might affect existing subsets)',
'table-prev': 'Select previous row in table',
'table-next': 'Select next row in table',
diff --git a/jdaviz/components/viewer_data_select.vue b/jdaviz/components/viewer_data_select.vue
index 7a93b0c41a..654f590584 100644
--- a/jdaviz/components/viewer_data_select.vue
+++ b/jdaviz/components/viewer_data_select.vue
@@ -50,6 +50,7 @@
:icon="layer_icons[item.name]"
:viewer="viewer"
:multi_select="multi_select"
+ :n_data_entries="nDataEntries"
@data-item-visibility="$emit('data-item-visibility', $event)"
@data-item-unload="$emit('data-item-unload', $event)"
@data-item-remove="$emit('data-item-remove', $event)"
@@ -79,6 +80,7 @@
:icon="layer_icons[item.name]"
:viewer="viewer"
:multi_select="multi_select"
+ :n_data_entries="nDataEntries"
@data-item-visibility="$emit('data-item-visibility', $event)"
@data-item-remove="$emit('data-item-remove', $event)"
>
@@ -216,6 +218,10 @@ module.exports = {
extraDataItems() {
return this.$props.data_items.filter((item) => this.itemIsVisible(item, true))
},
+ nDataEntries() {
+ // return number of data entries in the entire plugin that were NOT created by a plugin
+ return this.$props.data_items.filter((item) => item.meta.Plugin === undefined).length
+ },
}
};
diff --git a/jdaviz/components/viewer_data_select_item.vue b/jdaviz/components/viewer_data_select_item.vue
index f0f74e170d..ac4e2e85f8 100644
--- a/jdaviz/components/viewer_data_select_item.vue
+++ b/jdaviz/components/viewer_data_select_item.vue
@@ -50,7 +50,7 @@
mdi-delete
@@ -60,7 +60,7 @@