Skip to content

Commit 020735d

Browse files
authored
Add EditorState to PA YAML schema to support editor UI ordering (#743)
1 parent cbe69dd commit 020735d

File tree

7 files changed

+127
-0
lines changed

7 files changed

+127
-0
lines changed

schemas/pa-yaml/v3.0/pa.schema.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ properties:
1616
$ref: "#/definitions/ComponentDefinitions-name-instance-map"
1717
DataSources:
1818
$ref: "#/definitions/DataSources-name-instance-map"
19+
EditorState:
20+
$ref: "#/definitions/EditorState"
1921

2022
defaultSnippets:
2123
- label: App
@@ -503,6 +505,22 @@ definitions:
503505
additionalProperties:
504506
$ref: "#/definitions/pfx-formula"
505507

508+
EditorState:
509+
description: Represents metadata related to the editor state of the application that enhances the editing experience.
510+
type: object
511+
additionalProperties: false
512+
properties:
513+
ScreensOrder:
514+
description: Ordered list of screen names representing the order in the editor.
515+
type: array
516+
items:
517+
$ref: "#/definitions/Screen-name"
518+
ComponentDefinitionsOrder:
519+
description: Ordered list of component definition names representing the order in the editor.
520+
type: array
521+
items:
522+
$ref: "#/definitions/ComponentDefinition-name"
523+
506524
entity-name:
507525
description: The base requirements for a named entity in an app.
508526
type: string

src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public void DeserializeDuplicateControlNamesShouldFail()
191191
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/Screens-general-controls.pa.yaml")]
192192
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/Screens-with-components.pa.yaml")]
193193
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/DataSources/Dataversedatasources1.pa.yaml")]
194+
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/_EditorState.pa.yaml")]
194195
public void RoundTripFromYaml(string path)
195196
{
196197
var originalYaml = File.ReadAllText(path);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3;
5+
6+
public record EditorStateInstance
7+
{
8+
public string[]? ScreensOrder { get; init; }
9+
10+
public string[]? ComponentDefinitionsOrder { get; init; }
11+
}

src/Persistence/PaYaml/Models/SchemaV3/PaModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ public record PaModule
1515
public NamedObjectMapping<ScreenInstance>? Screens { get; init; }
1616

1717
public NamedObjectMapping<DataSourceInstance>? DataSources { get; init; }
18+
19+
public EditorStateInstance? EditorState { get; init; }
1820
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
EditorState:
2+
ScreensOrder:
3+
- FirstScreen
4+
- SecondScreen
5+
- ThirdScreen
6+
ComponentDefinitionsOrder:
7+
- FirstComponent
8+
- SecondComponent
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
App:
2+
Properties:
3+
StartScreen: =Screen1
4+
5+
Screens:
6+
Screen1:
7+
Properties:
8+
Fill: =RGBA(255, 255, 255, 1)
9+
Children:
10+
- Button1:
11+
Control: Button
12+
Properties:
13+
Text: ="Navigate to Screen2"
14+
OnSelect: =Navigate(Screen2)
15+
X: =40
16+
Y: =40
17+
Screen3:
18+
Properties:
19+
Fill: =RGBA(240, 240, 240, 1)
20+
Children:
21+
- Label1:
22+
Control: Label
23+
Properties:
24+
Text: ="This is Screen3"
25+
X: =40
26+
Y: =40
27+
Screen2:
28+
Properties:
29+
Fill: =RGBA(245, 245, 245, 1)
30+
Children:
31+
- Button2:
32+
Control: Button
33+
Properties:
34+
Text: ="Navigate to Screen3"
35+
OnSelect: =Navigate(Screen3)
36+
X: =40
37+
Y: =40
38+
39+
ComponentDefinitions:
40+
Component2:
41+
DefinitionType: CanvasComponent
42+
Properties:
43+
Height: =50
44+
Width: =200
45+
Children:
46+
- Label1:
47+
Control: Label
48+
Properties:
49+
Text: ="Component 2"
50+
Component1:
51+
DefinitionType: CanvasComponent
52+
Properties:
53+
Height: =100
54+
Width: =250
55+
Children:
56+
- Label1:
57+
Control: Label
58+
Properties:
59+
Text: ="Component 1"
60+
61+
EditorState:
62+
ScreensOrder:
63+
- Screen1
64+
- Screen2
65+
- Screen3
66+
67+
ComponentDefinitionsOrder:
68+
- Component1
69+
- Component2

src/schemas/pa-yaml/v3.0/pa.schema.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ properties:
2121
$ref: "#/definitions/ComponentDefinitions-name-instance-map"
2222
DataSources:
2323
$ref: "#/definitions/DataSources-name-instance-map"
24+
EditorState:
25+
$ref: "#/definitions/EditorState"
2426

2527
defaultSnippets:
2628
- label: App
@@ -541,6 +543,22 @@ definitions:
541543
additionalProperties:
542544
$ref: "#/definitions/pfx-formula"
543545

546+
EditorState:
547+
description: Represents metadata related to the editor state of the application that enhances the editing experience.
548+
type: object
549+
additionalProperties: false
550+
properties:
551+
ScreensOrder:
552+
description: Ordered list of screen names representing the order in the editor.
553+
type: array
554+
items:
555+
$ref: "#/definitions/Screen-name"
556+
ComponentDefinitionsOrder:
557+
description: Ordered list of component definition names representing the order in the editor.
558+
type: array
559+
items:
560+
$ref: "#/definitions/ComponentDefinition-name"
561+
544562
entity-name:
545563
# aka: DName
546564
description: The base requirements for a named entity in an app.

0 commit comments

Comments
 (0)