Skip to content

Commit 04c1b15

Browse files
pedrosousakodster28
authored andcommitted
[Rules] Snippets: Update dashboard instructions (#19511)
1 parent 98af3bd commit 04c1b15

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

src/content/changelogs/rules.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ productLink: "/rules/"
55
productArea: Application performance
66
productAreaLink: /fundamentals/reference/changelog/performance/
77
entries:
8+
- publish_date: "2025-01-29"
9+
title: New Snippets code editor
10+
description: |-
11+
The new Snippets code editor is now live, allowing users to edit both Snippets code and rules from a single page. This update simplifies the workflow and introduces features such as code formatting, refactoring, and auto-complete. The updated editor is available within the Snippets interface.
812
- publish_date: "2025-01-09"
913
title: New Rules Overview page
1014
description: |-

src/content/docs/rules/snippets/create-api.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ curl --request PUT https://api.cloudflare.com/client/v4/zones/{zone_id}/snippets
5858
--form metadata='{"main_module":"example.js"}'
5959
```
6060

61+
The name of a snippet can only contain the characters `a-z`, `0-9`, and `_` (underscore). The name must be unique in the context of the zone. You cannot change the snippet name after creating the snippet.
62+
6163
The required body parameters are:
6264

6365
- `files`: The file with your JavaScript code.
@@ -78,6 +80,8 @@ To make this example work, save your JavaScript code in a file named `example.js
7880
}
7981
```
8082

83+
To deploy a new snippet you must [create a snippet rule](#createupdatedelete-snippet-rules). The expression of the snippet rule defines when the snippet code will run.
84+
8185
### Create/update/delete snippet rules
8286

8387
:::caution

src/content/docs/rules/snippets/create-dashboard.mdx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,20 @@ head:
99
content: Create a snippet in the dashboard
1010
---
1111

12-
The snippet creation wizard will guide you through the following steps:
13-
14-
1. Define snippet code and test your snippet.
15-
2. Create snippet rule. The rule expression defines for which requests the snippet code will run.
16-
3. Review your snippet configuration and deploy the snippet.
17-
18-
## Procedure
19-
2012
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account and website.
2113

2214
2. Go to **Rules** > **Snippets**, and select **Create a Snippet**.
2315

24-
3. Enter a descriptive name for the snippet.
25-
26-
4. Enter the snippet's JavaScript code. You can test how your snippet will handle incoming requests using the **HTTP** and **Preview** tabs.
16+
3. In **Snippet name**, enter a descriptive name for the snippet. You cannot change the name after creating the snippet.
2717

28-
5. Select **Continue to add Snippet rule**.
18+
4. Enter the snippet's JavaScript code in the code editor. You can test how your snippet will handle incoming requests using the **HTTP** and **Preview** tabs.
2919

30-
6. Enter a descriptive name for the snippet rule. The snippet rule specifies for which requests the snippet code will run.
20+
5. Select **Snippet rule** to configure when the snippet will run.
3121

32-
7. Under **When incoming requests match**, select if you wish to run the snippet for all incoming requests or only for requests that match a custom filter expression.
22+
6. Under **Run this Snippet if incoming requests match**, select if you wish to run the snippet only for requests that match a custom filter expression or for all incoming requests.
3323

34-
8. (Optional) To define a custom expression, use the Expression Builder (specifying one or more values for **Field**, **Operator**, and **Value**) or manually enter an expression using the Expression Editor. For more information, refer to [Edit expressions in the dashboard](/ruleset-engine/rules-language/expressions/edit-expressions/).
24+
7. (Optional) To define a custom expression, use the Expression Builder (specifying one or more values for **Field**, **Operator**, and **Value**) or manually enter an expression using the Expression Editor. For more information, refer to [Edit expressions in the dashboard](/ruleset-engine/rules-language/expressions/edit-expressions/).
3525

36-
9. Select **Continue to create Snippet**.
26+
8. Select **Done**.
3727

38-
10. Review the snippet code and the snippet rule that defines when the snippet will run. To save your snippet and deploy a rule that enables it, select **Save and deploy Snippet**. If you are not ready to deploy your snippet, select **Save and enable later**.
28+
9. To deploy your snippet, select **Deploy**. If you are not ready to deploy your snippet, open the dropdown next to **Deploy** and select **Save as Draft**.

src/content/docs/rules/snippets/create-terraform.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ resource "cloudflare_snippet_rules" "cookie_snippet_rule" {
4040
}
4141
```
4242

43-
The name of a snippet can only contain the characters `a-z`, `0-9`, and `_` (underscore). The name must be unique in the context of the zone.
43+
The name of a snippet can only contain the characters `a-z`, `0-9`, and `_` (underscore). The name must be unique in the context of the zone. You cannot change the snippet name after creating the snippet.
4444

4545
All `snippet_name` values in the `cloudflare_snippet_rules` resource must match the names of existing snippets.
4646

src/content/docs/rules/snippets/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To create and deploy a Snippet, you need to define the following elements:
2626
- **Code snippet**: JavaScript code to be executed during the request-handling process.
2727
- **Snippet rule**: A [filter expression](/ruleset-engine/rules-language/expressions/) that determines which requests the Snippet will be applied to. Each Snippet can only be associated with one Snippet Rule.
2828

29-
For more information, refer to the [How it works](/rules/snippets/how-it-works/) and [Create in the dashboard](/rules/snippets/create-dashboard/) sections.
29+
For more information, refer to the [How it works](/rules/snippets/how-it-works/) and [Create a snippet in the dashboard](/rules/snippets/create-dashboard/) sections.
3030

3131
## Templates
3232

0 commit comments

Comments
 (0)