chore: clean up code formatting and improve readability across multiple files
This commit is contained in:
parent
3f7d9068bf
commit
fc07d2a3bb
16 changed files with 36 additions and 71 deletions
|
|
@ -5,6 +5,9 @@ yarn.lock
|
|||
bun.lock
|
||||
bun.lockb
|
||||
|
||||
# Local session artifacts
|
||||
.remember/
|
||||
|
||||
# Generated API schema. drf-spectacular writes YAML, and the file name says
|
||||
# .json, so prettier picks the JSON parser and dies on line 1 instead of
|
||||
# reporting a formatting diff. That aborts `pnpm run lint` before eslint runs.
|
||||
|
|
|
|||
|
|
@ -372,8 +372,8 @@
|
|||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between">
|
||||
<p class="text-sm font-medium text-red-800">
|
||||
{preview.errors.length} error{preview.errors.length === 1 ? '' : 's'}, fix the CSV before
|
||||
importing
|
||||
{preview.errors.length} error{preview.errors.length === 1 ? '' : 's'}, fix the CSV
|
||||
before importing
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
|
|
|
|||
|
|
@ -337,8 +337,8 @@
|
|||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between">
|
||||
<p class="text-sm font-medium text-red-800">
|
||||
{preview.errors.length} error{preview.errors.length === 1 ? '' : 's'}, fix the CSV before
|
||||
importing
|
||||
{preview.errors.length} error{preview.errors.length === 1 ? '' : 's'}, fix the CSV
|
||||
before importing
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ export function describeError(err) {
|
|||
if (err === null || err === undefined) return 'unknown error';
|
||||
|
||||
const message =
|
||||
typeof err === 'object' && err !== null && typeof (/** @type {any} */ (err).message) === 'string'
|
||||
typeof err === 'object' &&
|
||||
err !== null &&
|
||||
typeof (/** @type {any} */ (err).message) === 'string'
|
||||
? /** @type {any} */ (err).message
|
||||
: String(err);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|||
const apiRequest = vi.fn();
|
||||
vi.mock('$lib/api-helpers.js', () => ({ apiRequest: (...a) => apiRequest(...a) }));
|
||||
|
||||
const {
|
||||
createEscalationPolicy,
|
||||
updateEscalationPolicy,
|
||||
deleteEscalationPolicy,
|
||||
UPDATE_FIELDS
|
||||
} = await import('./escalation.js');
|
||||
const { createEscalationPolicy, updateEscalationPolicy, deleteEscalationPolicy, UPDATE_FIELDS } =
|
||||
await import('./escalation.js');
|
||||
|
||||
const cookies = /** @type {any} */ ({ get: () => 'token' });
|
||||
const event = /** @type {any} */ ({ cookies });
|
||||
|
|
|
|||
|
|
@ -77,9 +77,7 @@ export function displayValue(definition, value) {
|
|||
case 'number':
|
||||
return typeof value === 'number' ? value.toLocaleString() : String(value);
|
||||
case 'dropdown': {
|
||||
const match = (definition.options ?? []).find(
|
||||
(/** @type {any} */ o) => o.value === value
|
||||
);
|
||||
const match = (definition.options ?? []).find((/** @type {any} */ o) => o.value === value);
|
||||
return match?.label ?? String(value);
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -29,12 +29,7 @@ export async function getReopenPolicy({ cookies }) {
|
|||
|
||||
/** The four fields the serializer accepts. Everything else in the GET
|
||||
* response is a computed metric and is not writable. */
|
||||
const EDITABLE_FIELDS = [
|
||||
'is_enabled',
|
||||
'reopen_window_days',
|
||||
'reopen_to_status',
|
||||
'notify_assigned'
|
||||
];
|
||||
const EDITABLE_FIELDS = ['is_enabled', 'reopen_window_days', 'reopen_to_status', 'notify_assigned'];
|
||||
|
||||
/**
|
||||
* Update the org's reopen policy.
|
||||
|
|
|
|||
|
|
@ -208,11 +208,11 @@ describe('updateInvoiceTemplate', () => {
|
|||
});
|
||||
|
||||
it('does send the markup, unlike create', async () => {
|
||||
await updateInvoiceTemplate(
|
||||
{ cookies },
|
||||
't1',
|
||||
{ name: 'Clean', template_html: '<h1>x</h1>', template_css: 'h1{}' }
|
||||
);
|
||||
await updateInvoiceTemplate({ cookies }, 't1', {
|
||||
name: 'Clean',
|
||||
template_html: '<h1>x</h1>',
|
||||
template_css: 'h1{}'
|
||||
});
|
||||
const [, options] = apiRequest.mock.calls[0];
|
||||
expect(options.body.template_html).toBe('<h1>x</h1>');
|
||||
expect(options.body.template_css).toBe('h1{}');
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|||
const apiRequest = vi.fn();
|
||||
vi.mock('$lib/api-helpers.js', () => ({ apiRequest: (...a) => apiRequest(...a) }));
|
||||
|
||||
const { createApprovalRule, updateApprovalRule, deleteApprovalRule } = await import(
|
||||
'./ticket-approvals.js'
|
||||
);
|
||||
const { createApprovalRule, updateApprovalRule, deleteApprovalRule } =
|
||||
await import('./ticket-approvals.js');
|
||||
|
||||
const cookies = /** @type {any} */ ({ get: () => 'token' });
|
||||
const event = /** @type {any} */ ({ cookies });
|
||||
|
|
@ -96,9 +95,7 @@ describe('createApprovalRule', () => {
|
|||
});
|
||||
|
||||
it('refuses a rule with no name before making a request', async () => {
|
||||
await expect(createApprovalRule(event, { ...base, name: '' })).rejects.toThrow(
|
||||
/needs a name/i
|
||||
);
|
||||
await expect(createApprovalRule(event, { ...base, name: '' })).rejects.toThrow(/needs a name/i);
|
||||
expect(apiRequest).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,13 +20,7 @@
|
|||
* explain?: string,
|
||||
* hidden?: Record<string, string>
|
||||
* }} */
|
||||
let {
|
||||
action,
|
||||
label = 'Delete',
|
||||
confirmLabel = 'Confirm',
|
||||
explain = '',
|
||||
hidden = {}
|
||||
} = $props();
|
||||
let { action, label = 'Delete', confirmLabel = 'Confirm', explain = '', hidden = {} } = $props();
|
||||
|
||||
let armed = $state(false);
|
||||
let busy = $state(false);
|
||||
|
|
|
|||
|
|
@ -30,15 +30,7 @@
|
|||
* ondone?: () => void,
|
||||
* fields: import('svelte').Snippet
|
||||
* }} */
|
||||
let {
|
||||
title,
|
||||
action,
|
||||
error = null,
|
||||
submitLabel = 'Save',
|
||||
oncancel,
|
||||
ondone,
|
||||
fields
|
||||
} = $props();
|
||||
let { title, action, error = null, submitLabel = 'Save', oncancel, ondone, fields } = $props();
|
||||
|
||||
// Disables submit while a request is in flight so a double-click cannot
|
||||
// fire two writes.
|
||||
|
|
|
|||
|
|
@ -56,15 +56,7 @@ describe('every descriptor agrees with its module allow-list', () => {
|
|||
// Params a page's own `load` interprets rather than forwarding to the
|
||||
// API. `archived` is documents' opt-in to seeing archived rows, the
|
||||
// same shape as contacts' `inactive`.
|
||||
const VIEW_PARAMS = [
|
||||
'all',
|
||||
'inactive',
|
||||
'archived',
|
||||
'visibility',
|
||||
'view',
|
||||
'open',
|
||||
'rotten'
|
||||
];
|
||||
const VIEW_PARAMS = ['all', 'inactive', 'archived', 'visibility', 'view', 'open', 'rotten'];
|
||||
for (const preset of FILTERS[pageKey].presets) {
|
||||
for (const key of Object.keys(preset.params)) {
|
||||
if (VIEW_PARAMS.includes(key)) continue;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
import { fail, redirect, error } from '@sveltejs/kit';
|
||||
import {
|
||||
getInvoiceTemplateForEdit,
|
||||
updateInvoiceTemplate
|
||||
} from '$lib/server/v2/templates.js';
|
||||
import { getInvoiceTemplateForEdit, updateInvoiceTemplate } from '$lib/server/v2/templates.js';
|
||||
import { readableError } from '$lib/server/v2/form-errors.js';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@
|
|||
<span class="v2-sub" style="font-size:12px">
|
||||
{#if (t.scopes ?? []).length === 0}
|
||||
Everything {(owner.name ?? '').split(' ')[0]} can
|
||||
{:else if (t.scopes ?? []).every((/** @type {string} */ s) => s.endsWith(':read'))}
|
||||
{:else if (t.scopes ?? []).every( (/** @type {string} */ s) => s.endsWith(':read') )}
|
||||
Read only
|
||||
{:else}
|
||||
{(t.scopes ?? []).join(', ')}
|
||||
|
|
@ -364,10 +364,10 @@
|
|||
<div>
|
||||
<div style="font-weight:600;font-size:13px">A token is the whole account</div>
|
||||
<p class="v2-sub" style="font-size:12px;margin:4px 0 0">
|
||||
A token authenticates as its owner and inherits their role and organisation. There is
|
||||
no narrower permission to give it. Issue one per integration so a single revocation
|
||||
stops a single thing, set an expiry, and revoke anything you cannot name a use for. The
|
||||
value is shown once when the token is created and cannot be recovered afterwards.
|
||||
A token authenticates as its owner and inherits their role and organisation. There is no
|
||||
narrower permission to give it. Issue one per integration so a single revocation stops a
|
||||
single thing, set an expiry, and revoke anything you cannot name a use for. The value is
|
||||
shown once when the token is created and cannot be recovered afterwards.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -231,8 +231,8 @@
|
|||
</div>
|
||||
<p class="v2-sub" style="font-size:11.5px;margin-top:11px;line-height:1.5">
|
||||
These seven are the whole set. Anything else between percent signs is left exactly as
|
||||
written and goes out that way. The server does not guess, on purpose, so a typo is
|
||||
visible in the composer rather than a blank in the customer's inbox.
|
||||
written and goes out that way. The server does not guess, on purpose, so a typo is visible
|
||||
in the composer rather than a blank in the customer's inbox.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -47,9 +47,7 @@
|
|||
// The repeating condition rows being edited, as `{ field, op, value }`.
|
||||
// Held here, rather than read off `editing`, so a row can be added or
|
||||
// removed before submitting.
|
||||
let conditionRows = $state(
|
||||
/** @type {{ field: string, op: string, value: string }[]} */ ([])
|
||||
);
|
||||
let conditionRows = $state(/** @type {{ field: string, op: string, value: string }[]} */ ([]));
|
||||
|
||||
function openCreate() {
|
||||
editing = 'new';
|
||||
|
|
@ -378,7 +376,8 @@
|
|||
class="v2-btn v2-btn-sm"
|
||||
type="button"
|
||||
style="align-self:flex-start"
|
||||
onclick={() => (conditionRows = [...conditionRows, { field: '', op: 'eq', value: '' }])}
|
||||
onclick={() =>
|
||||
(conditionRows = [...conditionRows, { field: '', op: 'eq', value: '' }])}
|
||||
>
|
||||
Add a condition
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue