Skip to content

Commit

Permalink
Merge branch 'main' into component-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnewcomer committed Mar 6, 2024
2 parents 49d5830 + 6a56d06 commit 6c9a6ca
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 15 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.26.5](https://github.com/nyaruka/floweditor/compare/v1.26.4...v1.26.5)

> 4 March 2024
- Bump spec version to 13.3 [`f78035f`](https://github.com/nyaruka/floweditor/commit/f78035fa67a70722752e14c96766e8fadaffcbee)

#### [v1.26.4](https://github.com/nyaruka/floweditor/compare/v1.26.3...v1.26.4)

> 21 February 2024
- Bump follow-redirects from 1.14.8 to 1.15.4 [`#1215`](https://github.com/nyaruka/floweditor/pull/1215)
- Bump ip from 1.1.5 to 1.1.9 [`#1220`](https://github.com/nyaruka/floweditor/pull/1220)
- Add support to the simulator to display warnings [`#1218`](https://github.com/nyaruka/floweditor/pull/1218)

#### [v1.26.3](https://github.com/nyaruka/floweditor/compare/v1.26.2...v1.26.3)

> 4 January 2024
- Revert change to remove result name default on open ticket action [`5f7e185`](https://github.com/nyaruka/floweditor/commit/5f7e1853b1a7ca4a12918f04bc3b96cf21ba3354)

#### [v1.26.2](https://github.com/nyaruka/floweditor/compare/v1.26.1...v1.26.2)

> 4 January 2024
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@nyaruka/flow-editor",
"license": "AGPL-3.0",
"repository": "git://github.com/nyaruka/floweditor.git",
"version": "1.26.2",
"version": "1.26.5",
"description": "'Standalone flow editing tool designed for use within the RapidPro suite of messaging tools but can be adopted for use outside of that ecosystem.'",
"browser": "umd/flow-editor.min.js",
"unpkg": "umd/flow-editor.min.js",
Expand Down
2 changes: 1 addition & 1 deletion src/components/flow/routers/ticket/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getOriginalAction = (settings: NodeEditorSettings): OpenTicket => {
export const nodeToState = (settings: NodeEditorSettings): TicketRouterFormState => {
let subject = { value: '@run.flow.name' };
let body = { value: '' };
let resultName = { value: '' };
let resultName = { value: 'Result' };
let assignee: FormEntry = { value: null };
let topic: FormEntry = { value: null };

Expand Down
20 changes: 19 additions & 1 deletion src/components/simulator/LogEvent.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
transform: scale(0.2);
opacity: 0;
}

to {
transform: scale(1);
opacity: 1;
Expand All @@ -20,6 +21,7 @@
.msg_text {
padding: 8px 15px;
}

.ivr_msg,
.send_msg {
border-radius: 10px;
Expand Down Expand Up @@ -50,6 +52,16 @@
}
}

.warning {
float: inherit;
color: $yellow;
font-size: 11px;
border: none;
text-align: center;
padding: 10px 15px;
border-radius: 11px;
}

.error {
float: inherit;
color: $red;
Expand All @@ -72,6 +84,7 @@
.email {
text-decoration: underline;
cursor: pointer;

&:hover {
color: #999;
}
Expand All @@ -81,6 +94,7 @@
word-break: break-all;
text-decoration: underline;
cursor: pointer;

&:hover {
color: #999;
}
Expand Down Expand Up @@ -145,12 +159,14 @@
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;

::first-line {
font-family: 'Roboto', sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 34px;
}

.response {
padding-top: 20px;
}
Expand Down Expand Up @@ -182,11 +198,13 @@
width: 100%;
font-size: 90%;
color: #bbb;

td {
padding: 0 5px;
}

td:last-child {
text-align: right;
font-size: 90%;
}
}
}
7 changes: 7 additions & 0 deletions src/components/simulator/LogEvent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ describe(LogEvent.name, () => {
...commonEventProps
});
});
it('should render warning event', () => {
testEventRender({
type: 'warning',
text: "I'm an warning",
...commonEventProps
});
});
it('should render error event', () => {
testEventRender({
type: 'error',
Expand Down
26 changes: 20 additions & 6 deletions src/components/simulator/LogEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ const getStyleForDirection = (direction: Direction): string => {
return direction === Direction.MO ? styles.msg_received : styles.send_msg;
};

const renderWarning = (warning: string): JSX.Element => {
return (
<div className={styles.warning}>
<span>Warning: {warning}</span>
</div>
);
};

const renderError = (error: string): JSX.Element => {
return (
<div className={styles.error}>
Expand All @@ -109,6 +117,10 @@ const renderError = (error: string): JSX.Element => {
);
};

const renderInfoStyles = (allStyles: any[]): string => {
return allStyles.join(' ');
};

const renderInfo = (info: string, extraStyles?: any[]): JSX.Element => {
// localized text can have html entities, so this isn't as dangerous as it looks
const infoStyle = [styles.info];
Expand All @@ -120,9 +132,6 @@ const renderInfo = (info: string, extraStyles?: any[]): JSX.Element => {
</div>
);
};
const renderInfoStyles = (allStyles: any[]): string => {
return allStyles.join(' ');
};

const renderAttachment = (attachment: string): JSX.Element => {
const idx = attachment.indexOf(':');
Expand Down Expand Up @@ -381,6 +390,8 @@ export default class LogEvent extends React.Component<EventProps, LogEventState>
return renderMessage(this.props.msg.text, this.props.msg.attachments, Direction.MT);
case 'ivr_created':
return renderMessage(this.props.msg.text, this.props.msg.attachments, Direction.MT);
case 'warning':
return renderWarning(this.props.text);
case 'error':
return renderError(this.props.text);
case 'failure':
Expand All @@ -391,7 +402,7 @@ export default class LogEvent extends React.Component<EventProps, LogEventState>
return this.renderGroupsChanged();
case 'contact_urns_changed':
return renderInfo('Added a URN for the contact');
case 'contact_field_changed':
case 'contact_field_changed': {
const value = this.getValue(this.props.value);
if (value !== '') {
return renderInfo(
Expand All @@ -407,6 +418,7 @@ export default class LogEvent extends React.Component<EventProps, LogEventState>
})
);
}
}
case 'run_result_changed':
return renderInfo(
i18n.t('simulator.run_result_changed', 'Set result "[[field]]" to "[[value]]"', {
Expand All @@ -423,9 +435,10 @@ export default class LogEvent extends React.Component<EventProps, LogEventState>
case 'email_created':
case 'email_sent':
return this.renderEmailSent();
case 'broadcast_created':
case 'broadcast_created': {
const translation = this.props.translations[this.props.base_language];
return renderMessage(translation.text, translation.attachments, Direction.MT);
}
case 'resthook_called':
return renderInfo(
i18n.t('simulator.resthook_called', 'Triggered flow event "[[resthook]]"', {
Expand Down Expand Up @@ -475,7 +488,7 @@ export default class LogEvent extends React.Component<EventProps, LogEventState>
topic: this.props.ticket.topic.name
})
);
case 'airtime_transferred':
case 'airtime_transferred': {
const event = this.props as AirtimeTransferEvent;
return (
<>
Expand All @@ -494,6 +507,7 @@ export default class LogEvent extends React.Component<EventProps, LogEventState>
)}
</>
);
}
}

// should only get here if we are get an unexpected event
Expand Down
19 changes: 19 additions & 0 deletions src/components/simulator/__snapshots__/LogEvent.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,22 @@ exports[`LogEvent should render ticket_opened event 1`] = `
</div>
</body>
`;

exports[`LogEvent should render warning event 1`] = `
<body>
<div>
<div
class="evt"
>
<div
class="warning"
>
<span>
Warning:
I'm an warning
</span>
</div>
</div>
</div>
</body>
`;
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5868,9 +5868,9 @@ fn-name@~2.0.1:
integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=

follow-redirects@^1.0.0, follow-redirects@^1.14.0:
version "1.14.8"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
version "1.15.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf"
integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==

for-in@^0.1.3:
version "0.1.8"
Expand Down Expand Up @@ -6922,9 +6922,9 @@ ip-regex@^2.1.0:
integrity sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=

ip@^1.1.0, ip@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a"
integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=
version "1.1.9"
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.9.tgz#8dfbcc99a754d07f425310b86a99546b1151e396"
integrity sha512-cyRxvOEpNHNtchU3Ln9KC/auJgup87llfQpQ+t5ghoC/UhL16SWzbueiCsdTnWmqAWl7LadfuwhlqmtOaqMHdQ==

ipaddr.js@1.9.1, ipaddr.js@^1.9.0:
version "1.9.1"
Expand Down

0 comments on commit 6c9a6ca

Please sign in to comment.