All files / src/flow/actions play_audio.ts

100% Statements 46/46
60% Branches 3/5
100% Functions 2/2
100% Lines 46/46

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 4798x 1x 1x 98x 98x 98x 98x 98x 98x 98x 98x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 98x 98x 98x 98x 98x 98x 98x 98x 98x 98x 98x 98x  
import { html } from 'lit-html';
import { ActionConfig, ACTION_GROUPS, FormData, FlowTypes } from '../types';
import { Node, PlayAudio } from '../../store/flow-definition';
import { renderHighlightedText } from '../utils';
 
export const play_audio: ActionConfig = {
  name: 'Play Recording',
  group: ACTION_GROUPS.send,
  flowTypes: [FlowTypes.VOICE],
  render: (_node: Node, action: PlayAudio) => {
    return html`
      <div style="display: flex; align-items: center; gap: 0.3em;">
        <temba-icon name="recording" size="1"></temba-icon>
        <div
          style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;"
          title="${action.audio_url || ''}"
        >
          ${renderHighlightedText(action.audio_url || '', true)}
        </div>
      </div>
    `;
  },
  form: {
    audio_url: {
      type: 'text',
      label: 'Recording URL',
      required: true,
      evaluated: true
    }
  },
  layout: ['audio_url'],
  toFormData: (action: PlayAudio) => {
    return {
      uuid: action.uuid,
      audio_url: action.audio_url || ''
    };
  },
  fromFormData: (data: FormData) => {
    return {
      uuid: data.uuid,
      type: 'play_audio',
      audio_url: (data.audio_url || '').trim()
    } as PlayAudio;
  },
  localizable: ['audio_url']
};