Repository: napari/napari

Issue:
Available plugins list also shows installed plugins
## 🐛 Bug

Hi all,

I'm not 100%ly sure if this is a bug or a feature. I'm reporting it and you feel free to close it if this is intentional: The plugins installer shows all plugins in the "Available Plugins" list, also those which are already installed. I think this is new in 0.4.13rc1.

![image](https://user-images.githubusercontent.com/12660498/149632858-a5d75d47-6f06-40a6-82aa-cef07cf8696e.png)


## To Reproduce

Open a napari in a conda environment where some plugins are installed. Click on the menu "Plugins > Install / Uninstall Plugins"

## Expected behavior

Either the installed plugins do not show up in the list of "Available plugins", or the "install" button becomes an "uninstall" button.

## Environment

 - Please copy and paste the information at napari info option in help menubar here:


napari: 0.4.13rc1
Platform: Windows-10-10.0.19042-SP0
Python: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:36:06) [MSC v.1929 64 bit (AMD64)]
Qt: 5.15.2
PyQt5: 5.15.6
NumPy: 1.22.0
SciPy: 1.7.3
Dask: 2021.11.2
VisPy: 0.9.4

OpenGL:
- GL version: 4.6.0 NVIDIA 496.49
- MAX_TEXTURE_SIZE: 32768

Screens:
- screen 1: resolution 1920x1200, scale 1.0

Plugins:
- Measurements (Plot profile): 0.2.0
- PlatyMatch: 0.0.3
- RedLionfish: 0.5
- Search (Plugin): 0.1.2
- Segment (blobs and things with membranes): 0.2.11
- Segmentation (split/merge): 0.1.3
- aicsimageio-in-memory: 0.4.1
- aicsimageio-out-of-memory: 0.4.1
- animation: 0.0.2
- clEsperanto: 0.12.0
- console: 0.0.4
- devbio: 0.1.5
- napari-3d-ortho-viewer: 0.0.1
- napari-accelerated-pixel-and-object-classification: 0.6.0
- napari-brightness-contrast: 0.1.6
- napari-clusters-plotter: 0.2.1
- napari-crop: 0.1.5
- napari-cupy-image-processing: 0.1.9
- napari-curtain: 0.1.1
- napari-dexp: 0.0.4
- napari-folder-browser: 0.1.2
- napari-itk-io: 0.1.0
- napari-labels-overlap: 0.0.1
- napari-layer-details-display: 0.1.1
- napari-ome-zarr: 0.3.1
- napari-script-editor: 0.2.7
- napari-simpleitk-image-processing: 0.2.0
- napari-tabu: 0.1.5
- napari-time-slicer: 0.4.0
- napari-tools-menu: 0.1.9
- napari-workflow-optimizer: 0.1.3
- napari_skimage_regionprops1: 0.2.9
- napari_skimage_regionprops2: 0.2.9
- ome-types: 0.2.9
- scikit-image: 0.4.13rc1
- svg: 0.1.5



Discussion:
i noticed this too recently... seems odd to me.  would be nice to fix

> On Jan 15, 2022, at 1:11 PM, Robert Haase ***@***.***> wrote:
> 
> 
> 🐛 Bug
> 
> Hi all,
> 
> I'm not 100%ly sure if this is a bug or a feature. I'm reporting it and you feel free to close it if this is intentional: The plugins installer shows all plugins in the "Available Plugins" list, also those which are already installed. I think this is new in 0.4.13rc1.
> 
>  <https://user-images.githubusercontent.com/12660498/149632858-a5d75d47-6f06-40a6-82aa-cef07cf8696e.png>
> To Reproduce
> 
> Open a napari in a conda environment where some plugins are installed. Click on the menu "Plugins > Install / Uninstall Plugins"
> 
> Expected behavior
> 
> Either the installed plugins do not show up in the list of "Available plugins", or the "install" button becomes an "uninstall" button.
> 
> Environment
> 
> Please copy and paste the information at napari info option in help menubar here:
> napari: 0.4.13rc1
> Platform: Windows-10-10.0.19042-SP0
> Python: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:36:06) [MSC v.1929 64 bit (AMD64)]
> Qt: 5.15.2
> PyQt5: 5.15.6
> NumPy: 1.22.0
> SciPy: 1.7.3
> Dask: 2021.11.2
> VisPy: 0.9.4
> 
> OpenGL:
> 
> GL version: 4.6.0 NVIDIA 496.49
> MAX_TEXTURE_SIZE: 32768
> Screens:
> 
> screen 1: resolution 1920x1200, scale 1.0
> Plugins:
> 
> Measurements (Plot profile): 0.2.0
> PlatyMatch: 0.0.3
> RedLionfish: 0.5
> Search (Plugin): 0.1.2
> Segment (blobs and things with membranes): 0.2.11
> Segmentation (split/merge): 0.1.3
> aicsimageio-in-memory: 0.4.1
> aicsimageio-out-of-memory: 0.4.1
> animation: 0.0.2
> clEsperanto: 0.12.0
> console: 0.0.4
> devbio: 0.1.5
> napari-3d-ortho-viewer: 0.0.1
> napari-accelerated-pixel-and-object-classification: 0.6.0
> napari-brightness-contrast: 0.1.6
> napari-clusters-plotter: 0.2.1
> napari-crop: 0.1.5
> napari-cupy-image-processing: 0.1.9
> napari-curtain: 0.1.1
> napari-dexp: 0.0.4
> napari-folder-browser: 0.1.2
> napari-itk-io: 0.1.0
> napari-labels-overlap: 0.0.1
> napari-layer-details-display: 0.1.1
> napari-ome-zarr: 0.3.1
> napari-script-editor: 0.2.7
> napari-simpleitk-image-processing: 0.2.0
> napari-tabu: 0.1.5
> napari-time-slicer: 0.4.0
> napari-tools-menu: 0.1.9
> napari-workflow-optimizer: 0.1.3
> napari_skimage_regionprops1: 0.2.9
> napari_skimage_regionprops2: 0.2.9
> ome-types: 0.2.9
> scikit-image: 0.4.13rc1
> svg: 0.1.5
> —
> Reply to this email directly, view it on GitHub <https://github.com/napari/napari/issues/3942>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAMI52LZOMSXNPO6RG6NWK3UWG2DJANCNFSM5MBIDLQQ>.
> You are receiving this because you are subscribed to this thread.
> 


Let me try...

Resolving patch:
diff --git a/napari/_qt/dialogs/qt_plugin_dialog.py b/napari/_qt/dialogs/qt_plugin_dialog.py
--- a/napari/_qt/dialogs/qt_plugin_dialog.py
+++ b/napari/_qt/dialogs/qt_plugin_dialog.py
@@ -643,16 +643,15 @@ def refresh(self):
 
         plugin_manager.discover()  # since they might not be loaded yet
 
-        already_installed = set()
+        self.already_installed = set()
 
         def _add_to_installed(distname, enabled, npe_version=1):
-
             if distname:
                 meta = standard_metadata(distname)
                 if len(meta) == 0:
                     # will not add builtins.
                     return
-                already_installed.add(distname)
+                self.already_installed.add(distname)
             else:
                 meta = {}
 
@@ -672,7 +671,7 @@ def _add_to_installed(distname, enabled, npe_version=1):
 
         for manifest in _npe2.iter_manifests():
             distname = normalized_name(manifest.name or '')
-            if distname in already_installed or distname == 'napari':
+            if distname in self.already_installed or distname == 'napari':
                 continue
             _add_to_installed(distname, True, npe_version=2)
 
@@ -680,7 +679,7 @@ def _add_to_installed(distname, enabled, npe_version=1):
             # not showing these in the plugin dialog
             if plugin_name in ('napari_plugin_engine',):
                 continue
-            if distname in already_installed:
+            if distname in self.already_installed:
                 continue
             _add_to_installed(
                 distname, not plugin_manager.is_blocked(plugin_name)


Test patch: