Skip to content

Commit

Permalink
Display body as note on open ticket action
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 7, 2024
1 parent 263a378 commit cf4dc37
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@import 'variables.module.scss';

.subject {
margin-top: 8px;
}

.body {
.note {
margin-top: 8px;
}
35 changes: 12 additions & 23 deletions src/components/flow/routers/ticket/TicketRouterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import { Topic, User } from 'flowTypes';
export interface TicketRouterFormState extends FormState {
assignee: FormEntry;
topic: FormEntry;
subject: StringEntry;
body: StringEntry;
note: StringEntry;
resultName: StringEntry;
}

Expand All @@ -50,8 +49,7 @@ export default class TicketRouterForm extends React.Component<
keys: {
assignee?: User;
topic?: Topic;
subject?: string;
body?: string;
note?: string;
resultName?: string;
},
submitting = false
Expand All @@ -70,12 +68,8 @@ export default class TicketRouterForm extends React.Component<
]);
}

if (keys.hasOwnProperty('subject')) {
updates.subject = validate(i18n.t('forms.subject', 'Subject'), keys.subject, []);
}

if (keys.hasOwnProperty('body')) {
updates.body = validate(i18n.t('forms.body', 'Body'), keys.body, []);
if (keys.hasOwnProperty('note')) {
updates.note = validate(i18n.t('forms.note', 'Note'), keys.note, []);
}

if (keys.hasOwnProperty('resultName')) {
Expand All @@ -99,12 +93,8 @@ export default class TicketRouterForm extends React.Component<
this.handleUpdate({ topic });
}

private handleSubjectUpdate(subject: string, name: string, submitting = false): boolean {
return this.handleUpdate({ subject }, submitting);
}

private handleBodyUpdate(body: string): boolean {
return this.handleUpdate({ body });
private handleNoteUpdate(note: string): boolean {
return this.handleUpdate({ note });

Check warning on line 97 in src/components/flow/routers/ticket/TicketRouterForm.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/flow/routers/ticket/TicketRouterForm.tsx#L97

Added line #L97 was not covered by tests
}

private handleResultNameUpdate(value: string): void {
Expand All @@ -123,8 +113,7 @@ export default class TicketRouterForm extends React.Component<
// validate all fields in case they haven't interacted
const valid = this.handleUpdate(
{
subject: this.state.subject.value,
body: this.state.body.value,
note: this.state.note.value,
resultName: this.state.resultName.value
},
true
Expand Down Expand Up @@ -185,12 +174,12 @@ export default class TicketRouterForm extends React.Component<
/>
</div>
</div>
<div className={styles.body}>
<div className={styles.note}>
<TextInputElement
name={i18n.t('forms.body', 'Body')}
placeholder={i18n.t('forms.enter_a_body', 'Enter a body (optional)')}
entry={this.state.body}
onChange={this.handleBodyUpdate}
name={i18n.t('forms.note', 'Note')}
placeholder={i18n.t('forms.enter_a_note', 'Enter a note (optional)')}
entry={this.state.note}
onChange={this.handleNoteUpdate}
autocomplete={true}
textarea={true}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ exports[`TicketRouterForm render should render 1`] = `
</div>
</div>
<div
class="body"
class="note"
>
<div
class="ele"
Expand All @@ -105,9 +105,9 @@ exports[`TicketRouterForm render should render 1`] = `
class="wrapper normal"
>
<input
data-testid="Body"
name="Body"
placeholder="Enter a body (optional)"
data-testid="Note"
name="Note"
placeholder="Enter a note (optional)"
value="Where are my cookies"
/>
</div>
Expand Down Expand Up @@ -275,7 +275,7 @@ exports[`TicketRouterForm updates should save changes 1`] = `
</div>
</div>
<div
class="body"
class="note"
>
<div
class="ele"
Expand All @@ -284,9 +284,9 @@ exports[`TicketRouterForm updates should save changes 1`] = `
class="wrapper normal"
>
<input
data-testid="Body"
name="Body"
placeholder="Enter a body (optional)"
data-testid="Note"
name="Note"
placeholder="Enter a note (optional)"
value="Where are my cookies"
/>
</div>
Expand Down
11 changes: 4 additions & 7 deletions src/components/flow/routers/ticket/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ export const getOriginalAction = (settings: NodeEditorSettings): OpenTicket => {
};

export const nodeToState = (settings: NodeEditorSettings): TicketRouterFormState => {
let subject = { value: '@run.flow.name' };
let body = { value: '' };
let note = { value: '' };
let resultName = { value: 'Result' };
let assignee: FormEntry = { value: null };
let topic: FormEntry = { value: null };

if (getType(settings.originalNode) === Types.split_by_ticket) {
const action = getOriginalAction(settings) as OpenTicket;
subject = { value: action.subject };
body = { value: action.body };
note = { value: action.body };
topic = { value: action.topic };
assignee = { value: action.assignee };
resultName = { value: action.result_name };
Expand All @@ -36,8 +34,7 @@ export const nodeToState = (settings: NodeEditorSettings): TicketRouterFormState
const state: TicketRouterFormState = {
assignee,
topic,
subject,
body,
note,
resultName,
valid: true
};
Expand All @@ -58,7 +55,7 @@ export const stateToNode = (
const newAction: OpenTicket = {
uuid,
type: Types.open_ticket,
body: state.body.value,
body: state.note.value,
topic: state.topic.value,
assignee: state.assignee.value,
result_name: state.resultName.value
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/cs/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"email_recipient_name": "Příjemce",
"email_recipient_placeholder": "Komu",
"email_recipient_prompt": "Zadejte e-mailovou adresu",
"enter_a_body": "Zadejte obsah zprávy",
"enter_a_note": "Zadejte poznámku (volitelný)",
"enter_a_subject": "Zadejte předmět",
"enter_a_url": "Zadejte URL",
"enter_field_value": "Zadejte novou hodnotu pro [[field]]",
Expand Down Expand Up @@ -250,6 +250,7 @@
"minimum_value": "Minimální hodnota",
"must_be_less_than": "musí být menší než",
"name": "Název",
"note": "Poznámku",
"operand": "Operand",
"operator": "operátor",
"pdf_url": "URL adresa PDF dokumentu",
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"email_recipient_name": "Recipient",
"email_recipient_placeholder": "To",
"email_recipient_prompt": "Enter email address",
"enter_a_body": "Enter a body (optional)",
"enter_a_note": "Enter a note (optional)",
"enter_a_subject": "Enter a subject",
"enter_a_url": "Enter a URL",
"enter_field_value": "Enter a new value for [[field]]",
Expand Down Expand Up @@ -250,6 +250,7 @@
"minimum_value": "Minimum value",
"must_be_less_than": "must be less than",
"name": "Name",
"note": "Note",
"operand": "Operand",
"operator": "operator",
"pdf_url": "PDF Document URL",
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/es/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"email_recipient_name": "Destinatario",
"email_recipient_placeholder": "Para",
"email_recipient_prompt": "Introducir la dirección de correo electrónico",
"enter_a_body": "Introducir cuerpo (opcional)",
"enter_a_note": "Introducir nota (opcional)",
"enter_a_subject": "Introducir asunto",
"enter_a_url": "Introducir URL",
"enter_field_value": "Ingrese un nuevo valor para [[field]]",
Expand Down Expand Up @@ -250,6 +250,7 @@
"minimum_value": "Valor mínimo",
"must_be_less_than": "debe ser menor que",
"name": "Nombre",
"note": "Nota",
"operand": "Operando",
"operator": "operador",
"pdf_url": "URL de Documento PDF",
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/fr/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"email_recipient_name": "Bénéficiaire",
"email_recipient_placeholder": "À",
"email_recipient_prompt": "Entrer l'adresse e-mail",
"enter_a_body": "Entrez un corps",
"enter_a_note": "Entrez une note (facultatif)",
"enter_a_subject": "Entrez un sujet",
"enter_a_url": "Entrez une URL",
"enter_field_value": "Enter a new value for [[field]]",
Expand Down Expand Up @@ -250,6 +250,7 @@
"minimum_value": "Valeur minimum",
"must_be_less_than": "doit être inférieur à",
"name": "Nom",
"note": "Note",
"operand": "Opérande",
"operator": "opérateur",
"pdf_url": "PDF Document URL",
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/mn/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"email_recipient_name": "Хүлээн авагч",
"email_recipient_placeholder": "руу",
"email_recipient_prompt": "Имэйл хаягаа оруулна уу",
"enter_a_body": "Их биеийг оруулна уу",
"enter_a_note": "Тэмдэглэл оруулна уу",
"enter_a_subject": "Сэдвийг оруулна уу",
"enter_a_url": "URL оруулна уу",
"enter_field_value": "[[field]]-д шинэ утга оруулна уу",
Expand Down Expand Up @@ -250,6 +250,7 @@
"minimum_value": "Хамгийн бага утга",
"must_be_less_than": "-аас бага байх ёстой",
"name": "Нэр",
"note": "тэмдэглэл",
"operand": "Операнд",
"operator": "оператор",
"pdf_url": "PDF баримт бичгийн URL",
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/pt-br/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"email_recipient_name": "Destinatário",
"email_recipient_placeholder": "Para",
"email_recipient_prompt": "Insira o endereço de email",
"enter_a_body": "Insira um corpo",
"enter_a_note": "Insira uma nota (opcional)",
"enter_a_subject": "Insira um assunto",
"enter_a_url": "Insira um URL",
"enter_field_value": "Insira um novo valor para [[field]]",
Expand Down Expand Up @@ -250,6 +250,7 @@
"minimum_value": "Valor mínimo",
"must_be_less_than": "deve ser menor que",
"name": "Nome",
"note": "Nota",
"operand": "Operando",
"operator": "operador",
"pdf_url": "PDF Document URL",
Expand Down
1 change: 0 additions & 1 deletion src/flowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ export interface CallWebhook extends Action {
}

export interface OpenTicket extends Action {
subject?: string;
topic?: Topic;
body?: string;
result_name: string;
Expand Down

0 comments on commit cf4dc37

Please sign in to comment.