Skip to content

Commit 23f9e08

Browse files
SuaYooemma-sg
andauthored
feat: Add custom behaviors to workflow (#2520)
Resolves #2151 Follows #2505 ## Changes - Allows users to set custom behaviors in workflow editor. - Allows one or more behaviors, as simple URL or Git URL to be added - Calls validation endpoint to check if URL is valid. --------- Co-authored-by: emma <[email protected]>
1 parent cd7b695 commit 23f9e08

File tree

13 files changed

+819
-20
lines changed

13 files changed

+819
-20
lines changed

frontend/src/components/ui/config-details.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ export class ConfigDetails extends BtrixElement {
178178
.filter((v) => v)
179179
.join(", ") || none,
180180
)}
181+
${this.renderSetting(
182+
labelFor.customBehaviors,
183+
seedsConfig?.customBehaviors.length
184+
? html`
185+
<btrix-custom-behaviors-table
186+
.customBehaviors=${seedsConfig.customBehaviors}
187+
></btrix-custom-behaviors-table>
188+
`
189+
: none,
190+
)}
181191
${this.renderSetting(
182192
labelFor.pageLoadTimeoutSeconds,
183193
renderTimeLimit(

frontend/src/components/ui/copy-field.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export class CopyField extends TailwindElement {
3535
@property({ type: Boolean })
3636
hoist = false;
3737

38+
@property({ type: Boolean })
39+
border = true;
40+
3841
@property({ type: Boolean })
3942
monostyle = true;
4043

@@ -65,7 +68,7 @@ export class CopyField extends TailwindElement {
6568
<div
6669
role="group"
6770
class=${clsx(
68-
tw`rounded border`,
71+
this.border && tw`rounded border`,
6972
this.filled ? tw`bg-slate-50` : tw`border-neutral-150`,
7073
this.monostyle && tw`font-monostyle`,
7174
)}

frontend/src/components/ui/url-input.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import type { SlInputEvent } from "@shoelace-style/shoelace";
21
import { msg } from "@lit/localize";
32
import SlInput from "@shoelace-style/shoelace/dist/components/input/input.js";
43
import { customElement, property } from "lit/decorators.js";
@@ -20,45 +19,41 @@ export function validURL(url: string) {
2019
* @attr {String} name
2120
* @attr {String} label
2221
* @attr {String} value
22+
* @attr {Boolean} required
2323
*/
2424
@customElement("btrix-url-input")
25-
export class Component extends SlInput {
25+
export class UrlInput extends SlInput {
2626
@property({ type: Number, reflect: true })
2727
minlength = 4;
2828

2929
@property({ type: String, reflect: true })
3030
placeholder = "https://example.com";
3131

32-
connectedCallback(): void {
33-
this.inputmode = "url";
32+
constructor() {
33+
super();
3434

35-
super.connectedCallback();
35+
this.inputmode = "url";
3636

3737
this.addEventListener("sl-input", this.onInput);
38-
this.addEventListener("sl-blur", this.onBlur);
38+
this.addEventListener("sl-change", this.onChange);
3939
}
4040

4141
disconnectedCallback(): void {
4242
super.disconnectedCallback();
4343

4444
this.removeEventListener("sl-input", this.onInput);
45-
this.removeEventListener("sl-blur", this.onBlur);
45+
this.removeEventListener("sl-change", this.onChange);
4646
}
4747

48-
private readonly onInput = async () => {
49-
console.log("input 1");
50-
await this.updateComplete;
51-
48+
private readonly onInput = () => {
5249
if (!this.checkValidity() && validURL(this.value)) {
5350
this.setCustomValidity("");
5451
this.helpText = "";
5552
}
5653
};
5754

58-
private readonly onBlur = async () => {
59-
await this.updateComplete;
60-
61-
const value = this.value;
55+
private readonly onChange = () => {
56+
const value = this.value.trim();
6257

6358
if (value && !validURL(value)) {
6459
const text = msg("Please enter a valid URL.");

frontend/src/controllers/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export class APIController implements ReactiveController {
170170
message: errorMessage,
171171
status: resp.status,
172172
details: errorDetails,
173+
errorCode: errorDetail,
173174
});
174175
}
175176

0 commit comments

Comments
 (0)