All files / app/mods/org queue.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 0/0
100% Lines 7/7

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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158117x         117x                                                                                                                                                   117x                                                             117x                       117x                       117x                       117x                      
import { DateTime } from 'luxon';
import { Plugin } from '../../model/plugin';
import { Mod } from '../../model/tag';
import { Template } from '../../model/template';
 
export const queueTemplate: Template = {
  tag: 'queue',
  name: $localize`🚧️ Work Queue`,
  config: {
    type: 'lens',
    experimental: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    submit: $localize`🚧️ queue/`,
    view: $localize`🚧️`,
    description: $localize`Activates built-in Work Queue mode for managing workflows and invoices.`,
    filters: [
      { query: 'queue', label: $localize`🚧️ queue`, title: $localize`Work Queues`, group: $localize`Templates 🎨️` },
    ],
    // language=Handlebars
    ui: `
      {{#if bounty}}
        <div class="ext-text">
          <b i18n>Bounty:</b> {{ bounty }}
        </div>
      {{/if}}
      {{#if maxAge}}
        <div class="ext-text">
          <b>Max Age:</b> {{ maxAge }}
        </div>
      {{/if}}
      {{#if approvers}}
        <div class="ext-text">
          <b i18n>Approvers:</b>
          <br>
          {{#each approvers}}
            <a class="tag" href="/tag/{{this}}">{{this}}</a>
            <br>
          {{/each}}
        </div>
      {{/if}}
      {{#if (includes approvers account.tag)}}
        <a class="sidebar-link" href="/tag/{{prefix 'plugin/invoice' tag}}">invoices</a>
      {{/if}}
    `,
    form: [{
      key: 'bounty',
      type: 'string',
      props: {
        label: $localize`Bounty: `
      }
    }, {
      key: 'maxAge',
      type: 'string',
      props: {
        label: $localize`Max Age: `
      }
    }, {
      key: 'approvers',
      type: 'qusers',
      props: {
        label: $localize`Approvers: `,
        addText: $localize`+ Add another approver`,
      }
    }]
  },
  defaults: {
    approvers: [],
  },
  schema: {
    properties: {
      approvers: { elements: { type: 'string' } },
    },
    optionalProperties: {
      bounty: { type: 'string' },
      maxAge: { type: 'string' },
    },
  },
};
 
export const invoicePlugin: Plugin = {
  tag: 'plugin/invoice',
  name: $localize`🧾️ Invoice`,
  config: {
    mod: $localize`🚧️ Work Queue`,
    type: 'lens',
    experimental: true,
    add: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    description: $localize`Represent locked Refs as invoices and handle workflow status flow using plugin responses.`,
    icons: [
      { label: $localize`🧾️` },
      { label: $localize`👍️`, response: 'plugin/user/invoice.paid' },
      { label: $localize`👎️`, response: 'plugin/user/invoice.rejected' },
      { label: $localize`⚠️`, response: 'plugin/user/invoice.disputed' },
    ],
    actions: [
      { response: 'plugin/user/invoice.disputed', labelOff: $localize`dispute`, labelOn: $localize`un-dispute`, visible: 'author' },
      { response: 'plugin/user/invoice.rejected', clear: ['plugin/user/invoice.paid'], labelOff: $localize`reject`, labelOn: $localize`un-reject`, visible: 'recipient' },
      { response: 'plugin/user/invoice.paid', clear: ['plugin/user/invoice.rejected'], labelOff: $localize`paid`, labelOn: $localize`unpaid`, visible: 'recipient' },
    ],
    filters: [
      { query: 'plugin/invoice', label: $localize`🧾️ invoice`, title: $localize`Invoice`, group: $localize`Plugins 🧰️` },
      { response: '!plugin/user/invoice.paid', label: $localize`🧾️ unpaid`, title: $localize`Unpaid Invoices`, group: $localize`Invoices` },
      { response: 'plugin/user/invoice.paid', label: $localize`💸️ paid`, title: $localize`Paid Invoices`, group: $localize`Invoices` },
      { response: 'plugin/user/invoice.rejected', label: $localize`👎️ rejected`, title: $localize`Rejected Invoices`, group: $localize`Invoices` },
      { response: 'plugin/user/invoice.disputed', label: $localize`⚠️ disputed`, title: $localize`Disputed Invoices`, group: $localize`Invoices` },
    ],
  },
};
 
export const invoiceRejectionPlugin: Plugin = {
  tag: 'plugin/user/invoice.rejected',
  name: $localize`🧾️👎️ Invoice Rejected`,
  config: {
    mod: $localize`🚧️ Work Queue`,
    type: 'lens',
    experimental: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    description: $localize`Used to mark status in the plugin/invoice workflow.`,
  },
};
 
export const invoiceDisputedPlugin: Plugin = {
  tag: 'plugin/user/invoice.disputed',
  name: $localize`🧾️⚠️ Invoice Disputed`,
  config: {
    mod: $localize`🚧️ Work Queue`,
    type: 'lens',
    experimental: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    description: $localize`Used to mark status in the plugin/invoice workflow.`,
  },
};
 
export const invoicePaidPlugin: Plugin = {
  tag: 'plugin/user/invoice.paid',
  name: $localize`🧾️💸️ Invoice Paid`,
  config: {
    mod: $localize`🚧️ Work Queue`,
    type: 'lens',
    experimental: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    description: $localize`Used to mark status in the plugin/invoice workflow.`,
  },
};
 
export const queueMod: Mod = {
  plugin: [
    invoicePlugin,
    invoiceRejectionPlugin,
    invoiceDisputedPlugin,
    invoicePaidPlugin,
  ],
   template: [
    queueTemplate,
  ],
};