Skip to content

EditableTree: move EditableTreeContext code to a separate file#12300

Merged
CraigMacomber merged 1 commit into
microsoft:mainfrom
sharptrip:editableTree-move-context-file
Oct 6, 2022
Merged

EditableTree: move EditableTreeContext code to a separate file#12300
CraigMacomber merged 1 commit into
microsoft:mainfrom
sharptrip:editableTree-move-context-file

Conversation

@sharptrip
Copy link
Copy Markdown
Contributor

@sharptrip sharptrip commented Oct 6, 2022

This is a pure refactoring.

Step 1 in a series to push code from #12182.
Step 2 support global fields sharptrip#5
Step 3 support sequences (read-only)
Step 4 support editing
Step 5 add TypedJsonCursor and limited json support

@sharptrip sharptrip requested a review from a team as a code owner October 6, 2022 11:45
@github-actions github-actions Bot added the area: dds Issues related to distributed data structures label Oct 6, 2022
@github-actions github-actions Bot added the base: main PRs targeted against main branch label Oct 6, 2022
@CraigMacomber CraigMacomber merged commit 5257d8f into microsoft:main Oct 6, 2022
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 6, 2022

This commit is queued for merging with the next branch! Please ignore this PR for now. Contact @microsoft/fluid-cr-infra for help.

CraigMacomber pushed a commit that referenced this pull request Oct 11, 2022
This PR enables support of global fields in EditableTree and refactors
tests.

**Step 2** in a series to push code from #12182.

[Step 1](#12300)
CraigMacomber pushed a commit that referenced this pull request Oct 14, 2022
This PR provide a way to access fields of EditableTree without
unwrapping. Currently, this works only on "all or nothing" basis meaning
that (given we got an instance of EditableTreeContext with
`getEditableTreeContext()`):
- one can call `context.unwrappedRoot` to get root of EditableTree with
all children fields unwrapped into just values of their nodes if those
are primitives and the field has a non-sequence schema, nodes with a
sequence primary field ("arrays") unwrapped into arrays and so on.
- and one can call `context.root` to get root field typed as
`EditableField`, where no unwrapping happens, and then iterate over its
nodes, which is just an array of EditableTrees.

In turn, one can iterate over `EditableTree` to get its fields as
EditableFields.

Please, check the `"traverse a complete tree (generic)"` test case and
the corresponding `expectFieldEquals` and `expectNodeEquals` helper
functions to see how this works.

Opinions, comments, suggestions are very welcomed.

**Step 3** in a series to push code from #12182 to enable editing of
EditableTree.

[Step 2](#12306)
[Step 1](#12300)
CraigMacomber added a commit that referenced this pull request Oct 27, 2022
Same as
[#12488](#12512), but
using a new cursor API.

## Description

This PR implements `EditableField` as an array-like sequence of nodes
(`EditableTrees`), which
1) replaces handling of sequence fields with arrays,
2) allows to access nodes lazily by their indices with and without
unwrapping, and
3) is a required change to implement editing of `EditableTree`.

## Reviewer Guidance

Everything around "root" probably might be considered as a workaround as
currently `cursor.getPath()` and anchors do not support fields.

Also, it seems that "primaryField" property of `FieldProxyTarget` is
redundant, as `fieldKey` is also there, but it adds clarity, and we
might make use of it when implementing editing.

## Other information or known dependencies

**Step 4** in a series to push code from #12182 to enable editing of
EditableTree.

[Step 3](#12428)
[Step 2](#12306)
[Step 1](#12300)

Co-authored-by: Craig Macomber (Microsoft) <42876482+CraigMacomber@users.noreply.github.com>
sharptrip added a commit to sharptrip/FluidFramework that referenced this pull request Oct 28, 2022
)

Same as
[microsoft#12488](microsoft#12512), but
using a new cursor API.

## Description

This PR implements `EditableField` as an array-like sequence of nodes
(`EditableTrees`), which
1) replaces handling of sequence fields with arrays,
2) allows to access nodes lazily by their indices with and without
unwrapping, and
3) is a required change to implement editing of `EditableTree`.

## Reviewer Guidance

Everything around "root" probably might be considered as a workaround as
currently `cursor.getPath()` and anchors do not support fields.

Also, it seems that "primaryField" property of `FieldProxyTarget` is
redundant, as `fieldKey` is also there, but it adds clarity, and we
might make use of it when implementing editing.

## Other information or known dependencies

**Step 4** in a series to push code from microsoft#12182 to enable editing of
EditableTree.

[Step 3](microsoft#12428)
[Step 2](microsoft#12306)
[Step 1](microsoft#12300)

Co-authored-by: Craig Macomber (Microsoft) <42876482+CraigMacomber@users.noreply.github.com>
alexvy86 pushed a commit to alexvy86/FluidFramework that referenced this pull request Nov 1, 2022
)

Same as
[microsoft#12488](microsoft#12512), but
using a new cursor API.

## Description

This PR implements `EditableField` as an array-like sequence of nodes
(`EditableTrees`), which
1) replaces handling of sequence fields with arrays,
2) allows to access nodes lazily by their indices with and without
unwrapping, and
3) is a required change to implement editing of `EditableTree`.

## Reviewer Guidance

Everything around "root" probably might be considered as a workaround as
currently `cursor.getPath()` and anchors do not support fields.

Also, it seems that "primaryField" property of `FieldProxyTarget` is
redundant, as `fieldKey` is also there, but it adds clarity, and we
might make use of it when implementing editing.

## Other information or known dependencies

**Step 4** in a series to push code from microsoft#12182 to enable editing of
EditableTree.

[Step 3](microsoft#12428)
[Step 2](microsoft#12306)
[Step 1](microsoft#12300)

Co-authored-by: Craig Macomber (Microsoft) <42876482+CraigMacomber@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dds Issues related to distributed data structures base: main PRs targeted against main branch community-contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants