Commit Graph
16 Commits
Author SHA1 Message Date
Oleg Isonen bf6abe7384 feat: Manage data variables (#5488)
ref #4608

## Description

1. What is this PR about (link the issue and add a short description)

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
0000)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2025-12-07 23:15:48 +01:00
Bogdan Chadkin de444a3501 fix: copy paste search params in resources (#5412)
Reproduced when tried to insert the new baserow template
2025-09-27 16:47:49 +03:00
Bogdan Chadkin c1ec5beeb3 fix: rebind nested collection item properly (#5159)
Before parent collection item on nested collection was rebind with
nested collection item which lead to broken state

```
<Collection id="parent" data={[]} item="collectionItem">
  <Collection id="nested" data={collectionItem} item="collectionItem">
  </Collection
</Collection
```

```
collection.map(collectionItem =>
  // oops
  collectionItem2.map(collectionItem2 => {
  })
})
```
2025-04-25 21:05:54 +07:00
Bogdan Chadkin 8891748af7 fix: optimize saving global variables (#4936)
Reduced amount iterations over all instances
to optimize rebinding variables on save.
2025-03-01 10:37:37 +07:00
Bogdan Chadkin ea64f35ce8 fix: rebind variables within scope (#4927)
Found broken cases with rebinding variables
when they are renamed or just saved.
2025-02-28 01:42:40 +07:00
Bogdan Chadkin be2ae85854 feat: unset variables in page meta when deleted (#4907)
Another case I forgot. Variables should be unset in all page metas when
deleted.

- Test delete of body variable used in page title
- Test delete of global variable used in page title
- Bind all page meta values and delete the variable to make sure it was
unset from all fields
2025-02-24 21:27:07 +07:00
Bogdan Chadkin 5cd30fe8b0 feat: unset global variables when delete (#4904)
Global variables will be replaced with "name" or unset when deleted from
data variables section.

There are few cases to test

1. variable is unset on a few pages when delete
2. variable is unset on inside of slots when delete
2025-02-23 23:34:45 +07:00
Bogdan Chadkin 23034dad25 feat: add global system variable in builder (#4896)
Closes https://github.com/webstudio-is/webstudio/issues/4166

Now system is global variable and can be accessed in slots.

Legacy one can be deleted

<img width="264" alt="image"
src="https://github.com/user-attachments/assets/1c1d60f5-6be2-4871-9970-3593e3e7c08a"
/>
2025-02-23 01:46:21 +07:00
Bogdan ChadkinandOleg Isonen 34e18b35ae fix: allow broken variables when validate updates (#4892)
Some templates have variables with missing scopeInstanceId on dialogs or
something else from broken embed template. Here allow it in validation
because migration would be more complex.

---------

Co-authored-by: Oleg Isonen <oleg008@gmail.com>
2025-02-18 23:20:02 +07:00
Bogdan Chadkin 8ed3fbb085 feat: support global data variables (#4870)
Ref https://github.com/webstudio-is/webstudio/issues/4166
https://github.com/webstudio-is/webstudio/issues/3686

Added "Settings" section to global root. Now users can create data
variables which are available for all pages and inside slots.



https://github.com/user-attachments/assets/be2cf862-08ec-427e-aea3-076fa03a4437
2025-02-15 01:23:16 +08:00
Bogdan Chadkin 13a4660391 fix: rebind variables after delete (#4865)
Ref https://github.com/webstudio-is/webstudio/issues/4768

Forgot to handle the case with rebinding with parent variables after
variable on child is deleted.

Also fixed the case with rebinding variables outside of slot scope.
2025-02-13 18:00:54 +08:00
Bogdan Chadkin ae864ef8b6 feat: allow deleting variables used in expressions (#4860)
Ref https://github.com/webstudio-is/webstudio/issues/4768

Before we disabled deleting variables which are used in expressions. Now
we will ask confirmation and unset this variable. This way user will not
be locked if variable is lost and we will show diagnostics (in the
future) where all unset variables are.

<img width="908" alt="Screenshot 2025-02-12 at 15 38 14"
src="https://github.com/user-attachments/assets/ea9eea58-c276-4251-8b95-1214e9380621"
/>
2025-02-13 10:37:53 +08:00
Bogdan Chadkin 93334da114 feat: rebind masked variables (#4849)
Here improved creating variables to override deeper bindings when new
variable overrides ancestor variable similar to css variables behavior.

Here's a video with example



https://github.com/user-attachments/assets/41f93f5b-fd2d-4a3b-97d1-076f0ded5f01
2025-02-10 09:03:21 +07:00
Bogdan Chadkin 53ace3be3c feat: unset variables when create or rename data variables (#4808)
Ref https://github.com/webstudio-is/webstudio/issues/4768

Now user can write expressions with not existing variables and create
these variables later. Builder will automatically traverse all
expressions and bind to newly created variable by name.

Additionally user will see suggestions with all unset variables in
subtree.

<img width="504" alt="Screenshot 2025-01-30 at 12 35 21"
src="https://github.com/user-attachments/assets/6d042f45-ca4a-49b9-9259-7be2a3c74bdd"
/>
2025-01-31 13:21:00 +07:00
Bogdan Chadkin 6b04c9762d feat: allow saving expressions with unset variables (#4792)
Ref https://github.com/webstudio-is/webstudio/issues/4768
https://github.com/webstudio-is/webstudio/issues/4753

User can paste expression with not defined variable and should get it
saved in case of accidental closing popover.

Now such expressions can be executed in builder and will be compiled
with undefined instead of variables in published sites.

In the future we need to add global diagnostics to let users find such
places faster.

Also fixed a couple of ui issues
- react error about using button inside of button in data variables list
- react error about using unknown middlewareData prop from floating-ui

<img width="307" alt="Screenshot 2025-01-27 at 16 30 58"
src="https://github.com/user-attachments/assets/2ddc9ead-33a2-4438-b641-6943d7472f7e"
/>
2025-01-28 01:49:02 +07:00
Bogdan Chadkin bc5d2951ec feat: support expressions copy paste between instances (#4790)
Ref https://github.com/webstudio-is/webstudio/issues/4768

Here improved copy paste experience between expressions. All expressions
while editing have are no longer encoded with ids. For example
`system.search.name` is the same.
Though invalid js characters are encoded with code point like this
`Collection Item.title` becomes `Collection$32$Item.title` when copy
into textual editor.

And this less obscure name can be copied between different lists with
the same `Collection Item` name.
2025-01-27 11:18:37 +07:00