From 31d61d49b5a00dfb6a0a4c1e3291c16fc57859d8 Mon Sep 17 00:00:00 2001 From: foxriver76 Date: Thu, 11 Apr 2024 14:04:56 +0200 Subject: [PATCH] fixed npm adapter installation --- README.md | 3 ++ packages/admin/src/src/App.jsx | 4 +- packages/admin/src/src/tabs/Adapters.jsx | 56 ++++++++++++++---------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 4aad049f0..8f87b29da 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,9 @@ The icons may not be reused in other projects without the proper flaticon licens ### **WORK IN PROGRESS** --> ## Changelog +### **WORK IN PROGRESS** +* (foxriver76) fixed npm adapter installation + ### 6.17.2 (2024-04-08) * (foxriver76) avoid crash case if user has no permission to write objects diff --git a/packages/admin/src/src/App.jsx b/packages/admin/src/src/App.jsx index 89922075f..3560ba9c1 100644 --- a/packages/admin/src/src/App.jsx +++ b/packages/admin/src/src/App.jsx @@ -1263,8 +1263,8 @@ class App extends Router { break; } } catch (error) { - console.error(error); - this.showAlert(error, 'error'); + console.error(`Cannot find news instance: ${error}`); + this.showAlert(`Cannot find news instance: ${error}`, 'error'); } } resolve(0); diff --git a/packages/admin/src/src/tabs/Adapters.jsx b/packages/admin/src/src/tabs/Adapters.jsx index bb969b9d5..d99fffec6 100644 --- a/packages/admin/src/src/tabs/Adapters.jsx +++ b/packages/admin/src/src/tabs/Adapters.jsx @@ -879,33 +879,45 @@ class Adapters extends Component { return Promise.resolve(); }; + /** + * + * @param adapter name like admin or if customUrl is true packetName or iobroker.admin@latest or url + * @param instance + * @param debug + * @param customUrl + * @return {Promise} + */ async addInstance(adapter, instance, debug = false, customUrl = false) { - const adapterObject = this.state.repository[adapter]; - - const messages = checkCondition( - adapterObject.messages, - null, - adapterObject.version, - this.state.instances, - ); + if (!customUrl) { + const adapterObject = this.state.repository[adapter]; + + const messages = checkCondition( + adapterObject.messages, + null, + adapterObject.version, + this.state.instances, + ); - if (!instance && (this.props.expertMode || messages) && !customUrl) { - this.setState({ - addInstanceDialog: true, - addInstanceAdapter: adapter, - addInstanceHostName: this.state.currentHost.replace(/^system\.host\./, ''), - addInstanceId: instance || 'auto', - }); - return null; - } - if (instance && !customUrl) { - const instances = this.props.instancesWorker.getInstances(); - // if the instance already exists - if (instances[`system.adapter.${adapter}.${instance}`]) { - window.alert(this.props.t('Instance %s already exists', `${adapter}.${instance}`)); + if (!instance && (this.props.expertMode || messages)) { + this.setState({ + addInstanceDialog: true, + addInstanceAdapter: adapter, + addInstanceHostName: this.state.currentHost.replace(/^system\.host\./, ''), + addInstanceId: instance || 'auto', + }); return null; } + + if (instance) { + const instances = this.props.instancesWorker.getInstances(); + // if the instance already exists + if (instances[`system.adapter.${adapter}.${instance}`]) { + window.alert(this.props.t('Instance %s already exists', `${adapter}.${instance}`)); + return null; + } + } } + const host = (this.state.addInstanceHostName || this.state.currentHost).replace(/^system\.host\./, ''); return new Promise((resolve, reject) => {