Add AppsForm and Interactive Dialogs (#6142)

* Add AppsForm and Interactive Dialogs

* Add the missing plumbing for Interactive Dialogs and minor fixes

* Remove widgets subfolder

* Fix paths

* Address feedback

* Address feedback

* i18n extract

* Only set the dialog if we are in the same server
This commit is contained in:
Daniel Espino García
2022-04-28 18:26:21 +02:00
committed by GitHub
parent a2fac160ef
commit e047106bac
44 changed files with 3258 additions and 559 deletions

View File

@@ -2,6 +2,8 @@
// See LICENSE.txt for license information.
import {fetchCommands} from '@actions/remote/command';
import {INTERACTIVE_DIALOG} from '@constants/screens';
import {showModal} from '@screens/navigation';
const TIME_TO_REFETCH_COMMANDS = 60000; // 1 minute
class ServerIntegrationsManager {
@@ -10,6 +12,7 @@ class ServerIntegrationsManager {
private commands: {[teamId: string]: Command[] | undefined} = {};
private triggerId = '';
private storedDialog?: InteractiveDialogConfig;
private bindings: AppBinding[] = [];
private rhsBindings: AppBinding[] = [];
@@ -64,11 +67,26 @@ class ServerIntegrationsManager {
this.commandForms[key] = form;
}
public getTriggerId() {
return this.triggerId;
}
public setTriggerId(id: string) {
this.triggerId = id;
if (this.storedDialog?.trigger_id === id) {
this.showDialog();
}
}
public setDialog(dialog: InteractiveDialogConfig) {
this.storedDialog = dialog;
if (this.triggerId === dialog.trigger_id) {
this.showDialog();
}
}
private showDialog() {
const config = this.storedDialog;
if (!config) {
return;
}
showModal(INTERACTIVE_DIALOG, config.dialog.title, {config});
}
}