mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(core-connections): CB-564 new connections sorting
This commit is contained in:
+6
-2
@@ -28,14 +28,18 @@ export class ConnectionsAdministrationController {
|
||||
const isBNew = this.connectionsResource.isNew(b.id);
|
||||
|
||||
if (isANew === isBNew) {
|
||||
return 0;
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
if (isBNew) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
if (isANew) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { action } from 'mobx';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
@@ -93,8 +94,11 @@ export class ConnectionsResource extends CachedMapResource<string, AdminConnecti
|
||||
return this.add(connection, true);
|
||||
}
|
||||
|
||||
async add(connection: AdminConnection, isNew = false): Promise<AdminConnection> {
|
||||
@action add(connection: AdminConnection, isNew = false): AdminConnection {
|
||||
this.changed = true;
|
||||
|
||||
this.cleanNewFlags();
|
||||
|
||||
const newConnection: ConnectionNew = {
|
||||
...connection,
|
||||
[NEW_CONNECTION_SYMBOL]: isNew,
|
||||
@@ -163,6 +167,12 @@ export class ConnectionsResource extends CachedMapResource<string, AdminConnecti
|
||||
return this.data;
|
||||
}
|
||||
|
||||
private cleanNewFlags() {
|
||||
for (const connection of this.data.values()) {
|
||||
(connection as ConnectionNew)[NEW_CONNECTION_SYMBOL] = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async deleteConnectionTask(key: ResourceKey<string>) {
|
||||
await ResourceKeyUtils.forEachAsync(key, key => this.deleteConnection(key));
|
||||
await this.onItemDelete.execute(key);
|
||||
|
||||
Reference in New Issue
Block a user