-
-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
220 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,39 @@ | ||
/** | ||
* @typedef {Object} AdHocCommand | ||
* @property {string} action | ||
* @property {string} node | ||
* @property {string} sessionid | ||
* @property {string} status | ||
*/ | ||
/** | ||
* @param {Element} stanza | ||
* @returns {AdHocCommand[]} | ||
*/ | ||
export function parseForCommands(stanza: Element): AdHocCommand[]; | ||
/** | ||
* @typedef {Object} AdHocCommandFields | ||
* @property {string} sessionid | ||
* @property {string} [instructions] | ||
* @property {TemplateResult[]} [fields] | ||
* @property {string[]} [actions] | ||
*/ | ||
export function parseForCommands(stanza: Element): any; | ||
/** | ||
* @param {Element} iq | ||
* @param {string} [jid] | ||
* @returns {AdHocCommandFields} | ||
*/ | ||
export function getCommandFields(iq: Element, jid?: string): { | ||
sessionid: any; | ||
instructions: any; | ||
fields: any; | ||
actions: any[]; | ||
export function getCommandFields(iq: Element, jid?: string): AdHocCommandFields; | ||
export type AdHocCommand = { | ||
action: string; | ||
node: string; | ||
sessionid: string; | ||
status: string; | ||
}; | ||
export type AdHocCommandFields = { | ||
sessionid: string; | ||
instructions?: string; | ||
fields?: TemplateResult[]; | ||
actions?: string[]; | ||
}; | ||
export type TemplateResult = import('lit').TemplateResult; | ||
//# sourceMappingURL=utils.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,58 @@ | ||
/** | ||
* @typedef {import('../adhoc-commands').default} AdHocCommands | ||
* @typedef {import('../adhoc-commands').AdHocCommandUIProps} AdHocCommandUIProps | ||
*/ | ||
import { html } from 'lit'; | ||
import { __ } from 'i18n'; | ||
import { html } from "lit"; | ||
|
||
|
||
const action_map = { | ||
execute: __('Execute'), | ||
prev: __('Previous'), | ||
next: __('Next'), | ||
complete: __('Complete'), | ||
} | ||
}; | ||
|
||
/** | ||
* @param {AdHocCommands} el | ||
* @param {AdHocCommandUIProps} command | ||
*/ | ||
export default (el, command) => { | ||
const i18n_cancel = __('Cancel'); | ||
|
||
return html` | ||
<span> <!-- Don't remove this <span>, | ||
this is a workaround for a lit bug where a <form> cannot be removed | ||
if it contains an <input> with name "remove" --> | ||
<span> | ||
<!-- Don't remove this <span>, | ||
this is a workaround for a lit bug where a <form> cannot be removed | ||
if it contains an <input> with name "remove" --> | ||
<form> | ||
${ command.alert ? html`<div class="alert alert-${command.alert_type}" role="alert">${command.alert}</div>` : '' } | ||
<fieldset class="form-group"> | ||
<input type="hidden" name="command_node" value="${command.node}"/> | ||
<input type="hidden" name="command_jid" value="${command.jid}"/> | ||
${command.alert | ||
? html`<div class="alert alert-${command.alert_type}" role="alert">${command.alert}</div>` | ||
: ''} | ||
<fieldset class="form-group"> | ||
<input type="hidden" name="command_node" value="${command.node}" /> | ||
<input type="hidden" name="command_jid" value="${command.jid}" /> | ||
<p class="form-instructions">${command.instructions}</p> | ||
${ command.fields } | ||
</fieldset> | ||
<fieldset> | ||
${ command.actions.map((action) => | ||
html`<input data-action="${action}" | ||
@click=${(ev) => el.executeAction(ev)} | ||
<p class="form-instructions">${command.instructions}</p> | ||
${command.fields ?? []} | ||
</fieldset> | ||
<fieldset> | ||
${command.actions?.map( | ||
(action) => | ||
html`<input | ||
data-action="${action}" | ||
@click=${(ev) => el.executeAction(ev)} | ||
type="button" | ||
class="btn btn-primary" | ||
value="${action_map[action]}" | ||
/>` | ||
)}<input | ||
type="button" | ||
class="btn btn-primary" | ||
value="${action_map[action]}">`) | ||
}<input type="button" | ||
class="btn btn-secondary button-cancel" | ||
value="${i18n_cancel}" | ||
@click=${(ev) => el.cancel(ev)}> | ||
</fieldset> | ||
</form> | ||
class="btn btn-secondary button-cancel" | ||
value="${i18n_cancel}" | ||
@click=${(ev) => el.cancel(ev)} | ||
/> | ||
</fieldset> | ||
</form> | ||
</span> | ||
`; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.