ioBroker.admin icon indicating copy to clipboard operation
ioBroker.admin copied to clipboard

Add option to create instance if not already exist from git/npm/URL

Open Copilot opened this issue 5 months ago • 2 comments

This enhancement adds a user-facing checkbox option "Create instance if not already exist" to the GitHubInstallDialog, allowing users to automatically create an adapter instance after installing from Git, npm, or custom URLs only when no instances already exist.

Background

Previously, when users installed adapters via Git/npm/URL, the adapter would be installed but no instance would be created automatically. Users had to manually navigate to the Adapters tab and click the "+" button to create an instance, which was an additional step that many users expected to happen automatically.

Solution

Added a checkbox control to all three installation tabs (GitHub, npm, URL) in the GitHubInstallDialog that intelligently determines when to create instances. When checked, the system will:

  1. Install the adapter as normal
  2. Automatically create an instance only if no instances already exist
  3. Skip instance creation for adapter updates where instances exist
  4. Bypass the instance creation dialog for a streamlined experience

Key Features

  • Smart Default Behavior: Checkbox defaults to checked only when no instances exist for the selected adapter
  • Update-Friendly: Accounts for scenarios where users are updating existing adapters
  • Dynamic Updates: Checkbox state automatically updates when users select different adapters
  • Persistent Preference: User choices are saved in localStorage for convenience
  • All Installation Types: Works with GitHub, npm, and custom URL installations
  • Backward Compatible: Existing behavior unchanged when checkbox is unchecked
  • Internationalized: Includes translations for English and German

Technical Implementation

  • Modified GitHubInstallDialog.tsx to add checkbox UI, state management, and instance checking logic
  • Added hasExistingInstances() method to check adapter instance count from installed adapters
  • Added updateCreateInstanceForAdapter() to dynamically update checkbox state on adapter selection
  • Updated AdapterInstallDialog.tsx addInstance method to respect the createInstance parameter
  • Enhanced installation flow in Adapters.tsx to pass the option through
  • Updated translations from "Create instance after installation" to "Create instance if not already exist"

The implementation follows the suggestion from @Apollon77 to handle this through a dialog option rather than requiring js-controller changes, with enhanced logic based on feedback from @GermanBluefox.

Testing

  • All builds pass successfully
  • Linting passes without errors
  • Code follows existing style guidelines and patterns
  • No breaking changes to existing functionality
  • Development server validates UI changes work correctly

This addresses the user need expressed in the issue: "I as user want to have an instance of newly installed adapter via git/npm automatically" while intelligently handling both new installations and adapter updates.

Admin Interface

Addressing #2693.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Sep 09 '25 03:09 Copilot

@copilot The option must be "Create instance if not already exist" and it must be checked before installation if not any instance already exist as the user could just make an update of the existing adapter

GermanBluefox avatar Sep 12 '25 12:09 GermanBluefox

@copilot The option must be "Create instance if not already exist" and it must be checked before installation if not any instance already exist as the user could just make an update of the existing ad...

Updated the implementation as requested in commit c5e4f2e:

  1. ✅ Changed checkbox text to "Create instance if not already exist" (updated both English and German translations)
  2. ✅ Checkbox is now checked by default BEFORE installation only when no instances already exist for the selected adapter
  3. ✅ Added logic to check existing instances using the installed prop and automatically update checkbox state when adapter selection changes
  4. ✅ Properly handles update scenarios where users might just be updating existing adapters

The checkbox now intelligently defaults to checked only when it would be beneficial to create an instance, while preserving user preferences when they explicitly set the checkbox state.

Updated Interface

Copilot avatar Sep 12 '25 13:09 Copilot