@crombolo/backoffice-host 0.43.1 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/plugin/app-preview/umbraco-package.json +1 -1
- package/plugin/branding/theme-dark.css +2 -0
- package/plugin/branding/theme.css +3 -0
- package/plugin/bundle-editor.js +1 -1
- package/plugin/bundles-client.js +6 -0
- package/plugin/bundles-created-overview.js +1 -1
- package/plugin/bundles-created.js +13 -4
- package/plugin/bundles-installed.js +35 -6
- package/plugin/bundles-marketplace.js +73 -11
- package/plugin/bundles-signature-words.js +47 -0
- package/plugin/bundles-signature.js +35 -0
- package/plugin/bundles-tool.js +79 -0
- package/plugin/ci-access-words.js +63 -0
- package/plugin/ci-access.js +270 -0
- package/plugin/form-picker-options.js +61 -5
- package/plugin/form-picker.js +27 -18
- package/plugin/form-type-note.js +53 -0
- package/plugin/forms-client.js +6 -0
- package/plugin/forms-entries.js +39 -0
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/overview-dashboard.js +4 -4
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/settings-card.js +57 -0
- package/plugin/settings-cards.js +67 -17
- package/plugin/settings-section.js +57 -27
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +53 -40
- package/src/extensions.ts +7 -3
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI access, a Settings tool for administrators (story 160): the CI jobs this
|
|
3
|
+
* site trusts to pull and push without a person, each by the repository and
|
|
4
|
+
* branch, tag or environment its provider's signed identity token names. There
|
|
5
|
+
* is no secret to set up; a rule here is all a job needs.
|
|
6
|
+
*/
|
|
7
|
+
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
8
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
9
|
+
import { CI_PERMISSIONS, providerName, trustApi } from './ci-access-words.js'
|
|
10
|
+
|
|
11
|
+
const EMPTY = {
|
|
12
|
+
name: '',
|
|
13
|
+
issuer: '',
|
|
14
|
+
repository: '',
|
|
15
|
+
refKind: 'branch',
|
|
16
|
+
refValue: '',
|
|
17
|
+
permissions: [],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default class CromboloCiAccessElement extends UmbLitElement {
|
|
21
|
+
static properties = {
|
|
22
|
+
_state: { state: true },
|
|
23
|
+
_draft: { state: true },
|
|
24
|
+
_problems: { state: true },
|
|
25
|
+
_busy: { state: true },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super()
|
|
30
|
+
this._state = undefined
|
|
31
|
+
this._draft = undefined
|
|
32
|
+
this._problems = []
|
|
33
|
+
this._busy = false
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback()
|
|
38
|
+
this.#load()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async #load() {
|
|
42
|
+
try {
|
|
43
|
+
this._state = await trustApi('GET')
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this._state = { error: error.message }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async #act(method, path, body) {
|
|
50
|
+
this._busy = true
|
|
51
|
+
this._problems = []
|
|
52
|
+
try {
|
|
53
|
+
await trustApi(method, path, body)
|
|
54
|
+
this._draft = undefined
|
|
55
|
+
await this.#load()
|
|
56
|
+
} catch (error) {
|
|
57
|
+
this._problems = error.items ?? [error.message]
|
|
58
|
+
} finally {
|
|
59
|
+
this._busy = false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#set(field, value) {
|
|
64
|
+
this._draft = { ...this._draft, [field]: value }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#toggle(verb, on) {
|
|
68
|
+
const permissions = new Set(this._draft.permissions)
|
|
69
|
+
if (on) permissions.add(verb)
|
|
70
|
+
else permissions.delete(verb)
|
|
71
|
+
this.#set('permissions', [...permissions])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#form() {
|
|
75
|
+
const draft = this._draft
|
|
76
|
+
const issuers = this._state.issuers ?? []
|
|
77
|
+
return html`<uui-box headline="Trust a CI job">
|
|
78
|
+
<div class="form">
|
|
79
|
+
<uui-label for="ci-name">Name</uui-label>
|
|
80
|
+
<uui-input id="ci-name" label="Name" .value=${draft.name} @input=${(e) => this.#set('name', e.target.value)}></uui-input>
|
|
81
|
+
<uui-label for="ci-provider">Provider</uui-label>
|
|
82
|
+
<uui-select
|
|
83
|
+
id="ci-provider"
|
|
84
|
+
label="Provider"
|
|
85
|
+
.options=${issuers.map((issuer) => ({ name: providerName(issuer), value: issuer, selected: issuer === draft.issuer }))}
|
|
86
|
+
@change=${(e) => this.#set('issuer', e.target.value)}
|
|
87
|
+
></uui-select>
|
|
88
|
+
<uui-label for="ci-repository">Repository</uui-label>
|
|
89
|
+
<uui-input
|
|
90
|
+
id="ci-repository"
|
|
91
|
+
label="Repository"
|
|
92
|
+
placeholder="owner/name, or group/project"
|
|
93
|
+
.value=${draft.repository}
|
|
94
|
+
@input=${(e) => this.#set('repository', e.target.value)}
|
|
95
|
+
></uui-input>
|
|
96
|
+
<uui-label for="ci-ref">Runs on</uui-label>
|
|
97
|
+
<div class="ref">
|
|
98
|
+
<uui-select
|
|
99
|
+
label="Runs on"
|
|
100
|
+
.options=${[
|
|
101
|
+
{ name: 'Branch', value: 'branch', selected: draft.refKind === 'branch' },
|
|
102
|
+
{ name: 'Tag', value: 'tag', selected: draft.refKind === 'tag' },
|
|
103
|
+
{
|
|
104
|
+
name: 'Environment',
|
|
105
|
+
value: 'environment',
|
|
106
|
+
selected: draft.refKind === 'environment',
|
|
107
|
+
},
|
|
108
|
+
]}
|
|
109
|
+
@change=${(e) => this.#set('refKind', e.target.value)}
|
|
110
|
+
></uui-select>
|
|
111
|
+
<uui-input id="ci-ref" label="Its name" placeholder="main" .value=${draft.refValue} @input=${(e) => this.#set('refValue', e.target.value)}></uui-input>
|
|
112
|
+
</div>
|
|
113
|
+
<span class="label">May</span>
|
|
114
|
+
<div class="may">
|
|
115
|
+
${CI_PERMISSIONS.map(
|
|
116
|
+
(p) => html`<uui-toggle
|
|
117
|
+
label=${p.label}
|
|
118
|
+
.checked=${draft.permissions.includes(p.verb)}
|
|
119
|
+
@change=${(e) => this.#toggle(p.verb, e.target.checked)}
|
|
120
|
+
></uui-toggle>
|
|
121
|
+
<small>${p.explain}</small>`,
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
${
|
|
126
|
+
this._problems.length > 0
|
|
127
|
+
? html`<ul class="problems" role="alert">${this._problems.map((p) => html`<li>${p}</li>`)}</ul>`
|
|
128
|
+
: nothing
|
|
129
|
+
}
|
|
130
|
+
<div class="actions">
|
|
131
|
+
<uui-button look="secondary" label="Cancel" @click=${() => {
|
|
132
|
+
this._draft = undefined
|
|
133
|
+
this._problems = []
|
|
134
|
+
}}></uui-button>
|
|
135
|
+
<uui-button
|
|
136
|
+
look="primary"
|
|
137
|
+
label="Trust this job"
|
|
138
|
+
.state=${this._busy ? 'waiting' : undefined}
|
|
139
|
+
@click=${() => this.#act('POST', '', draft)}
|
|
140
|
+
></uui-button>
|
|
141
|
+
</div>
|
|
142
|
+
</uui-box>`
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
render() {
|
|
146
|
+
const state = this._state
|
|
147
|
+
if (!state) return html`<uui-loader></uui-loader>`
|
|
148
|
+
if (state.error)
|
|
149
|
+
return html`<uui-box headline="CI access"><p role="alert">${state.error}</p></uui-box>`
|
|
150
|
+
return html`
|
|
151
|
+
${
|
|
152
|
+
state.remoteEnabled
|
|
153
|
+
? nothing
|
|
154
|
+
: html`<p class="notice" role="status">
|
|
155
|
+
This site does not take pulls or pushes yet, so these rules do nothing until it does.
|
|
156
|
+
</p>`
|
|
157
|
+
}
|
|
158
|
+
${this._draft ? this.#form() : nothing}
|
|
159
|
+
<uui-box headline="Trusted CI jobs">
|
|
160
|
+
<uui-button
|
|
161
|
+
slot="header-actions"
|
|
162
|
+
look="primary"
|
|
163
|
+
label="Trust a CI job"
|
|
164
|
+
?disabled=${Boolean(this._draft)}
|
|
165
|
+
@click=${() => {
|
|
166
|
+
this._draft = { ...EMPTY, issuer: state.issuers?.[0] ?? '' }
|
|
167
|
+
}}
|
|
168
|
+
></uui-button>
|
|
169
|
+
<p class="intro">
|
|
170
|
+
A job proves where it runs with its provider's signed identity, so there is no password or
|
|
171
|
+
key to keep. It may only do what its rule says.
|
|
172
|
+
</p>
|
|
173
|
+
${
|
|
174
|
+
state.items.length === 0
|
|
175
|
+
? html`<p>No CI job is trusted yet.</p>`
|
|
176
|
+
: html`<uui-table>
|
|
177
|
+
<uui-table-head>
|
|
178
|
+
<uui-table-head-cell>Name</uui-table-head-cell>
|
|
179
|
+
<uui-table-head-cell>Runs from</uui-table-head-cell>
|
|
180
|
+
<uui-table-head-cell>May</uui-table-head-cell>
|
|
181
|
+
<uui-table-head-cell>Last used</uui-table-head-cell>
|
|
182
|
+
<uui-table-head-cell></uui-table-head-cell>
|
|
183
|
+
</uui-table-head>
|
|
184
|
+
${repeat(
|
|
185
|
+
state.items,
|
|
186
|
+
(rule) => rule.key,
|
|
187
|
+
(rule) => html`<uui-table-row class=${rule.disabled ? 'disabled' : ''}>
|
|
188
|
+
<uui-table-cell>${rule.name}${rule.disabled ? html` <uui-tag look="secondary">Disabled</uui-tag>` : nothing}</uui-table-cell>
|
|
189
|
+
<uui-table-cell>${providerName(rule.issuer)} ${rule.repository}, ${rule.refKind} ${rule.refValue}</uui-table-cell>
|
|
190
|
+
<uui-table-cell>${rule.permissions.map((verb) => CI_PERMISSIONS.find((p) => p.verb === verb)?.label ?? verb).join(', ')}</uui-table-cell>
|
|
191
|
+
<uui-table-cell>${rule.lastUsedDate ? new Date(rule.lastUsedDate).toLocaleString() : 'Never'}</uui-table-cell>
|
|
192
|
+
<uui-table-cell class="row-actions">
|
|
193
|
+
<uui-button
|
|
194
|
+
look="secondary"
|
|
195
|
+
label=${rule.disabled ? 'Enable' : 'Disable'}
|
|
196
|
+
@click=${() => this.#act('POST', `/${rule.key}/${rule.disabled ? 'enable' : 'disable'}`)}
|
|
197
|
+
></uui-button>
|
|
198
|
+
<uui-button
|
|
199
|
+
look="secondary"
|
|
200
|
+
color="danger"
|
|
201
|
+
label="Delete"
|
|
202
|
+
@click=${() => this.#act('DELETE', `/${rule.key}`)}
|
|
203
|
+
></uui-button>
|
|
204
|
+
</uui-table-cell>
|
|
205
|
+
</uui-table-row>`,
|
|
206
|
+
)}
|
|
207
|
+
</uui-table>`
|
|
208
|
+
}
|
|
209
|
+
</uui-box>
|
|
210
|
+
`
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
static styles = css`
|
|
214
|
+
:host {
|
|
215
|
+
display: block;
|
|
216
|
+
padding: var(--uui-size-layout-1);
|
|
217
|
+
max-width: 72rem;
|
|
218
|
+
}
|
|
219
|
+
uui-box + uui-box {
|
|
220
|
+
margin-top: var(--uui-size-layout-1);
|
|
221
|
+
}
|
|
222
|
+
.notice {
|
|
223
|
+
padding: var(--uui-size-space-4) var(--uui-size-space-5);
|
|
224
|
+
border-left: 4px solid var(--uui-color-warning);
|
|
225
|
+
background: color-mix(in srgb, var(--uui-color-warning) 12%, var(--uui-color-surface));
|
|
226
|
+
}
|
|
227
|
+
.intro {
|
|
228
|
+
margin-top: 0;
|
|
229
|
+
color: var(--uui-color-text-alt);
|
|
230
|
+
}
|
|
231
|
+
.form {
|
|
232
|
+
display: grid;
|
|
233
|
+
grid-template-columns: 10rem 1fr;
|
|
234
|
+
gap: var(--uui-size-space-4);
|
|
235
|
+
align-items: center;
|
|
236
|
+
}
|
|
237
|
+
.ref {
|
|
238
|
+
display: flex;
|
|
239
|
+
gap: var(--uui-size-space-3);
|
|
240
|
+
}
|
|
241
|
+
.may {
|
|
242
|
+
display: grid;
|
|
243
|
+
grid-template-columns: auto 1fr;
|
|
244
|
+
gap: var(--uui-size-space-2) var(--uui-size-space-4);
|
|
245
|
+
align-items: center;
|
|
246
|
+
}
|
|
247
|
+
.may small {
|
|
248
|
+
color: var(--uui-color-text-alt);
|
|
249
|
+
}
|
|
250
|
+
.actions {
|
|
251
|
+
display: flex;
|
|
252
|
+
justify-content: flex-end;
|
|
253
|
+
gap: var(--uui-size-space-3);
|
|
254
|
+
margin-top: var(--uui-size-space-5);
|
|
255
|
+
}
|
|
256
|
+
.problems {
|
|
257
|
+
color: var(--uui-color-danger);
|
|
258
|
+
}
|
|
259
|
+
.row-actions {
|
|
260
|
+
display: flex;
|
|
261
|
+
gap: var(--uui-size-space-2);
|
|
262
|
+
justify-content: flex-end;
|
|
263
|
+
}
|
|
264
|
+
uui-table-row.disabled {
|
|
265
|
+
opacity: 0.6;
|
|
266
|
+
}
|
|
267
|
+
`
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
customElements.define('crombolo-ci-access', CromboloCiAccessElement)
|
|
@@ -1,13 +1,69 @@
|
|
|
1
1
|
/** The select reserves an empty value for its disabled placeholder. */
|
|
2
2
|
export const NO_FORM_VALUE = '@none'
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {{ key: string, name: string }} FormSummary
|
|
6
|
+
* @typedef {{ key: string, name: string, formKey: string, formName: string | null, published: boolean }} LibraryFormItem
|
|
7
|
+
* @typedef {{ name: string, value: string, group?: string, selected: boolean }} PickerOption
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Choices for the form picker (story 239): each Library form, grouped by the
|
|
12
|
+
* form it is made from. A page saved before Library forms names a form itself,
|
|
13
|
+
* which stays selected, shown in the form's own words; a saved choice that has
|
|
14
|
+
* since gone stays too, as unavailable.
|
|
15
|
+
*
|
|
16
|
+
* @param {{ forms?: FormSummary[], libraryForms?: LibraryFormItem[] }} from
|
|
17
|
+
* @param {string | undefined} value
|
|
18
|
+
* @returns {PickerOption[]}
|
|
19
|
+
*/
|
|
20
|
+
export function formPickerOptions({ forms = [], libraryForms = [] }, value) {
|
|
21
|
+
/** @type {PickerOption[]} */
|
|
6
22
|
const options = [
|
|
7
23
|
{ name: 'No form', value: NO_FORM_VALUE, selected: !value },
|
|
8
|
-
...
|
|
24
|
+
...libraryForms.map((item) => ({
|
|
25
|
+
name: item.published ? item.name : `${item.name} (not published)`,
|
|
26
|
+
value: item.key,
|
|
27
|
+
group: item.formName ?? 'Unavailable form',
|
|
28
|
+
selected: item.key === value,
|
|
29
|
+
})),
|
|
9
30
|
]
|
|
10
|
-
if (value
|
|
11
|
-
|
|
31
|
+
if (!value || libraryForms.some((item) => item.key === value)) return options
|
|
32
|
+
const form = forms.find((candidate) => candidate.key === value)
|
|
33
|
+
options.push(
|
|
34
|
+
form
|
|
35
|
+
? { name: `${form.name} (the form's own words)`, value, group: 'Forms', selected: true }
|
|
36
|
+
: { name: 'Unavailable form', value, selected: true },
|
|
37
|
+
)
|
|
12
38
|
return options
|
|
13
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The form a picked value shows: a Library form's, or the form a page names itself.
|
|
43
|
+
*
|
|
44
|
+
* @param {{ forms?: FormSummary[], libraryForms?: LibraryFormItem[] }} from
|
|
45
|
+
* @param {string | undefined} value
|
|
46
|
+
*/
|
|
47
|
+
export function pickedForm({ forms = [], libraryForms = [] }, value) {
|
|
48
|
+
if (!value) return undefined
|
|
49
|
+
const item = libraryForms.find((candidate) => candidate.key === value)
|
|
50
|
+
const key = item ? item.formKey : value
|
|
51
|
+
const form = forms.find((candidate) => candidate.key === key)
|
|
52
|
+
return form ? { form, library: item } : undefined
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The entries view's Library form filter for one form; empty when it has none.
|
|
57
|
+
*
|
|
58
|
+
* @param {LibraryFormItem[]} libraryForms
|
|
59
|
+
* @param {string} formKey
|
|
60
|
+
*/
|
|
61
|
+
export function entriesLibraryOptions(libraryForms, formKey, selected = '') {
|
|
62
|
+
const own = libraryForms.filter((item) => item.formKey === formKey)
|
|
63
|
+
if (own.length === 0) return []
|
|
64
|
+
return [
|
|
65
|
+
{ name: 'Any Library form', value: '', selected: selected === '' },
|
|
66
|
+
...own.map((item) => ({ name: item.name, value: item.key, selected: item.key === selected })),
|
|
67
|
+
{ name: 'None: the form itself', value: 'none', selected: selected === 'none' },
|
|
68
|
+
]
|
|
69
|
+
}
|
package/plugin/form-picker.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Form Picker property editor.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* It picks a Library form (story 239), the editor's words over a form a
|
|
5
|
+
* developer defined in `schema/forms/`, and stores its key. A page saved before
|
|
6
|
+
* Library forms stores a form's own key, which still renders in that form's
|
|
7
|
+
* own words.
|
|
8
8
|
*/
|
|
9
9
|
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
10
10
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
11
|
-
import { formPickerOptions, NO_FORM_VALUE } from './form-picker-options.js'
|
|
12
|
-
import { listForms, readForm } from './forms-client.js'
|
|
11
|
+
import { formPickerOptions, NO_FORM_VALUE, pickedForm } from './form-picker-options.js'
|
|
12
|
+
import { listForms, listLibraryForms, readForm } from './forms-client.js'
|
|
13
13
|
|
|
14
14
|
export default class CromboloFormPickerElement extends UmbLitElement {
|
|
15
15
|
static properties = {
|
|
@@ -29,10 +29,10 @@ export default class CromboloFormPickerElement extends UmbLitElement {
|
|
|
29
29
|
|
|
30
30
|
connectedCallback() {
|
|
31
31
|
super.connectedCallback()
|
|
32
|
-
listForms().then(
|
|
33
|
-
(
|
|
32
|
+
Promise.all([listForms(), listLibraryForms()]).then(
|
|
33
|
+
([forms, libraryForms]) => {
|
|
34
34
|
this._failed = false
|
|
35
|
-
this._items =
|
|
35
|
+
this._items = { forms, libraryForms }
|
|
36
36
|
},
|
|
37
37
|
() => {
|
|
38
38
|
this._failed = true
|
|
@@ -45,14 +45,16 @@ export default class CromboloFormPickerElement extends UmbLitElement {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async #loadFields() {
|
|
48
|
-
const
|
|
48
|
+
const value = this.value
|
|
49
49
|
this._detail = undefined
|
|
50
|
-
|
|
50
|
+
const picked = this._items && pickedForm(this._items, value)
|
|
51
|
+
if (!picked) return
|
|
52
|
+
const key = picked.form.key
|
|
51
53
|
try {
|
|
52
54
|
const detail = await readForm(key)
|
|
53
|
-
if (this.value ===
|
|
55
|
+
if (this.value === value) this._detail = { key: value, definition: detail.definition }
|
|
54
56
|
} catch {
|
|
55
|
-
if (this.value ===
|
|
57
|
+
if (this.value === value) this._detail = { key: value, failed: true }
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -72,10 +74,14 @@ export default class CromboloFormPickerElement extends UmbLitElement {
|
|
|
72
74
|
render() {
|
|
73
75
|
if (this._failed) return html`<uui-box><p>The list of forms could not be loaded.</p></uui-box>`
|
|
74
76
|
if (this._items === undefined) return html`<uui-loader></uui-loader>`
|
|
75
|
-
if (this._items.length === 0 && !this.value)
|
|
77
|
+
if (this._items.libraryForms.length === 0 && !this.value)
|
|
76
78
|
return html`
|
|
77
79
|
<p class="empty">
|
|
78
|
-
|
|
80
|
+
${
|
|
81
|
+
this._items.forms.length === 0
|
|
82
|
+
? 'This site has no forms yet. A developer adds them in the Forms section.'
|
|
83
|
+
: 'No Library forms yet. Create one in the Library, then pick it here.'
|
|
84
|
+
}
|
|
79
85
|
</p>
|
|
80
86
|
`
|
|
81
87
|
return html`
|
|
@@ -86,7 +92,7 @@ export default class CromboloFormPickerElement extends UmbLitElement {
|
|
|
86
92
|
></uui-select>
|
|
87
93
|
${this.value ? html`<p class="detail">${this.#describe()}</p>` : nothing}
|
|
88
94
|
${
|
|
89
|
-
this._items
|
|
95
|
+
pickedForm(this._items, this.value)
|
|
90
96
|
? html`<details>
|
|
91
97
|
<summary>View form fields</summary>
|
|
92
98
|
${this.#fields()}
|
|
@@ -97,8 +103,11 @@ export default class CromboloFormPickerElement extends UmbLitElement {
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
#describe() {
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
106
|
+
const picked = this._items && pickedForm(this._items, this.value)
|
|
107
|
+
if (!picked) return 'The selected form is no longer available.'
|
|
108
|
+
const { form, library } = picked
|
|
109
|
+
if (library && !library.published)
|
|
110
|
+
return 'Not published yet: the page shows no form until it is.'
|
|
102
111
|
const fields = `${form.fieldCount} field${form.fieldCount === 1 ? '' : 's'}`
|
|
103
112
|
const pages = `${form.pageCount} page${form.pageCount === 1 ? '' : 's'}`
|
|
104
113
|
return `${fields} over ${pages}${form.storeEntries ? '' : '; entries are not stored'}`
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A note in the document-type workspace footer for a type made from a form
|
|
3
|
+
* (story 239): it follows the form, so it is changed there, and saving it here
|
|
4
|
+
* is refused.
|
|
5
|
+
*/
|
|
6
|
+
import { UMB_DOCUMENT_TYPE_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document-type'
|
|
7
|
+
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api'
|
|
8
|
+
import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
9
|
+
import { listLibraryTypes } from './forms-client.js'
|
|
10
|
+
|
|
11
|
+
export default class CromboloFormTypeNoteElement extends UmbElementMixin(LitElement) {
|
|
12
|
+
static properties = { _formName: { state: true } }
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super()
|
|
16
|
+
this._formName = undefined
|
|
17
|
+
this.consumeContext(UMB_DOCUMENT_TYPE_WORKSPACE_CONTEXT, (context) => {
|
|
18
|
+
if (!context) return
|
|
19
|
+
this.observe(context.unique, (unique) => this.#lookUp(unique))
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async #lookUp(unique) {
|
|
24
|
+
this._formName = undefined
|
|
25
|
+
if (!unique) return
|
|
26
|
+
try {
|
|
27
|
+
const made = (await listLibraryTypes()).find((item) => item.typeKey === unique)
|
|
28
|
+
this._formName = made?.formName
|
|
29
|
+
} catch {
|
|
30
|
+
// Without the list there is nothing to say; the server still refuses a save.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
if (!this._formName) return nothing
|
|
36
|
+
return html`<uui-tag
|
|
37
|
+
color="default"
|
|
38
|
+
look="secondary"
|
|
39
|
+
title="This type follows the ${this._formName} form. Change the form in Forms, and this type changes with it."
|
|
40
|
+
>
|
|
41
|
+
Made from the ${this._formName} form: change it in Forms
|
|
42
|
+
</uui-tag>`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static styles = css`
|
|
46
|
+
:host {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
customElements.define('crombolo-form-type-note', CromboloFormTypeNoteElement)
|
package/plugin/forms-client.js
CHANGED
|
@@ -27,6 +27,12 @@ const call = async (path, init) => {
|
|
|
27
27
|
|
|
28
28
|
export const listForms = async () => (await call('')).body.items ?? []
|
|
29
29
|
|
|
30
|
+
/** The content types made from forms (story 239), by key, with each form's name. */
|
|
31
|
+
export const listLibraryTypes = async () => (await call('/library-types')).body.items ?? []
|
|
32
|
+
|
|
33
|
+
/** Every Library form (story 239), with the form each is made from. */
|
|
34
|
+
export const listLibraryForms = async () => (await call('/library-forms')).body.items ?? []
|
|
35
|
+
|
|
30
36
|
/** The field and workflow types this site has, built in and from its bundles. */
|
|
31
37
|
export const listFormTypes = async () => (await call('/available-types')).body
|
|
32
38
|
|
package/plugin/forms-entries.js
CHANGED
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
12
12
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
13
|
+
import { entriesLibraryOptions } from './form-picker-options.js'
|
|
13
14
|
import {
|
|
14
15
|
deleteEntry,
|
|
15
16
|
downloadEntriesCsv,
|
|
16
17
|
listEntries,
|
|
17
18
|
listForms,
|
|
19
|
+
listLibraryForms,
|
|
18
20
|
setEntryState,
|
|
19
21
|
} from './forms-client.js'
|
|
20
22
|
|
|
@@ -22,6 +24,8 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
22
24
|
static properties = {
|
|
23
25
|
_forms: { state: true },
|
|
24
26
|
_selected: { state: true },
|
|
27
|
+
_libraryForms: { state: true },
|
|
28
|
+
_library: { state: true },
|
|
25
29
|
_entries: { state: true },
|
|
26
30
|
_total: { state: true },
|
|
27
31
|
_state: { state: true },
|
|
@@ -34,6 +38,8 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
34
38
|
super()
|
|
35
39
|
this._forms = undefined
|
|
36
40
|
this._selected = ''
|
|
41
|
+
this._libraryForms = []
|
|
42
|
+
this._library = ''
|
|
37
43
|
this._entries = []
|
|
38
44
|
this._total = 0
|
|
39
45
|
this._state = ''
|
|
@@ -44,6 +50,13 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
44
50
|
|
|
45
51
|
connectedCallback() {
|
|
46
52
|
super.connectedCallback()
|
|
53
|
+
// Only for the filter and the names on entries: a failure leaves both out.
|
|
54
|
+
listLibraryForms().then(
|
|
55
|
+
(items) => {
|
|
56
|
+
this._libraryForms = items
|
|
57
|
+
},
|
|
58
|
+
() => {},
|
|
59
|
+
)
|
|
47
60
|
listForms().then(
|
|
48
61
|
(forms) => {
|
|
49
62
|
this._forms = forms
|
|
@@ -62,6 +75,7 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
62
75
|
try {
|
|
63
76
|
const page = await listEntries(this._selected, {
|
|
64
77
|
state: this._state,
|
|
78
|
+
library: this._library,
|
|
65
79
|
search: this._search,
|
|
66
80
|
includeSpam: this._includeSpam ? 'true' : '',
|
|
67
81
|
take: 200,
|
|
@@ -94,6 +108,23 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
|
|
111
|
+
#libraryFilter() {
|
|
112
|
+
const options = entriesLibraryOptions(this._libraryForms, this._selected, this._library)
|
|
113
|
+
if (options.length === 0) return nothing
|
|
114
|
+
return html`<uui-select
|
|
115
|
+
label="Library form"
|
|
116
|
+
.options=${options}
|
|
117
|
+
@change=${(event) => {
|
|
118
|
+
this._library = event.target.value
|
|
119
|
+
this.#load()
|
|
120
|
+
}}
|
|
121
|
+
></uui-select>`
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#libraryName(key) {
|
|
125
|
+
return this._libraryForms.find((item) => item.key === key)?.name ?? 'A deleted Library form'
|
|
126
|
+
}
|
|
127
|
+
|
|
97
128
|
render() {
|
|
98
129
|
if (this._forms === undefined) return html`<uui-loader></uui-loader>`
|
|
99
130
|
if (this._forms.length === 0)
|
|
@@ -111,9 +142,11 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
111
142
|
}))}
|
|
112
143
|
@change=${(event) => {
|
|
113
144
|
this._selected = event.target.value
|
|
145
|
+
this._library = ''
|
|
114
146
|
this.#load()
|
|
115
147
|
}}
|
|
116
148
|
></uui-select>
|
|
149
|
+
${this.#libraryFilter()}
|
|
117
150
|
<uui-select
|
|
118
151
|
label="State"
|
|
119
152
|
.options=${[
|
|
@@ -172,6 +205,11 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
172
205
|
<strong>${new Date(entry.createDate).toLocaleString()}</strong>
|
|
173
206
|
<span class="state">${entry.state}</span>
|
|
174
207
|
${entry.spam ? html`<span class="spam">spam</span>` : nothing}
|
|
208
|
+
${
|
|
209
|
+
entry.libraryKey
|
|
210
|
+
? html`<span class="library">${this.#libraryName(entry.libraryKey)}</span>`
|
|
211
|
+
: nothing
|
|
212
|
+
}
|
|
175
213
|
</div>
|
|
176
214
|
<dl>
|
|
177
215
|
${entry.values.map(
|
|
@@ -223,6 +261,7 @@ export default class CromboloFormsEntriesElement extends UmbLitElement {
|
|
|
223
261
|
align-items: baseline;
|
|
224
262
|
}
|
|
225
263
|
.state,
|
|
264
|
+
.library,
|
|
226
265
|
.spam {
|
|
227
266
|
font-size: var(--uui-type-small-size, 0.8rem);
|
|
228
267
|
text-transform: uppercase;
|
|
@@ -93,7 +93,7 @@ export default class CromboloOverviewDashboardElement extends UmbLitElement {
|
|
|
93
93
|
return html`
|
|
94
94
|
<header>
|
|
95
95
|
<h1>Overview</h1>
|
|
96
|
-
<p>${name ? `Welcome back, ${name}. ` : ''}Here’s what’s happening
|
|
96
|
+
<p>${name ? `Welcome back, ${name}. ` : ''}Here’s what’s happening in Crombolo.</p>
|
|
97
97
|
</header>
|
|
98
98
|
${this._error ? html`<uui-box><p class="error">${this._error}</p></uui-box>` : nothing}
|
|
99
99
|
<div class="grid">
|
|
@@ -102,7 +102,7 @@ export default class CromboloOverviewDashboardElement extends UmbLitElement {
|
|
|
102
102
|
<button class="new" type="button" @click=${() => this.#newPage()}>
|
|
103
103
|
<span>
|
|
104
104
|
<strong>New content</strong>
|
|
105
|
-
<small>
|
|
105
|
+
<small>Create a new page</small>
|
|
106
106
|
</span>
|
|
107
107
|
<uui-icon name="icon-add"></uui-icon>
|
|
108
108
|
</button>
|
|
@@ -176,7 +176,7 @@ export default class CromboloOverviewDashboardElement extends UmbLitElement {
|
|
|
176
176
|
#emptyText() {
|
|
177
177
|
if (this._list === 'drafts') return 'No drafts: every page you can see is published.'
|
|
178
178
|
if (this._list === 'published') return 'Nothing is published yet.'
|
|
179
|
-
return 'No pages yet
|
|
179
|
+
return 'No pages created yet'
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
#renderStats() {
|
|
@@ -212,7 +212,7 @@ export default class CromboloOverviewDashboardElement extends UmbLitElement {
|
|
|
212
212
|
!activity
|
|
213
213
|
? html`<uui-loader></uui-loader>`
|
|
214
214
|
: activity.length === 0
|
|
215
|
-
? html`<p class="empty">
|
|
215
|
+
? html`<p class="empty">No recent activity</p>`
|
|
216
216
|
: html`<ul class="feed">
|
|
217
217
|
${activity.map(
|
|
218
218
|
(a) => html`<li>
|