@crombolo/backoffice-host 0.61.0 → 0.62.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/forms-client.js +7 -0
- package/plugin/forms-overview.js +79 -0
- package/plugin/forms-workflows.js +18 -0
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@crombolo/core": "0.
|
|
36
|
-
"@crombolo/backoffice-dist": "0.
|
|
35
|
+
"@crombolo/core": "0.62.0",
|
|
36
|
+
"@crombolo/backoffice-dist": "0.62.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/plugin/forms-client.js
CHANGED
|
@@ -67,6 +67,13 @@ export const previewChoices = (source) =>
|
|
|
67
67
|
/** Every dictionary item, with its words in the default language. */
|
|
68
68
|
export const listWords = async () => (await call('/words')).body.words ?? []
|
|
69
69
|
|
|
70
|
+
/** Sets a send-to-URL workflow's secret header (story 304), or with no value removes it. */
|
|
71
|
+
export const setSecretHeader = (form, workflow, header, value) =>
|
|
72
|
+
call(
|
|
73
|
+
`/${encodeURIComponent(form)}/workflows/${encodeURIComponent(workflow)}/secrets/${encodeURIComponent(header)}`,
|
|
74
|
+
value === undefined ? { method: 'DELETE' } : { method: 'PUT', body: JSON.stringify({ value }) },
|
|
75
|
+
)
|
|
76
|
+
|
|
70
77
|
export const deleteForm = (key) => call(`/${encodeURIComponent(key)}`, { method: 'DELETE' })
|
|
71
78
|
|
|
72
79
|
export const listEntries = async (key, query = {}) => {
|
package/plugin/forms-overview.js
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
previewChoices,
|
|
30
30
|
readForm,
|
|
31
31
|
saveForm,
|
|
32
|
+
setSecretHeader,
|
|
32
33
|
} from './forms-client.js'
|
|
33
34
|
import {
|
|
34
35
|
addGroup,
|
|
@@ -52,6 +53,8 @@ import {
|
|
|
52
53
|
addWorkflow,
|
|
53
54
|
describeProblemPath,
|
|
54
55
|
removeWorkflow,
|
|
56
|
+
secretHeaderNames,
|
|
57
|
+
setSecretHeaderName,
|
|
55
58
|
setWorkflowName,
|
|
56
59
|
setWorkflowSetting,
|
|
57
60
|
setWorkflowTrigger,
|
|
@@ -99,6 +102,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
99
102
|
_types: { state: true },
|
|
100
103
|
_workflowTypes: { state: true },
|
|
101
104
|
_designs: { state: true },
|
|
105
|
+
_secrets: { state: true },
|
|
102
106
|
_because: { state: true },
|
|
103
107
|
_tab: { state: true },
|
|
104
108
|
}
|
|
@@ -183,6 +187,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
183
187
|
this._tab = 'design'
|
|
184
188
|
const detail = await readForm(key)
|
|
185
189
|
this._editing = withLayout(detail.definition)
|
|
190
|
+
this._secrets = detail.secrets ?? []
|
|
186
191
|
this._choices = new Map()
|
|
187
192
|
for (const field of this.#fields) if (field.source) this.#preview(field)
|
|
188
193
|
}
|
|
@@ -792,9 +797,73 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
792
797
|
${hint}
|
|
793
798
|
</label>`
|
|
794
799
|
})}
|
|
800
|
+
${workflow.type === 'sendToUrl' ? this.#secretHeaders(workflow, index) : nothing}
|
|
795
801
|
</div>`
|
|
796
802
|
}
|
|
797
803
|
|
|
804
|
+
/** Headers kept sealed on the site and sent only to the address they were set for (story 304). */
|
|
805
|
+
#secretHeaders(workflow, index) {
|
|
806
|
+
const names = secretHeaderNames(workflow)
|
|
807
|
+
return html`<div class="secret-headers">
|
|
808
|
+
<span>Secret headers</span>
|
|
809
|
+
<small class="offered">For a key or token the address needs. Kept on this site, never shown again, and sent only to the address above: change the address and set them again.</small>
|
|
810
|
+
${names.map((name) => {
|
|
811
|
+
const saved = (this._secrets ?? []).find(
|
|
812
|
+
(secret) => secret.workflow === workflow.key && secret.header === name,
|
|
813
|
+
)
|
|
814
|
+
return html`<div class="secret-header">
|
|
815
|
+
<code>${name}</code>
|
|
816
|
+
<span>${saved ? (saved.set ? 'Set' : 'Not set') : 'Save the form, then set it'}</span>
|
|
817
|
+
${
|
|
818
|
+
saved
|
|
819
|
+
? html`<uui-input
|
|
820
|
+
type="password"
|
|
821
|
+
label=${`A value for ${name}`}
|
|
822
|
+
placeholder=${saved.set ? 'Replace it' : 'Its value'}
|
|
823
|
+
@change=${(event) => this.#setSecret(workflow, name, event.target.value)}
|
|
824
|
+
></uui-input>`
|
|
825
|
+
: nothing
|
|
826
|
+
}
|
|
827
|
+
${
|
|
828
|
+
saved?.set
|
|
829
|
+
? html`<uui-button compact look="secondary" label="Clear"
|
|
830
|
+
@click=${() => this.#setSecret(workflow, name, undefined)}></uui-button>`
|
|
831
|
+
: nothing
|
|
832
|
+
}
|
|
833
|
+
<uui-button compact look="secondary" color="danger" label=${`Stop sending ${name}`}
|
|
834
|
+
@click=${() => this.#apply(setSecretHeaderName, index, name, false)}></uui-button>
|
|
835
|
+
</div>`
|
|
836
|
+
})}
|
|
837
|
+
<uui-input
|
|
838
|
+
label="Add a secret header"
|
|
839
|
+
placeholder="Its name, such as Authorization"
|
|
840
|
+
@change=${(event) => {
|
|
841
|
+
const name = event.target.value.trim()
|
|
842
|
+
if (!name) return
|
|
843
|
+
this.#apply(setSecretHeaderName, index, name, true)
|
|
844
|
+
event.target.value = ''
|
|
845
|
+
}}
|
|
846
|
+
></uui-input>
|
|
847
|
+
</div>`
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
async #setSecret(workflow, header, value) {
|
|
851
|
+
if (value === '') return
|
|
852
|
+
try {
|
|
853
|
+
const result = await setSecretHeader(this._editing.key, workflow.key, header, value)
|
|
854
|
+
if (!result.ok) {
|
|
855
|
+
this._notice = result.body.message ?? 'That header could not be set.'
|
|
856
|
+
return
|
|
857
|
+
}
|
|
858
|
+
this.#notifications?.peek('positive', {
|
|
859
|
+
data: { message: value === undefined ? `${header} cleared` : `${header} set` },
|
|
860
|
+
})
|
|
861
|
+
this._secrets = (await readForm(this._editing.key)).secrets ?? []
|
|
862
|
+
} catch (error) {
|
|
863
|
+
this._notice = error.message
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
798
867
|
#touch() {
|
|
799
868
|
// Lit tracks the reference, not what is inside it.
|
|
800
869
|
this._editing = { ...this._editing }
|
|
@@ -1120,6 +1189,16 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
1120
1189
|
gap: var(--uui-size-space-3, 9px);
|
|
1121
1190
|
max-width: 60ch;
|
|
1122
1191
|
}
|
|
1192
|
+
.secret-headers {
|
|
1193
|
+
display: grid;
|
|
1194
|
+
gap: var(--uui-size-space-2, 6px);
|
|
1195
|
+
}
|
|
1196
|
+
.secret-header {
|
|
1197
|
+
display: flex;
|
|
1198
|
+
flex-wrap: wrap;
|
|
1199
|
+
align-items: center;
|
|
1200
|
+
gap: var(--uui-size-space-3, 9px);
|
|
1201
|
+
}
|
|
1123
1202
|
.workflow-settings label,
|
|
1124
1203
|
.workflow-settings .switch {
|
|
1125
1204
|
display: grid;
|
|
@@ -145,3 +145,21 @@ export function describeProblemPath(form, path, types = new Map()) {
|
|
|
145
145
|
)
|
|
146
146
|
return `${name}: ${setting?.label ?? FILE_ONLY_LABELS[found[2]] ?? found[2]}`
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
/** The headers a send-to-URL workflow keeps sealed on the site (story 304). */
|
|
150
|
+
export const secretHeaderNames = (workflow) =>
|
|
151
|
+
Object.entries(workflow.settings?.headers ?? {})
|
|
152
|
+
.filter(([, value]) => value && typeof value === 'object' && value.secret === true)
|
|
153
|
+
.map(([name]) => name)
|
|
154
|
+
|
|
155
|
+
/** Names a header as secret, or with `secret` false takes it out. */
|
|
156
|
+
export const setSecretHeaderName = (form, index, name, secret) =>
|
|
157
|
+
replace(form, index, (workflow) => {
|
|
158
|
+
const headers = { ...(workflow.settings?.headers ?? {}) }
|
|
159
|
+
if (secret) headers[name] = { secret: true }
|
|
160
|
+
else delete headers[name]
|
|
161
|
+
const settings = { ...workflow.settings }
|
|
162
|
+
if (Object.keys(headers).length > 0) settings.headers = headers
|
|
163
|
+
else delete settings.headers
|
|
164
|
+
return { settings }
|
|
165
|
+
})
|