mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-10-22 12:31:26 +00:00
Pass the id of the server to remove to event listeners (#855)
* Pass the id of the server to be removed from the manager to the event listener * Correctly reset appRoot state after destroying a server * Rename to forgetServer * Remove stray logging * Apply suggestions from code review Co-authored-by: Vinicius Fortuna <fortuna@users.noreply.github.com> * Further suggested changes Co-authored-by: Vinicius Fortuna <fortuna@users.noreply.github.com>
This commit is contained in:
parent
766c22c9f6
commit
8fdd8d7273
2 changed files with 8 additions and 14 deletions
|
|
@ -162,11 +162,11 @@ export class App {
|
|||
});
|
||||
|
||||
appRoot.addEventListener('DeleteServerRequested', (event: CustomEvent) => {
|
||||
this.deleteSelectedServer();
|
||||
this.deleteServer(event.detail.serverId);
|
||||
});
|
||||
|
||||
appRoot.addEventListener('ForgetServerRequested', (event: CustomEvent) => {
|
||||
this.forgetSelectedServer();
|
||||
this.forgetServer(event.detail.serverId);
|
||||
});
|
||||
|
||||
appRoot.addEventListener('AddAccessKeyRequested', (event: CustomEvent) => {
|
||||
|
|
@ -1072,9 +1072,8 @@ export class App {
|
|||
});
|
||||
}
|
||||
|
||||
private deleteSelectedServer() {
|
||||
const serverToDelete = this.selectedServer;
|
||||
const serverId = serverToDelete.getId();
|
||||
private deleteServer(serverId: string) {
|
||||
const serverToDelete = this.getServerById(serverId);
|
||||
if (!isManagedServer(serverToDelete)) {
|
||||
const msg = 'cannot delete non-ManagedServer';
|
||||
console.error(msg);
|
||||
|
|
@ -1091,8 +1090,6 @@ export class App {
|
|||
.then(
|
||||
() => {
|
||||
this.removeServer(serverId);
|
||||
this.appRoot.selectedServer = null;
|
||||
this.selectedServer = null;
|
||||
this.showIntro();
|
||||
this.appRoot.showNotification(
|
||||
this.appRoot.localize('notification-server-destroyed'));
|
||||
|
|
@ -1107,9 +1104,8 @@ export class App {
|
|||
});
|
||||
}
|
||||
|
||||
private forgetSelectedServer() {
|
||||
const serverToForget = this.selectedServer;
|
||||
const serverId = serverToForget.getId();
|
||||
private forgetServer(serverId: string) {
|
||||
const serverToForget = this.getServerById(serverId);
|
||||
if (!isManualServer(serverToForget)) {
|
||||
const msg = 'cannot forget non-ManualServer';
|
||||
console.error(msg);
|
||||
|
|
@ -1122,8 +1118,6 @@ export class App {
|
|||
this.appRoot.getConfirmation(confirmationTitle, confirmationText, confirmationButton, () => {
|
||||
serverToForget.forget();
|
||||
this.removeServer(serverId);
|
||||
this.appRoot.selectedServerId = '';
|
||||
this.selectedServer = null;
|
||||
this.showIntro();
|
||||
this.appRoot.showNotification(this.appRoot.localize('notification-server-removed'));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1043,11 +1043,11 @@ export class ServerView extends DirMixin(PolymerElement) {
|
|||
}
|
||||
|
||||
destroyServer() {
|
||||
this.dispatchEvent(makePublicEvent('DeleteServerRequested'));
|
||||
this.dispatchEvent(makePublicEvent('DeleteServerRequested', {serverId: this.serverId}));
|
||||
}
|
||||
|
||||
removeServer() {
|
||||
this.dispatchEvent(makePublicEvent('ForgetServerRequested'));
|
||||
this.dispatchEvent(makePublicEvent('ForgetServerRequested', {serverId: this.serverId}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue