All files / app/mods user.ts

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

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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211158x         158x   158x                                                                                                                                                                                                                                                                                                                                                                                                           158x          
import { DateTime } from 'luxon';
import { Mod } from '../model/tag';
import { Template } from '../model/template';
import { RootConfig } from './root';
 
export const defaultSubs = ['+meta', 'science', 'politics', 'history', 'news', 'funny'];
 
export const userTemplate: Template = {
  tag: 'user',
  name: $localize`🧑️ User`,
  config: {
    mod: $localize`🧑️ User`,
    version: 3,
    default: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    description: $localize`Allows users to save useful public data in their Ext.`,
    aiInstructions: ` # user
    The user template allows users to interact with the system. User templates are only used as
    protected or private. By adding your user tag to a Ref you retain write access and (in the case
    of protected tags or private) allow others to see you as the author.
 
    When tagging another user in a Ref, the users inbox tag should be used to notify the user
    and give them read-access to the Ref.
 
    If you are responding to a thread or comment section where multiple users are talking, you may
    get sent messages where there is no response needed from you. For example, if a user is requested
    to reply to a thread, one convention is to simply reply tagging the user like so: '+user/chris'.
    If you receive such a message, simply respond 'ACK', so that we can silently hide your response.
    `,
    overrideForm: true,
    form: [{
      key: 'liveSearch',
      type: 'boolean',
      props: {
        label: $localize`Live Search:`,
        title: $localize`Search as you type.`,
      }
    }, {
      key: 'email',
      type: 'email',
    }, {
      key: 'bookmarks',
      type: 'bookmarks',
      props: {
        label: $localize`Bookmarks:`,
        addText: $localize`+ Add another bookmark`,
      }
    }, {
      key: 'alarms',
      type: 'queries',
      props: {
        label: $localize`Alarms:`,
        addText: $localize`+ Add another alarm`,
      },
      fieldArray: {
        props: {
          label: $localize`🔔`,
        }
      },
    }, {
      key: 'subscriptions',
      type: 'queries',
      expressions: {
        hide: '!formState.admin.home',
      },
      props: {
        label: $localize`Subscriptions:`,
        addText: $localize`+ Add another subscription`,
      },
      fieldArray: {
        props: {
          label: $localize`🏡`,
        }
      },
    }],
    advancedForm: [{
      key: 'queryStyle',
      type: 'enum',
      props: {
        label: $localize`Query Style:`,
        options: [
          { label: $localize`Default` },
          { value: 'code', label: $localize`Code` },
          { value: 'set', label: $localize`Set` },
          { value: 'logic', label: $localize`Logic` },
        ],
      },
    }, {
      key: 'editors',
      type: 'tags',
      props: {
        label: $localize`Editors:`,
        addText: $localize`+ Add another editor`,
      },
      fieldArray: {
        props: {
          label: $localize`📝`,
        }
      },
    }, {
      key: 'pinned',
      type: 'refs',
      props: {
        label: $localize`Pinned:`,
        addText: $localize`+ Add another pinned link`,
      },
      fieldArray: {
        props: {
          label: $localize`📌️`,
        }
      },
    }, {
      key: 'queryFilters',
      type: 'list',
      props: {
        label: $localize`Query Filters:`,
        addText: $localize`+ Add another query filter`,
      },
      fieldArray: {
        fieldGroup: [{
          key: 'label',
          type: 'string',
          props: {
            label: $localize`Label:`
          }
        }, {
          key: 'query',
          type: 'query',
          props: {
            required: true,
          }
        }]
      }
    }, {
      key: 'responseFilters',
      type: 'list',
      props: {
        label: $localize`Response Filters:`,
        addText: $localize`+ Add another response filter`,
      },
      fieldArray: {
        fieldGroup: [{
          key: 'label',
          type: 'string',
          props: {
            label: $localize`Label:`
          }
        }, {
          key: 'response',
          type: 'plugin',
          props: {
            required: true,
          }
        }]
      }
    }, {
      key: 'kanbanLoadSize',
      type: 'number',
      props: {
        label: $localize`Kanban Load Size:`,
      }
    }, {
      key: 'defaults',
      type: 'boolean',
      props: {
        label: $localize`Defaults:`,
      },
    }],
  },
  defaults: <UserConfig> {
    subscriptions: defaultSubs,
  },
  schema: {
    optionalProperties: {
      queryStyle: { type: 'string' },
      liveSearch: { type: 'boolean' },
      email: { type: 'string' },
      lastNotified: { type: 'string' },
      subscriptions: { elements: { type: 'string' } },
      bookmarks: { elements: { type: 'string' } },
      alarms: { elements: { type: 'string' } },
      editors: { elements: { type: 'string' } },
      userTheme: { type: 'string' },
      consent: { values: { type: 'boolean' }},
      kanbanLoadSize: { type: 'uint8' },
    }
  },
};
 
export interface UserConfig extends RootConfig {
  queryStyle?: string;
  liveSearch?: boolean;
  email?: string;
  lastNotified?: string;
  subscriptions?: string[];
  bookmarks?: string[];
  alarms?: string[];
  editors?: string[];
  userTheme?: string;
  consent?: { [key: string]: boolean };
 
  // TODO: move to ref `tag:/user/chris?url=tag:/kanban with plugin/settings/kanban
  kanbanLoadSize?: number;
}
 
export const userMod: Mod = {
  template: [
    userTemplate,
  ]
};