Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed npm adapter installation #2427

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
56 changes: 34 additions & 22 deletions packages/admin/src/src/tabs/Adapters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -879,33 +879,45 @@
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<unknown>}
*/
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',
});
Comment on lines +902 to +907

Check warning

Code scanning / CodeQL

Potentially inconsistent state update Warning

Component state update uses
potentially inconsistent value
.
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) => {
Expand Down
Loading