@crombolo/simple-redirects 0.59.0 → 0.61.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 +6 -7
- package/provenance.json +40 -34
- package/src/server/index.ts +264 -4
- package/src/backoffice/redirects-client.js +0 -41
- package/src/backoffice/redirects-workspace.js +0 -481
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/simple-redirects",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
4
|
"description": "Manage redirects in the Crombolo backoffice: a Settings screen over the redirect engine in core.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"id": "redirects",
|
|
41
41
|
"name": "Redirects",
|
|
42
42
|
"server": "redirects",
|
|
43
|
-
"schemaVersion":
|
|
43
|
+
"schemaVersion": 6,
|
|
44
44
|
"settings": {
|
|
45
45
|
"section": {
|
|
46
46
|
"label": "Where redirects are managed",
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"permissions": {
|
|
56
|
-
"backoffice.code": "Shows the redirects screen in Settings",
|
|
57
56
|
"redirects.read": "Lists the redirect rules on the Redirects screen",
|
|
58
57
|
"redirects.write": "Saves the rules you add, change and remove there",
|
|
59
58
|
"content.read": "Shows the address of the page each rule sends people to"
|
|
@@ -78,17 +77,17 @@
|
|
|
78
77
|
"type": "workspace",
|
|
79
78
|
"alias": "Crombolo.Workspace.Redirects",
|
|
80
79
|
"name": "Redirects Workspace",
|
|
81
|
-
"element": "src/backoffice/redirects-workspace.js",
|
|
82
80
|
"meta": {
|
|
83
81
|
"entityType": "crombolo-redirects"
|
|
84
|
-
}
|
|
82
|
+
},
|
|
83
|
+
"screen": "rules"
|
|
85
84
|
}
|
|
86
85
|
]
|
|
87
86
|
},
|
|
88
87
|
"peerDependencies": {
|
|
89
|
-
"@crombolo/crombolo": ">=0.
|
|
88
|
+
"@crombolo/crombolo": ">=0.61.0"
|
|
90
89
|
},
|
|
91
90
|
"dependencies": {
|
|
92
|
-
"@crombolo/extension": "0.
|
|
91
|
+
"@crombolo/extension": "0.61.0"
|
|
93
92
|
}
|
|
94
93
|
}
|
package/provenance.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
|
-
"digest": "sha256-
|
|
3
|
+
"digest": "sha256-7ef64c01ac03b5cbcbec56663e3f94d4163100e9325144591af328618e83db7f",
|
|
4
4
|
"signature": {
|
|
5
5
|
"mediaType": "application/vnd.dev.sigstore.bundle.v0.3+json",
|
|
6
6
|
"verificationMaterial": {
|
|
7
7
|
"certificate": {
|
|
8
|
-
"rawBytes": "
|
|
8
|
+
"rawBytes": "MIIHBjCCBoygAwIBAgIUAfVjhPTyklehI022k2RxVVAjda0wCgYIKoZIzj0EAwMwNzEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MR4wHAYDVQQDExVzaWdzdG9yZS1pbnRlcm1lZGlhdGUwHhcNMjYxMTExMDk0OTA1WhcNMjYxMTExMDk1OTA1WjAAMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE/qxBkDYltu8PeZofUoI/qWZ1uSVhNpxePbgFzdb+4ErAVnOg7o+ScTzSARRe7L3+O4dpZVkdVfy+/sxvJC9WaqOCBaswggWnMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAfBgNVHSMEGDAWgBTf0+nPViQRlvmo2OkoVaLGLhhkPzBnBgNVHREBAf8EXTBbhllodHRwczovL2dpdGh1Yi5jb20va2luZWNvLWF1L2Nyb21ib2xvLWNtcy8uZ2l0aHViL3dvcmtmbG93cy9yZWxlYXNlLnltbEByZWZzL3RhZ3MvdjAuNjEuMDA5BgorBgEEAYO/MAEBBCtodHRwczovL3Rva2VuLmFjdGlvbnMu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S4wMDgGCisGAQQBg78wARMEKgwoMmZkMzgzMWFkOTQ5Y2UxYWFlNGRlZGE2MWIwMzllMzNmYmVkZmY4YjAUBgorBgEEAYO/MAEUBAYMBHB1c2gwXQYKKwYBBAGDvzABFQRPDE1odHRwczovL2dpdGh1Yi5jb20va2luZWNvLWF1L2Nyb21ib2xvLWNtcy9hY3Rpb25zL3J1bnMvNDI5OTM1ODUwMTUvYXR0ZW1wdHMvMTAWBgorBgEEAYO/MAEWBAgMBnB1YmxpYzBVBgorBgEEAYO/MAEYBEcMRXJlcG86a2luZWNvLWF1QDcwMTI3MDQ3L2Nyb21ib2xvLWNtc0AxNDAxNjA1ODY0OnJlZjpyZWZzL3RhZ3MvdjAuNjEuMDCBigYKKwYBBAHWeQIEAgR8BHoAeAB2AN09MGrGxxEyYxkeHJlnNwKiSl643jyt/4eKcoAvKe6OAAABocoC0x0AAAQDAEcwRQIgcZsnOX09ExmBrDGDfFSOshlLd6FXLvOn1xGnA5T8tcsCIQCAoO0COhzpqSSgBEnAAZuj1OxQLoesJqymMwvfNEpTNzAKBggqhkjOPQQDAwNoADBlAjBrYmLJYlxYLcdfEmzbIi31X1zFW/N5foALx0H0z+X7NFmmAMAC4QAfJ9w9rvjXZicCMQDSpjQln2CvPdOuGujDsuuTegGETipMxkaQ8PfaMPyUK3hUQuvrUeM6BjDHV4usxbI="
|
|
9
9
|
},
|
|
10
10
|
"tlogEntries": [
|
|
11
11
|
{
|
|
12
|
-
"logIndex": "
|
|
12
|
+
"logIndex": "3807419372",
|
|
13
13
|
"logId": {
|
|
14
14
|
"keyId": "wNI9atQGlz+VWfO6LRygH4QUfY/8W4RFwiT5i5WRgB0="
|
|
15
15
|
},
|
|
@@ -17,29 +17,35 @@
|
|
|
17
17
|
"kind": "dsse",
|
|
18
18
|
"version": "0.0.1"
|
|
19
19
|
},
|
|
20
|
-
"integratedTime": "
|
|
20
|
+
"integratedTime": "1794390545",
|
|
21
21
|
"inclusionPromise": {
|
|
22
|
-
"signedEntryTimestamp": "
|
|
22
|
+
"signedEntryTimestamp": "MEYCIQDEQev/4wWTRVhC+QcScOZ6lKqd18lGKocV7bcYpLYnYAIhALLfhMdaENrxOHvBrbZ931/nvS7OiQ2coTBEK3VCtXFr"
|
|
23
23
|
},
|
|
24
24
|
"inclusionProof": {
|
|
25
|
-
"logIndex": "
|
|
26
|
-
"rootHash": "
|
|
27
|
-
"treeSize": "
|
|
25
|
+
"logIndex": "3685515110",
|
|
26
|
+
"rootHash": "gSTXpfRtG7gxXhfmY2h0ud/w1KQV10AjSy92qNytumE=",
|
|
27
|
+
"treeSize": "3685515143",
|
|
28
28
|
"hashes": [
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
29
|
+
"Oz1vYvf1+xt/jYq/8z42Ow5xW85LhPwYo5XWhnMrLRk=",
|
|
30
|
+
"5VG8QDIM3HtWjTfVsCCDcvkY0wN32VMW2YUPzH8IxbI=",
|
|
31
|
+
"x220I4U7CVbUWLZDlWyjgMTkcXhGVxMEN73rAirA+qc=",
|
|
32
|
+
"KGubmjBblqM3HzAudftXbi+LE+V6VeGQUYEuC9heORE=",
|
|
33
|
+
"Srkwjfv4Kdfq0m0DA85A2dIxGJtGwvtvf2qIt3b20Bk=",
|
|
34
|
+
"wV4CD18agthFJ/hpNNBdwZFkjYXTCqgTuff1O7oFWqs=",
|
|
35
|
+
"PYrdRUnEjxQGIWBbH+kpIKN97vywj+ZHR0RCVRLORls=",
|
|
36
|
+
"bH+T7JhbUeqZUHsvECfmrs3jtLybIeDJGMwHmyCycj8=",
|
|
37
|
+
"YXAAZqHEn6Jpm3mBfDSjUJSxn5Yefwzu9nIQhpcA9qs=",
|
|
38
|
+
"xfInr4a6f9tApNR51TzmhWFpBUBkj7elWS9oaC/SUcs=",
|
|
39
|
+
"g2REAX1fug6SNL9njXU9s5o3GQ9Yx/ykgHA5Z2h/uR8=",
|
|
40
|
+
"lMFaO3aufpPRYyeZL+NxBwSA66c4vIfG4mYIRiW+ItU=",
|
|
41
|
+
"q67v331MUyzPxzNZW+wSNH5e0x80dvqHWrbfv1b3oAw=",
|
|
42
|
+
"rKAbgC0pXL/Jya45WGhnQB7LGXbwFX6nuUY1M68LcX4=",
|
|
43
|
+
"AuheGyzV3nGmUQm1M8fer7kM88sTi/wFbU3UmmD8Ejc=",
|
|
44
|
+
"KfBNdq4/yNJ1Gj74Pm1QCvw/VXX5fzLaq60P/ddRlRM=",
|
|
45
|
+
"CRRHvFmEh8BhdGCm5/tFEztQv2qy+rjCtY5OO8AijUU=",
|
|
46
|
+
"KT/mQERVdYE+E92Ny7JwdTI0eSfhX58eh09t56HQgM4=",
|
|
47
|
+
"Fi+BO6OXYoidtnICrZZRGVe4C0Do3dzZvsR7arPlpFc=",
|
|
48
|
+
"vIhOJ6KiGvig/14xSGhs6CC3a76vmTsrJ9v2cgfvvls=",
|
|
43
49
|
"5aDKaREuMwcynRhLn5m/9b0QE9pxbeQInhCcIC+n5YQ=",
|
|
44
50
|
"XPex1okR3Qf1VhXr/LVSojah9cB4R1RgvK/mRrmdWLY=",
|
|
45
51
|
"SlixnS34BhAO+yRI2FaGPSOh9V6JSVNPfLl1bHxrcQY=",
|
|
@@ -47,20 +53,20 @@
|
|
|
47
53
|
"xH/DCseLHr9eKoYT8qsORZK7zVdEGYWHuVtsVrD95wY="
|
|
48
54
|
],
|
|
49
55
|
"checkpoint": {
|
|
50
|
-
"envelope": "rekor.sigstore.dev - 1193050959916656506\
|
|
56
|
+
"envelope": "rekor.sigstore.dev - 1193050959916656506\n3685515143\ngSTXpfRtG7gxXhfmY2h0ud/w1KQV10AjSy92qNytumE=\n\n— rekor.sigstore.dev wNI9ajBGAiEAgFTnH5NgPKwtFQt7538hqlO6YCqao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0ZW1lbnQvdjEiLCJzdWJqZWN0IjpbeyJuYW1lIjoiY3JvbWJvbG8tYnVuZGxlIiwiZGlnZXN0Ijp7InNoYTI1NiI6IjdlZjY0YzAxYWMwM2I1Y2JjYmVjNTY2NjNlM2Y5NGQ0MTYzMTAwZTkzMjUxNDQ1OTFhZjMyODYxOGU4M2RiN2YifX1dLCJwcmVkaWNhdGVUeXBlIjoiaHR0cHM6Ly9jcm9tYm9sby5kZXYvYnVuZGxlLXByb3ZlbmFuY2UvdjEiLCJwcmVkaWNhdGUiOnsiZm9ybWF0IjoxfX0=",
|
|
60
66
|
"payloadType": "application/vnd.in-toto+json",
|
|
61
67
|
"signatures": [
|
|
62
68
|
{
|
|
63
|
-
"sig": "
|
|
69
|
+
"sig": "MEUCIB5FUInv3nIk3HKQMzq8CuvVBt2x/JGXztikbAXtsiCrAiEA7wPSQ7vNuyIHX4Mg4jgBlmo+puI3Ea1Zw1XUPUyxzr8="
|
|
64
70
|
}
|
|
65
71
|
]
|
|
66
72
|
}
|
|
@@ -68,15 +74,15 @@
|
|
|
68
74
|
"source": {
|
|
69
75
|
"issuer": "https://token.actions.githubusercontent.com",
|
|
70
76
|
"repository": "kineco-au/crombolo-cms",
|
|
71
|
-
"ref": "refs/tags/v0.
|
|
72
|
-
"commit": "
|
|
73
|
-
"workflow": "https://github.com/kineco-au/crombolo-cms/.github/workflows/release.yml@refs/tags/v0.
|
|
74
|
-
"run": "https://github.com/kineco-au/crombolo-cms/actions/runs/
|
|
77
|
+
"ref": "refs/tags/v0.61.0",
|
|
78
|
+
"commit": "2fd3831ad949ce1aae4deda61b039e33fbedff8b",
|
|
79
|
+
"workflow": "https://github.com/kineco-au/crombolo-cms/.github/workflows/release.yml@refs/tags/v0.61.0",
|
|
80
|
+
"run": "https://github.com/kineco-au/crombolo-cms/actions/runs/42993585015/attempts/1"
|
|
75
81
|
},
|
|
76
82
|
"links": {
|
|
77
|
-
"commit": "https://github.com/kineco-au/crombolo-cms/commit/
|
|
78
|
-
"tag": "https://github.com/kineco-au/crombolo-cms/releases/tag/v0.
|
|
79
|
-
"run": "https://github.com/kineco-au/crombolo-cms/actions/runs/
|
|
80
|
-
"log": "https://search.sigstore.dev/?logIndex=
|
|
83
|
+
"commit": "https://github.com/kineco-au/crombolo-cms/commit/2fd3831ad949ce1aae4deda61b039e33fbedff8b",
|
|
84
|
+
"tag": "https://github.com/kineco-au/crombolo-cms/releases/tag/v0.61.0",
|
|
85
|
+
"run": "https://github.com/kineco-au/crombolo-cms/actions/runs/42993585015/attempts/1",
|
|
86
|
+
"log": "https://search.sigstore.dev/?logIndex=3807419372"
|
|
81
87
|
}
|
|
82
88
|
}
|
package/src/server/index.ts
CHANGED
|
@@ -8,17 +8,31 @@
|
|
|
8
8
|
* rename records or the site's config declares already work without this bundle.
|
|
9
9
|
* What this adds is the third kind: a rule somebody typed, stored as `manual`.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `docs/bundles.md` for why that asymmetry is the whole security story.
|
|
11
|
+
* Its screen is described, not shipped (stories 323, 329): `screens.rules`
|
|
12
|
+
* answers the table, the filter and the editor as data, and the back office
|
|
13
|
+
* draws them, so no code of this package runs in the page.
|
|
15
14
|
*/
|
|
16
15
|
import {
|
|
17
16
|
type BundleRedirectInput,
|
|
18
17
|
type BundleRouteContext,
|
|
18
|
+
type BundleScreenContext,
|
|
19
19
|
type BundleSection,
|
|
20
|
+
button,
|
|
21
|
+
type Cell,
|
|
22
|
+
cell,
|
|
23
|
+
empty,
|
|
24
|
+
field,
|
|
25
|
+
form,
|
|
26
|
+
problem,
|
|
27
|
+
type Row,
|
|
20
28
|
route,
|
|
29
|
+
row,
|
|
30
|
+
type Screen,
|
|
31
|
+
type ScreenResult,
|
|
21
32
|
type ServerBundle,
|
|
33
|
+
screen,
|
|
34
|
+
search,
|
|
35
|
+
table,
|
|
22
36
|
} from '@crombolo/extension'
|
|
23
37
|
import manifest from '../../package.json' with { type: 'json' }
|
|
24
38
|
|
|
@@ -92,6 +106,251 @@ async function present(
|
|
|
92
106
|
}
|
|
93
107
|
}
|
|
94
108
|
|
|
109
|
+
const MATCH_KINDS = [
|
|
110
|
+
{ value: 'exact', label: 'Exactly this URL' },
|
|
111
|
+
{ value: 'prefix', label: 'This URL and everything below it' },
|
|
112
|
+
{ value: 'regex', label: 'A regular expression' },
|
|
113
|
+
]
|
|
114
|
+
const TARGET_KINDS = [
|
|
115
|
+
{ value: 'document', label: 'A page on this site' },
|
|
116
|
+
{ value: 'path', label: 'A path on this site' },
|
|
117
|
+
{ value: 'url', label: 'Another site' },
|
|
118
|
+
]
|
|
119
|
+
const STATUS_CODES = [
|
|
120
|
+
{ value: '301', label: '301 — moved permanently' },
|
|
121
|
+
{ value: '302', label: '302 — found, temporarily' },
|
|
122
|
+
{ value: '307', label: '307 — temporary, keeping the method' },
|
|
123
|
+
{ value: '308', label: '308 — permanent, keeping the method' },
|
|
124
|
+
]
|
|
125
|
+
const SOURCES: Record<string, { label: string; look: 'primary' | 'secondary' | 'default' }> = {
|
|
126
|
+
manual: { label: 'Added here', look: 'primary' },
|
|
127
|
+
config: { label: 'In configuration', look: 'secondary' },
|
|
128
|
+
tracked: { label: 'From a rename', look: 'default' },
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
type Presented = NonNullable<Awaited<ReturnType<typeof present>>>
|
|
132
|
+
|
|
133
|
+
/** What the screen keeps between calls: the search, and the rule open in the editor. */
|
|
134
|
+
interface RulesState {
|
|
135
|
+
query?: string
|
|
136
|
+
editing?: { key?: string; values: Record<string, unknown> }
|
|
137
|
+
problem?: string
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** What a visitor would have typed: the pattern and how it matches. */
|
|
141
|
+
const fromOf = (rule: Presented) =>
|
|
142
|
+
rule.matchKind === 'prefix'
|
|
143
|
+
? `${rule.pattern === '/' ? '' : rule.pattern}/*`
|
|
144
|
+
: rule.matchKind === 'regex'
|
|
145
|
+
? `/${rule.pattern}/`
|
|
146
|
+
: rule.pattern
|
|
147
|
+
|
|
148
|
+
const toOf = (rule: Presented) =>
|
|
149
|
+
rule.targetKind === 'document'
|
|
150
|
+
? rule.destinationUrl || 'a page that is not published'
|
|
151
|
+
: rule.target
|
|
152
|
+
|
|
153
|
+
const BLANK = {
|
|
154
|
+
matchKind: 'exact',
|
|
155
|
+
pattern: '',
|
|
156
|
+
targetKind: 'document',
|
|
157
|
+
page: '',
|
|
158
|
+
target: '',
|
|
159
|
+
statusCode: '301',
|
|
160
|
+
culture: '',
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** A rule as the editor's values: its target in the page field or the text field. */
|
|
164
|
+
const valuesOf = (rule: Presented) => ({
|
|
165
|
+
matchKind: rule.matchKind,
|
|
166
|
+
pattern: rule.pattern,
|
|
167
|
+
targetKind: rule.targetKind,
|
|
168
|
+
page: rule.targetKind === 'document' ? rule.target : '',
|
|
169
|
+
target: rule.targetKind === 'document' ? '' : rule.target,
|
|
170
|
+
statusCode: String(rule.statusCode),
|
|
171
|
+
culture: rule.culture ?? '',
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
/** The editor's values as the capability takes them. */
|
|
175
|
+
const inputOf = (values: Record<string, unknown>): BundleRedirectInput =>
|
|
176
|
+
readInput({
|
|
177
|
+
...values,
|
|
178
|
+
target: values.targetKind === 'document' ? values.page : values.target,
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
const editor = (editing: NonNullable<RulesState['editing']>) =>
|
|
182
|
+
form(
|
|
183
|
+
[
|
|
184
|
+
field.choice('matchKind', 'Match', MATCH_KINDS),
|
|
185
|
+
field.text('pattern', 'Redirect from', {
|
|
186
|
+
required: true,
|
|
187
|
+
placeholder: '/old-page',
|
|
188
|
+
hints: [
|
|
189
|
+
{
|
|
190
|
+
when: { field: 'matchKind', equals: 'regex' },
|
|
191
|
+
text: 'Captures are available in the target as $1 to $9.',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
when: { field: 'matchKind', equals: 'prefix' },
|
|
195
|
+
text: 'Everything below this path is matched; the remainder is available as $1.',
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
}),
|
|
199
|
+
field.choice('targetKind', 'Redirect to', TARGET_KINDS),
|
|
200
|
+
field.page('page', 'Page', {
|
|
201
|
+
required: true,
|
|
202
|
+
visibleWhen: { field: 'targetKind', equals: 'document' },
|
|
203
|
+
hint: 'A page keeps working as a target when it is renamed or moved, because the rule names the page rather than its URL.',
|
|
204
|
+
}),
|
|
205
|
+
field.text('target', 'Path or URL', {
|
|
206
|
+
required: true,
|
|
207
|
+
placeholder: '/new-page',
|
|
208
|
+
visibleWhen: { field: 'targetKind', oneOf: ['path', 'url'] },
|
|
209
|
+
}),
|
|
210
|
+
field.choice('statusCode', 'Status code', STATUS_CODES),
|
|
211
|
+
field.text('culture', 'Culture', {
|
|
212
|
+
placeholder: 'Every culture',
|
|
213
|
+
hint: 'Leave this empty to redirect whichever language the URL resolved in.',
|
|
214
|
+
}),
|
|
215
|
+
],
|
|
216
|
+
{ ...BLANK, ...editing.values } as never,
|
|
217
|
+
[
|
|
218
|
+
button(editing.key ? 'Save' : 'Add redirect', 'save', { submit: true, look: 'primary' }),
|
|
219
|
+
button('Cancel', 'cancel'),
|
|
220
|
+
],
|
|
221
|
+
{ title: editing.key ? 'Edit redirect' : 'Add a redirect' },
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
/** The rule's row: what it is, where it goes, and Edit and Delete where it may be changed here. */
|
|
225
|
+
const ruleRow = (rule: Presented): Row => {
|
|
226
|
+
const source = SOURCES[rule.source] ?? { label: rule.source, look: 'default' as const }
|
|
227
|
+
const cells: Cell[] = [
|
|
228
|
+
cell.code(fromOf(rule)),
|
|
229
|
+
cell.code(rule.culture ? `${toOf(rule)} (${rule.culture})` : toOf(rule)),
|
|
230
|
+
cell.text(String(rule.statusCode)),
|
|
231
|
+
cell.tag(source.label, source.look),
|
|
232
|
+
]
|
|
233
|
+
return row(
|
|
234
|
+
rule.key,
|
|
235
|
+
cells,
|
|
236
|
+
rule.editable
|
|
237
|
+
? [
|
|
238
|
+
button('Edit', 'edit', { input: { key: rule.key } }),
|
|
239
|
+
button('Delete', 'remove', {
|
|
240
|
+
input: { key: rule.key },
|
|
241
|
+
look: 'danger',
|
|
242
|
+
confirm: `Delete the redirect from ${fromOf(rule)}?`,
|
|
243
|
+
}),
|
|
244
|
+
]
|
|
245
|
+
: [],
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** The whole screen, for a state. */
|
|
250
|
+
async function rulesScreen(host: Host, state: RulesState): Promise<Screen> {
|
|
251
|
+
const result = await host.redirects.list({ filter: state.query || undefined, skip: 0, take: 500 })
|
|
252
|
+
const rules = (
|
|
253
|
+
await Promise.all(result.items.map((rule) => present(rule, host.documents)))
|
|
254
|
+
).filter((rule): rule is Presented => rule !== undefined)
|
|
255
|
+
return screen(
|
|
256
|
+
'Redirects',
|
|
257
|
+
[
|
|
258
|
+
...(state.problem ? [problem(state.problem)] : []),
|
|
259
|
+
...(state.editing ? [editor(state.editing)] : []),
|
|
260
|
+
rules.length === 0
|
|
261
|
+
? empty(state.query ? 'No redirect matches' : 'No redirects yet', {
|
|
262
|
+
text: state.query
|
|
263
|
+
? 'Nothing redirects from or to that.'
|
|
264
|
+
: 'Nothing redirects on this site. Add a rule here, or rename a published page, which records one by itself so the old URL keeps working.',
|
|
265
|
+
})
|
|
266
|
+
: table(['From', 'To', 'Status', 'Source'], rules.map(ruleRow)),
|
|
267
|
+
],
|
|
268
|
+
{
|
|
269
|
+
toolbar: [
|
|
270
|
+
search('find', { placeholder: 'Search either URL', value: state.query ?? '' }),
|
|
271
|
+
button('Add redirect', 'add', { look: 'primary' }),
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
type RulesContext = BundleScreenContext<Capability>
|
|
278
|
+
|
|
279
|
+
const answer = async (
|
|
280
|
+
context: RulesContext,
|
|
281
|
+
state: RulesState,
|
|
282
|
+
notice?: string,
|
|
283
|
+
): Promise<ScreenResult> => ({
|
|
284
|
+
screen: await rulesScreen(context.bundle as Host, state),
|
|
285
|
+
state: { query: state.query, editing: state.editing } as Record<string, unknown>,
|
|
286
|
+
...(notice ? { notice } : {}),
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
const stateOf = (context: RulesContext): RulesState => context.state as RulesState
|
|
290
|
+
|
|
291
|
+
/** The Redirects screen (story 329): the table, the filter and the editor, as data. */
|
|
292
|
+
const rulesScreenHandlers = {
|
|
293
|
+
view: (context: RulesContext) => answer(context, stateOf(context)),
|
|
294
|
+
actions: {
|
|
295
|
+
find: (context: RulesContext) =>
|
|
296
|
+
answer(context, { ...stateOf(context), query: String(context.input.query ?? '') }),
|
|
297
|
+
add: (context: RulesContext) =>
|
|
298
|
+
answer(context, { ...stateOf(context), editing: { values: { ...BLANK } } }),
|
|
299
|
+
cancel: (context: RulesContext) => answer(context, { query: stateOf(context).query }),
|
|
300
|
+
async edit(context: RulesContext) {
|
|
301
|
+
const bundle = context.bundle as Host
|
|
302
|
+
const rule = await present(
|
|
303
|
+
await bundle.redirects.byKey(String(context.input.key ?? '')),
|
|
304
|
+
bundle.documents,
|
|
305
|
+
)
|
|
306
|
+
if (!rule)
|
|
307
|
+
return answer(context, { ...stateOf(context), problem: 'That redirect no longer exists.' })
|
|
308
|
+
return answer(context, {
|
|
309
|
+
query: stateOf(context).query,
|
|
310
|
+
editing: { key: rule.key, values: valuesOf(rule) },
|
|
311
|
+
})
|
|
312
|
+
},
|
|
313
|
+
async save(context: RulesContext) {
|
|
314
|
+
const bundle = context.bundle as Host
|
|
315
|
+
const state = stateOf(context)
|
|
316
|
+
const values = (context.input.values ?? {}) as Record<string, unknown>
|
|
317
|
+
const key = state.editing?.key
|
|
318
|
+
const outcome = key
|
|
319
|
+
? await bundle.redirects.replace(key, inputOf(values))
|
|
320
|
+
: await bundle.redirects.save(inputOf(values))
|
|
321
|
+
// A refusal keeps the editor open with what was typed, and says why above it.
|
|
322
|
+
if (!outcome.ok)
|
|
323
|
+
return answer(context, {
|
|
324
|
+
query: state.query,
|
|
325
|
+
editing: { ...(key ? { key } : {}), values },
|
|
326
|
+
problem: outcome.message,
|
|
327
|
+
})
|
|
328
|
+
bundle.log.info('{user} {action} the redirect {pattern} -> {target}', {
|
|
329
|
+
user: context.principal?.email,
|
|
330
|
+
action: key ? 'changed' : 'added',
|
|
331
|
+
pattern: outcome.rule.pattern,
|
|
332
|
+
target: outcome.rule.target,
|
|
333
|
+
})
|
|
334
|
+
return answer(context, { query: state.query }, key ? 'Redirect updated.' : 'Redirect added.')
|
|
335
|
+
},
|
|
336
|
+
async remove(context: RulesContext) {
|
|
337
|
+
const bundle = context.bundle as Host
|
|
338
|
+
const outcome = await bundle.redirects.remove(String(context.input.key ?? ''))
|
|
339
|
+
const state = { query: stateOf(context).query }
|
|
340
|
+
if (outcome === 'notFound')
|
|
341
|
+
return answer(context, { ...state, problem: 'That redirect no longer exists.' })
|
|
342
|
+
if (outcome === 'notEditable')
|
|
343
|
+
return answer(context, {
|
|
344
|
+
...state,
|
|
345
|
+
problem:
|
|
346
|
+
'Only a redirect added here can be deleted here. A configured rule belongs to the site, and a tracked one to the page that was renamed.',
|
|
347
|
+
})
|
|
348
|
+
bundle.log.info('{user} deleted a redirect', { user: context.principal?.email })
|
|
349
|
+
return answer(context, state, 'Redirect deleted.')
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
}
|
|
353
|
+
|
|
95
354
|
/**
|
|
96
355
|
* The bundle a site wires into `defineConfig({ bundles: [redirects()] })`.
|
|
97
356
|
*
|
|
@@ -105,6 +364,7 @@ export function redirects(options: RedirectsBundleOptions = {}): ServerBundle<Ca
|
|
|
105
364
|
id: REDIRECTS_BUNDLE_ID,
|
|
106
365
|
section,
|
|
107
366
|
capabilities: CAPABILITIES,
|
|
367
|
+
screens: { rules: rulesScreenHandlers } as unknown as ServerBundle<Capability>['screens'],
|
|
108
368
|
// Back-office routes (story 211): the screen calls them below the bundle's
|
|
109
369
|
// namespace, and the host has checked the user and the section first.
|
|
110
370
|
routes: [
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads and drives this bundle's endpoints at
|
|
3
|
-
* `<backoffice>/crombolo/api/bundle/redirects/*`. The session cookie carries the
|
|
4
|
-
* auth, exactly as the framework's own plugin endpoints do.
|
|
5
|
-
*
|
|
6
|
-
* The base is read from `<base href>` rather than hard-coded, because the
|
|
7
|
-
* backoffice path is configurable (`CROMBOLO_BACKOFFICE_PATH`).
|
|
8
|
-
*/
|
|
9
|
-
const base = () => {
|
|
10
|
-
const href = document.querySelector('base')?.getAttribute('href') ?? '/umbraco/'
|
|
11
|
-
return `${href.replace(/\/$/, '')}/crombolo/api/bundle/redirects`
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const json = async (path, init) => {
|
|
15
|
-
const response = await fetch(`${base()}${path}`, {
|
|
16
|
-
credentials: 'include',
|
|
17
|
-
headers: {
|
|
18
|
-
accept: 'application/json',
|
|
19
|
-
...(init?.body ? { 'content-type': 'application/json' } : {}),
|
|
20
|
-
},
|
|
21
|
-
...init,
|
|
22
|
-
})
|
|
23
|
-
const body = await response.json().catch(() => ({}))
|
|
24
|
-
// A refusal carries a message the screen shows, so 400/404/409 are answers
|
|
25
|
-
// rather than failures; anything else is not something to paraphrase.
|
|
26
|
-
if (!response.ok && ![400, 404, 409].includes(response.status))
|
|
27
|
-
throw new Error(`The redirects endpoint answered ${response.status}`)
|
|
28
|
-
return body
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const listRedirects = (filter) =>
|
|
32
|
-
json(`/rules${filter ? `?filter=${encodeURIComponent(filter)}` : ''}`)
|
|
33
|
-
|
|
34
|
-
export const createRedirect = (rule) =>
|
|
35
|
-
json('/rules', { method: 'POST', body: JSON.stringify(rule) })
|
|
36
|
-
|
|
37
|
-
export const updateRedirect = (key, rule) =>
|
|
38
|
-
json(`/rules/${encodeURIComponent(key)}`, { method: 'PUT', body: JSON.stringify(rule) })
|
|
39
|
-
|
|
40
|
-
export const deleteRedirect = (key) =>
|
|
41
|
-
json(`/rules/${encodeURIComponent(key)}`, { method: 'DELETE' })
|
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Redirects screen, in Settings under Advanced.
|
|
3
|
-
*
|
|
4
|
-
* It lists every rule in force, not only the ones it can change: a screen that
|
|
5
|
-
* hid the configured and tracked rules would be lying about what the site does
|
|
6
|
-
* when a URL is requested. The three are told apart by a badge, and only a rule
|
|
7
|
-
* added here is editable — the others belong to the site's code and to the URL
|
|
8
|
-
* tracker, and the server refuses to change them whatever this screen sends.
|
|
9
|
-
*
|
|
10
|
-
* The editor offers everything the matcher supports, because the alternative is
|
|
11
|
-
* a screen quietly weaker than `crombolo.config.ts`: exact, starts-with and
|
|
12
|
-
* regular-expression matching, a page, a path or an external URL as the target,
|
|
13
|
-
* the four redirect status codes, and an optional culture.
|
|
14
|
-
*/
|
|
15
|
-
// Both imports are for their side effects: they register the custom elements
|
|
16
|
-
// this template uses. `uui-*` is registered by the app shell, but
|
|
17
|
-
// `umb-body-layout` and `umb-input-document` are defined in chunks the shell
|
|
18
|
-
// loads lazily — and this module is loaded through the import map rather than as
|
|
19
|
-
// part of the client's own chunk graph, so nothing else would pull them in.
|
|
20
|
-
import '@umbraco-cms/backoffice/components'
|
|
21
|
-
import '@umbraco-cms/backoffice/document'
|
|
22
|
-
import { css, html, nothing, repeat } from '@umbraco-cms/backoffice/external/lit'
|
|
23
|
-
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
24
|
-
import {
|
|
25
|
-
createRedirect,
|
|
26
|
-
deleteRedirect,
|
|
27
|
-
listRedirects,
|
|
28
|
-
updateRedirect,
|
|
29
|
-
} from './redirects-client.js'
|
|
30
|
-
|
|
31
|
-
const MATCH_KINDS = [
|
|
32
|
-
['exact', 'Exactly this URL'],
|
|
33
|
-
['prefix', 'This URL and everything below it'],
|
|
34
|
-
['regex', 'A regular expression'],
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
const TARGET_KINDS = [
|
|
38
|
-
['document', 'A page on this site'],
|
|
39
|
-
['path', 'A path on this site'],
|
|
40
|
-
['url', 'Another site'],
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
const STATUS_CODES = [
|
|
44
|
-
[301, '301 — moved permanently'],
|
|
45
|
-
[302, '302 — found, temporarily'],
|
|
46
|
-
[307, '307 — temporary, keeping the method'],
|
|
47
|
-
[308, '308 — permanent, keeping the method'],
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
const SOURCES = {
|
|
51
|
-
manual: { label: 'Added here', look: 'primary' },
|
|
52
|
-
config: { label: 'In configuration', look: 'secondary' },
|
|
53
|
-
tracked: { label: 'From a rename', look: 'default' },
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const BLANK = {
|
|
57
|
-
matchKind: 'exact',
|
|
58
|
-
pattern: '',
|
|
59
|
-
targetKind: 'document',
|
|
60
|
-
target: '',
|
|
61
|
-
statusCode: 301,
|
|
62
|
-
culture: '',
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default class CromboloRedirectsWorkspaceElement extends UmbLitElement {
|
|
66
|
-
static properties = {
|
|
67
|
-
_rules: { state: true },
|
|
68
|
-
_loading: { state: true },
|
|
69
|
-
_editing: { state: true },
|
|
70
|
-
_problem: { state: true },
|
|
71
|
-
_notice: { state: true },
|
|
72
|
-
_busy: { state: true },
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
constructor() {
|
|
76
|
-
super()
|
|
77
|
-
this._rules = []
|
|
78
|
-
this._loading = true
|
|
79
|
-
this._editing = undefined
|
|
80
|
-
this._problem = ''
|
|
81
|
-
this._notice = ''
|
|
82
|
-
this._busy = false
|
|
83
|
-
this._filter = ''
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
connectedCallback() {
|
|
87
|
-
super.connectedCallback()
|
|
88
|
-
this.#load()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async #load() {
|
|
92
|
-
this._loading = true
|
|
93
|
-
try {
|
|
94
|
-
const result = await listRedirects(this._filter)
|
|
95
|
-
this._rules = result.items ?? []
|
|
96
|
-
this._problem = ''
|
|
97
|
-
} catch (error) {
|
|
98
|
-
this._problem = error instanceof Error ? error.message : String(error)
|
|
99
|
-
} finally {
|
|
100
|
-
this._loading = false
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
#filterChanged(event) {
|
|
105
|
-
this._filter = event.target.value ?? ''
|
|
106
|
-
this.#load()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
#add() {
|
|
110
|
-
this._notice = ''
|
|
111
|
-
this._problem = ''
|
|
112
|
-
this._editing = { ...BLANK }
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#edit(rule) {
|
|
116
|
-
this._notice = ''
|
|
117
|
-
this._problem = ''
|
|
118
|
-
this._editing = {
|
|
119
|
-
key: rule.key,
|
|
120
|
-
matchKind: rule.matchKind,
|
|
121
|
-
pattern: rule.pattern,
|
|
122
|
-
targetKind: rule.targetKind,
|
|
123
|
-
target: rule.target,
|
|
124
|
-
statusCode: rule.statusCode,
|
|
125
|
-
culture: rule.culture ?? '',
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
#change(field, value) {
|
|
130
|
-
this._editing = { ...this._editing, [field]: value }
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** Changing what the target *is* makes the old value meaningless. */
|
|
134
|
-
#changeTargetKind(value) {
|
|
135
|
-
this._editing = { ...this._editing, targetKind: value, target: '' }
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async #save() {
|
|
139
|
-
const editing = this._editing
|
|
140
|
-
if (!editing) return
|
|
141
|
-
this._busy = true
|
|
142
|
-
this._problem = ''
|
|
143
|
-
try {
|
|
144
|
-
const rule = {
|
|
145
|
-
matchKind: editing.matchKind,
|
|
146
|
-
pattern: editing.pattern,
|
|
147
|
-
targetKind: editing.targetKind,
|
|
148
|
-
target: editing.target,
|
|
149
|
-
statusCode: Number(editing.statusCode),
|
|
150
|
-
culture: editing.culture,
|
|
151
|
-
}
|
|
152
|
-
const outcome = editing.key
|
|
153
|
-
? await updateRedirect(editing.key, rule)
|
|
154
|
-
: await createRedirect(rule)
|
|
155
|
-
if (!outcome.ok) {
|
|
156
|
-
this._problem = outcome.message ?? 'The redirect could not be saved.'
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
this._editing = undefined
|
|
160
|
-
this._notice = editing.key ? 'Redirect updated.' : 'Redirect added.'
|
|
161
|
-
await this.#load()
|
|
162
|
-
} catch (error) {
|
|
163
|
-
this._problem = error instanceof Error ? error.message : String(error)
|
|
164
|
-
} finally {
|
|
165
|
-
this._busy = false
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async #delete(rule) {
|
|
170
|
-
if (!confirm(`Delete the redirect from ${this.#from(rule)}?`)) return
|
|
171
|
-
this._problem = ''
|
|
172
|
-
try {
|
|
173
|
-
const outcome = await deleteRedirect(rule.key)
|
|
174
|
-
if (!outcome.ok) {
|
|
175
|
-
this._problem = outcome.message ?? 'The redirect could not be deleted.'
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
this._notice = 'Redirect deleted.'
|
|
179
|
-
await this.#load()
|
|
180
|
-
} catch (error) {
|
|
181
|
-
this._problem = error instanceof Error ? error.message : String(error)
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** What a visitor would have typed, which is the pattern plus how it matches. */
|
|
186
|
-
#from(rule) {
|
|
187
|
-
if (rule.matchKind === 'prefix') return `${rule.pattern === '/' ? '' : rule.pattern}/*`
|
|
188
|
-
if (rule.matchKind === 'regex') return `/${rule.pattern}/`
|
|
189
|
-
return rule.pattern
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
#to(rule) {
|
|
193
|
-
if (rule.targetKind === 'document') return rule.destinationUrl || 'a page that is not published'
|
|
194
|
-
return rule.target
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
#editor() {
|
|
198
|
-
const editing = this._editing
|
|
199
|
-
const documentTarget = editing.targetKind === 'document'
|
|
200
|
-
return html`
|
|
201
|
-
<uui-box headline=${editing.key ? 'Edit redirect' : 'Add a redirect'}>
|
|
202
|
-
<div class="field">
|
|
203
|
-
<label for="match">Match</label>
|
|
204
|
-
<uui-select
|
|
205
|
-
id="match"
|
|
206
|
-
.value=${editing.matchKind}
|
|
207
|
-
@change=${(event) => this.#change('matchKind', event.target.value)}
|
|
208
|
-
.options=${MATCH_KINDS.map(([value, name]) => ({
|
|
209
|
-
value,
|
|
210
|
-
name,
|
|
211
|
-
selected: value === editing.matchKind,
|
|
212
|
-
}))}></uui-select>
|
|
213
|
-
</div>
|
|
214
|
-
|
|
215
|
-
<div class="field">
|
|
216
|
-
<label for="pattern">Redirect from</label>
|
|
217
|
-
<uui-input
|
|
218
|
-
id="pattern"
|
|
219
|
-
.value=${editing.pattern}
|
|
220
|
-
placeholder=${editing.matchKind === 'regex' ? '^/news/(\\d+)$' : '/old-page'}
|
|
221
|
-
@input=${(event) => this.#change('pattern', event.target.value)}></uui-input>
|
|
222
|
-
${
|
|
223
|
-
editing.matchKind === 'regex'
|
|
224
|
-
? html`<small
|
|
225
|
-
>Captures are available in the target as <code>$1</code> to
|
|
226
|
-
<code>$9</code>.</small
|
|
227
|
-
>`
|
|
228
|
-
: nothing
|
|
229
|
-
}
|
|
230
|
-
${
|
|
231
|
-
editing.matchKind === 'prefix'
|
|
232
|
-
? html`<small
|
|
233
|
-
>Everything below this path is matched; the remainder is available as
|
|
234
|
-
<code>$1</code>.</small
|
|
235
|
-
>`
|
|
236
|
-
: nothing
|
|
237
|
-
}
|
|
238
|
-
</div>
|
|
239
|
-
|
|
240
|
-
<div class="field">
|
|
241
|
-
<label for="target-kind">Redirect to</label>
|
|
242
|
-
<uui-select
|
|
243
|
-
id="target-kind"
|
|
244
|
-
.value=${editing.targetKind}
|
|
245
|
-
@change=${(event) => this.#changeTargetKind(event.target.value)}
|
|
246
|
-
.options=${TARGET_KINDS.map(([value, name]) => ({
|
|
247
|
-
value,
|
|
248
|
-
name,
|
|
249
|
-
selected: value === editing.targetKind,
|
|
250
|
-
}))}></uui-select>
|
|
251
|
-
</div>
|
|
252
|
-
|
|
253
|
-
<div class="field">
|
|
254
|
-
${
|
|
255
|
-
documentTarget
|
|
256
|
-
? html`
|
|
257
|
-
<label>Page</label>
|
|
258
|
-
<umb-input-document
|
|
259
|
-
max="1"
|
|
260
|
-
.selection=${editing.target ? [editing.target] : []}
|
|
261
|
-
@change=${(event) => this.#change('target', event.target.selection?.[0] ?? '')}>
|
|
262
|
-
</umb-input-document>
|
|
263
|
-
<small>
|
|
264
|
-
A page keeps working as a target when it is renamed or moved, because the
|
|
265
|
-
rule names the page rather than its URL.
|
|
266
|
-
</small>
|
|
267
|
-
`
|
|
268
|
-
: html`
|
|
269
|
-
<label for="target">${editing.targetKind === 'url' ? 'URL' : 'Path'}</label>
|
|
270
|
-
<uui-input
|
|
271
|
-
id="target"
|
|
272
|
-
.value=${editing.target}
|
|
273
|
-
placeholder=${
|
|
274
|
-
editing.targetKind === 'url' ? 'https://example.com/page' : '/new-page'
|
|
275
|
-
}
|
|
276
|
-
@input=${(event) => this.#change('target', event.target.value)}></uui-input>
|
|
277
|
-
`
|
|
278
|
-
}
|
|
279
|
-
</div>
|
|
280
|
-
|
|
281
|
-
<div class="field">
|
|
282
|
-
<label for="status">Status code</label>
|
|
283
|
-
<uui-select
|
|
284
|
-
id="status"
|
|
285
|
-
.value=${String(editing.statusCode)}
|
|
286
|
-
@change=${(event) => this.#change('statusCode', event.target.value)}
|
|
287
|
-
.options=${STATUS_CODES.map(([value, name]) => ({
|
|
288
|
-
value: String(value),
|
|
289
|
-
name,
|
|
290
|
-
selected: value === Number(editing.statusCode),
|
|
291
|
-
}))}></uui-select>
|
|
292
|
-
</div>
|
|
293
|
-
|
|
294
|
-
<div class="field">
|
|
295
|
-
<label for="culture">Culture</label>
|
|
296
|
-
<uui-input
|
|
297
|
-
id="culture"
|
|
298
|
-
.value=${editing.culture}
|
|
299
|
-
placeholder="Every culture"
|
|
300
|
-
@input=${(event) => this.#change('culture', event.target.value)}></uui-input>
|
|
301
|
-
<small>Leave this empty to redirect whichever language the URL resolved in.</small>
|
|
302
|
-
</div>
|
|
303
|
-
|
|
304
|
-
<div slot="actions">
|
|
305
|
-
<uui-button
|
|
306
|
-
label="Cancel"
|
|
307
|
-
@click=${() => {
|
|
308
|
-
this._editing = undefined
|
|
309
|
-
}}></uui-button>
|
|
310
|
-
<uui-button
|
|
311
|
-
look="primary"
|
|
312
|
-
color="positive"
|
|
313
|
-
label=${editing.key ? 'Save' : 'Add redirect'}
|
|
314
|
-
.state=${this._busy ? 'waiting' : undefined}
|
|
315
|
-
@click=${() => this.#save()}></uui-button>
|
|
316
|
-
</div>
|
|
317
|
-
</uui-box>
|
|
318
|
-
`
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
#table() {
|
|
322
|
-
if (this._rules.length === 0)
|
|
323
|
-
return html`
|
|
324
|
-
<uui-box headline="No redirects yet">
|
|
325
|
-
<p>
|
|
326
|
-
Nothing redirects on this site. Add a rule here, or rename a published page —
|
|
327
|
-
which records one by itself so the old URL keeps working.
|
|
328
|
-
</p>
|
|
329
|
-
</uui-box>
|
|
330
|
-
`
|
|
331
|
-
|
|
332
|
-
return html`
|
|
333
|
-
<uui-table>
|
|
334
|
-
<uui-table-head>
|
|
335
|
-
<uui-table-head-cell>From</uui-table-head-cell>
|
|
336
|
-
<uui-table-head-cell>To</uui-table-head-cell>
|
|
337
|
-
<uui-table-head-cell>Status</uui-table-head-cell>
|
|
338
|
-
<uui-table-head-cell>Source</uui-table-head-cell>
|
|
339
|
-
<uui-table-head-cell></uui-table-head-cell>
|
|
340
|
-
</uui-table-head>
|
|
341
|
-
${repeat(
|
|
342
|
-
this._rules,
|
|
343
|
-
(rule) => rule.key,
|
|
344
|
-
(rule) => html`
|
|
345
|
-
<uui-table-row>
|
|
346
|
-
<uui-table-cell><code>${this.#from(rule)}</code></uui-table-cell>
|
|
347
|
-
<uui-table-cell>
|
|
348
|
-
<code>${this.#to(rule)}</code>
|
|
349
|
-
${
|
|
350
|
-
rule.culture
|
|
351
|
-
? html`<uui-tag look="default" size="s">${rule.culture}</uui-tag>`
|
|
352
|
-
: nothing
|
|
353
|
-
}
|
|
354
|
-
</uui-table-cell>
|
|
355
|
-
<uui-table-cell>${rule.statusCode}</uui-table-cell>
|
|
356
|
-
<uui-table-cell>
|
|
357
|
-
<uui-tag look=${SOURCES[rule.source]?.look ?? 'default'} size="s">
|
|
358
|
-
${SOURCES[rule.source]?.label ?? rule.source}
|
|
359
|
-
</uui-tag>
|
|
360
|
-
</uui-table-cell>
|
|
361
|
-
<uui-table-cell class="actions">
|
|
362
|
-
${
|
|
363
|
-
rule.editable
|
|
364
|
-
? html`
|
|
365
|
-
<uui-button
|
|
366
|
-
label="Edit"
|
|
367
|
-
look="secondary"
|
|
368
|
-
compact
|
|
369
|
-
@click=${() => this.#edit(rule)}></uui-button>
|
|
370
|
-
<uui-button
|
|
371
|
-
label="Delete"
|
|
372
|
-
look="secondary"
|
|
373
|
-
color="danger"
|
|
374
|
-
compact
|
|
375
|
-
@click=${() => this.#delete(rule)}></uui-button>
|
|
376
|
-
`
|
|
377
|
-
: nothing
|
|
378
|
-
}
|
|
379
|
-
</uui-table-cell>
|
|
380
|
-
</uui-table-row>
|
|
381
|
-
`,
|
|
382
|
-
)}
|
|
383
|
-
</uui-table>
|
|
384
|
-
`
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
render() {
|
|
388
|
-
return html`
|
|
389
|
-
<umb-body-layout headline="Redirects">
|
|
390
|
-
<div id="content">
|
|
391
|
-
<div id="head">
|
|
392
|
-
<uui-input
|
|
393
|
-
type="search"
|
|
394
|
-
label="Search redirects"
|
|
395
|
-
placeholder="Search either URL"
|
|
396
|
-
@change=${this.#filterChanged}></uui-input>
|
|
397
|
-
<uui-button
|
|
398
|
-
look="primary"
|
|
399
|
-
label="Add redirect"
|
|
400
|
-
@click=${() => this.#add()}></uui-button>
|
|
401
|
-
</div>
|
|
402
|
-
|
|
403
|
-
${this._problem ? html`<div class="banner problem">${this._problem}</div>` : nothing}
|
|
404
|
-
${this._notice ? html`<div class="banner notice">${this._notice}</div>` : nothing}
|
|
405
|
-
${this._editing ? this.#editor() : nothing}
|
|
406
|
-
${
|
|
407
|
-
this._loading && this._rules.length === 0
|
|
408
|
-
? html`<div id="loader"><uui-loader></uui-loader></div>`
|
|
409
|
-
: this.#table()
|
|
410
|
-
}
|
|
411
|
-
</div>
|
|
412
|
-
</umb-body-layout>
|
|
413
|
-
`
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
static styles = css`
|
|
417
|
-
:host {
|
|
418
|
-
display: block;
|
|
419
|
-
width: 100%;
|
|
420
|
-
height: 100%;
|
|
421
|
-
}
|
|
422
|
-
#content {
|
|
423
|
-
padding: var(--uui-size-layout-1, 24px);
|
|
424
|
-
display: flex;
|
|
425
|
-
flex-direction: column;
|
|
426
|
-
gap: var(--uui-size-space-5, 18px);
|
|
427
|
-
}
|
|
428
|
-
#head {
|
|
429
|
-
display: flex;
|
|
430
|
-
align-items: center;
|
|
431
|
-
gap: var(--uui-size-space-4, 12px);
|
|
432
|
-
}
|
|
433
|
-
#head uui-input {
|
|
434
|
-
flex: 1;
|
|
435
|
-
}
|
|
436
|
-
#loader {
|
|
437
|
-
display: flex;
|
|
438
|
-
justify-content: center;
|
|
439
|
-
padding: var(--uui-size-layout-3, 48px);
|
|
440
|
-
}
|
|
441
|
-
.field {
|
|
442
|
-
display: flex;
|
|
443
|
-
flex-direction: column;
|
|
444
|
-
gap: var(--uui-size-space-2, 6px);
|
|
445
|
-
margin-bottom: var(--uui-size-space-5, 18px);
|
|
446
|
-
max-width: 48rem;
|
|
447
|
-
}
|
|
448
|
-
.field label {
|
|
449
|
-
font-weight: bold;
|
|
450
|
-
}
|
|
451
|
-
.field small {
|
|
452
|
-
opacity: 0.8;
|
|
453
|
-
line-height: 1.5;
|
|
454
|
-
}
|
|
455
|
-
.banner {
|
|
456
|
-
padding: var(--uui-size-space-4, 12px);
|
|
457
|
-
border-left: 3px solid var(--uui-color-default, #3544b1);
|
|
458
|
-
background: var(--uui-color-surface-alt, #f3f3f5);
|
|
459
|
-
}
|
|
460
|
-
.banner.problem {
|
|
461
|
-
border-left-color: var(--uui-color-danger, #d42054);
|
|
462
|
-
}
|
|
463
|
-
.banner.notice {
|
|
464
|
-
border-left-color: var(--uui-color-positive, #2bc37c);
|
|
465
|
-
}
|
|
466
|
-
.actions {
|
|
467
|
-
display: flex;
|
|
468
|
-
gap: var(--uui-size-space-2, 6px);
|
|
469
|
-
justify-content: flex-end;
|
|
470
|
-
}
|
|
471
|
-
code {
|
|
472
|
-
word-break: break-all;
|
|
473
|
-
}
|
|
474
|
-
p {
|
|
475
|
-
max-width: 60ch;
|
|
476
|
-
line-height: 1.5;
|
|
477
|
-
}
|
|
478
|
-
`
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
customElements.define('crombolo-redirects-workspace', CromboloRedirectsWorkspaceElement)
|