Skip to content

Commit 50bc235

Browse files
authored
Merge pull request #7385 from TheThingsNetwork/feature/new-console-preferences-field
Add new `tutorials` field to `UserConsolePreferences`
2 parents 659abd0 + 048fb68 commit 50bc235

File tree

14 files changed

+1142
-549
lines changed

14 files changed

+1142
-549
lines changed

api/ttn/lorawan/v3/api.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,14 @@
819819
- [Message `UserConsolePreferences`](#ttn.lorawan.v3.UserConsolePreferences)
820820
- [Message `UserConsolePreferences.DashboardLayouts`](#ttn.lorawan.v3.UserConsolePreferences.DashboardLayouts)
821821
- [Message `UserConsolePreferences.SortBy`](#ttn.lorawan.v3.UserConsolePreferences.SortBy)
822+
- [Message `UserConsolePreferences.Tutorials`](#ttn.lorawan.v3.UserConsolePreferences.Tutorials)
822823
- [Message `UserSession`](#ttn.lorawan.v3.UserSession)
823824
- [Message `UserSessionIdentifiers`](#ttn.lorawan.v3.UserSessionIdentifiers)
824825
- [Message `UserSessions`](#ttn.lorawan.v3.UserSessions)
825826
- [Message `Users`](#ttn.lorawan.v3.Users)
826827
- [Enum `ConsoleTheme`](#ttn.lorawan.v3.ConsoleTheme)
827828
- [Enum `DashboardLayout`](#ttn.lorawan.v3.DashboardLayout)
829+
- [Enum `Tutorial`](#ttn.lorawan.v3.Tutorial)
828830
- [File `ttn/lorawan/v3/user_services.proto`](#ttn/lorawan/v3/user_services.proto)
829831
- [Service `UserAccess`](#ttn.lorawan.v3.UserAccess)
830832
- [Service `UserBookmarkRegistry`](#ttn.lorawan.v3.UserBookmarkRegistry)
@@ -11634,6 +11636,7 @@ UserConsolePreferences is the message that defines the user preferences for the
1163411636
| `console_theme` | [`ConsoleTheme`](#ttn.lorawan.v3.ConsoleTheme) | | |
1163511637
| `dashboard_layouts` | [`UserConsolePreferences.DashboardLayouts`](#ttn.lorawan.v3.UserConsolePreferences.DashboardLayouts) | | |
1163611638
| `sort_by` | [`UserConsolePreferences.SortBy`](#ttn.lorawan.v3.UserConsolePreferences.SortBy) | | |
11639+
| `tutorials` | [`UserConsolePreferences.Tutorials`](#ttn.lorawan.v3.UserConsolePreferences.Tutorials) | | |
1163711640

1163811641
### <a name="ttn.lorawan.v3.UserConsolePreferences.DashboardLayouts">Message `UserConsolePreferences.DashboardLayouts`</a>
1163911642

@@ -11674,6 +11677,18 @@ SortBy defines the field to which the Console will sort the display of entities.
1167411677
| `organization` | <p>`string.in`: `[ organization_id -organization_id name -name created_at -created_at]`</p> |
1167511678
| `user` | <p>`string.in`: `[ user_id -user_id name -name primary_email_address -primary_email_address state -state admin -admin created_at -created_at]`</p> |
1167611679

11680+
### <a name="ttn.lorawan.v3.UserConsolePreferences.Tutorials">Message `UserConsolePreferences.Tutorials`</a>
11681+
11682+
| Field | Type | Label | Description |
11683+
| ----- | ---- | ----- | ----------- |
11684+
| `seen` | [`Tutorial`](#ttn.lorawan.v3.Tutorial) | repeated | |
11685+
11686+
#### Field Rules
11687+
11688+
| Field | Validations |
11689+
| ----- | ----------- |
11690+
| `seen` | <p>`repeated.unique`: `true`</p><p>`repeated.items.enum.defined_only`: `true`</p> |
11691+
1167711692
### <a name="ttn.lorawan.v3.UserSession">Message `UserSession`</a>
1167811693

1167911694
| Field | Type | Label | Description |
@@ -11738,6 +11753,15 @@ DashboardLayout is a set of possible layout values to be used in the Console.
1173811753
| `DASHBOARD_LAYOUT_LIST` | 1 | |
1173911754
| `DASHBOARD_LAYOUT_GRID` | 2 | |
1174011755

11756+
### <a name="ttn.lorawan.v3.Tutorial">Enum `Tutorial`</a>
11757+
11758+
Tutorial is a set of possible tutorials in the Console.
11759+
11760+
| Name | Number | Description |
11761+
| ---- | ------ | ----------- |
11762+
| `TUTORIAL_UNKNOWN` | 0 | |
11763+
| `TUTORIAL_LIVE_DATA_SPLIT_VIEW` | 1 | |
11764+
1174111765
## <a name="ttn/lorawan/v3/user_services.proto">File `ttn/lorawan/v3/user_services.proto`</a>
1174211766

1174311767
### <a name="ttn.lorawan.v3.UserAccess">Service `UserAccess`</a>

api/ttn/lorawan/v3/api.swagger.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19010,6 +19010,17 @@
1901019010
},
1901119011
"description": "SortBy defines the field to which the Console will sort the display of entities."
1901219012
},
19013+
"UserConsolePreferencesTutorials": {
19014+
"type": "object",
19015+
"properties": {
19016+
"seen": {
19017+
"type": "array",
19018+
"items": {
19019+
"$ref": "#/definitions/v3Tutorial"
19020+
}
19021+
}
19022+
}
19023+
},
1901319024
"UserRegistrationAdminApproval": {
1901419025
"type": "object",
1901519026
"properties": {
@@ -29036,6 +29047,15 @@
2903629047
}
2903729048
}
2903829049
},
29050+
"v3Tutorial": {
29051+
"type": "string",
29052+
"enum": [
29053+
"TUTORIAL_UNKNOWN",
29054+
"TUTORIAL_LIVE_DATA_SPLIT_VIEW"
29055+
],
29056+
"default": "TUTORIAL_UNKNOWN",
29057+
"description": "Tutorial is a set of possible tutorials in the Console."
29058+
},
2903929059
"v3TxAcknowledgment": {
2904029060
"type": "object",
2904129061
"properties": {
@@ -29383,6 +29403,9 @@
2938329403
},
2938429404
"sort_by": {
2938529405
"$ref": "#/definitions/UserConsolePreferencesSortBy"
29406+
},
29407+
"tutorials": {
29408+
"$ref": "#/definitions/UserConsolePreferencesTutorials"
2938629409
}
2938729410
},
2938829411
"description": "UserConsolePreferences is the message that defines the user preferences for the Console."

api/ttn/lorawan/v3/user.proto

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ enum ConsoleTheme {
4343
CONSOLE_THEME_DARK = 2;
4444
}
4545

46+
// Tutorial is a set of possible tutorials in the Console.
47+
enum Tutorial {
48+
option (thethings.json.enum) = {marshal_as_string: true};
49+
50+
TUTORIAL_UNKNOWN = 0;
51+
TUTORIAL_LIVE_DATA_SPLIT_VIEW = 1;
52+
}
53+
4654
// DashboardLayout is a set of possible layout values to be used in the Console.
4755
enum DashboardLayout {
4856
option (thethings.json.enum) = {
@@ -171,6 +179,16 @@ message UserConsolePreferences {
171179
}];
172180
}
173181
SortBy sort_by = 3;
182+
183+
message Tutorials {
184+
repeated Tutorial seen = 1 [(validate.rules).repeated = {
185+
unique: true,
186+
items: {
187+
enum: {defined_only: true}
188+
}
189+
}];
190+
}
191+
Tutorials tutorials = 4;
174192
}
175193

176194
// User is the message that defines a user on the network.

pkg/identityserver/bunstore/user_store.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ func (s *userStore) updateUserModel( //nolint:gocyclo
597597
case "console_preferences.sort_by":
598598
updateConsolePreferences = true
599599
consolePreferences.SortBy = pb.ConsolePreferences.GetSortBy()
600+
case "console_preferences.tutorials":
601+
updateConsolePreferences = true
602+
consolePreferences.Tutorials = pb.ConsolePreferences.GetTutorials()
600603
case "universal_rights":
601604
columns = append(columns, "universal_rights")
602605
}

pkg/identityserver/storetest/user_store.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ func (st *StoreTest) TestUserStoreCRUD(t *T) {
221221
DashboardLayouts: &ttnpb.UserConsolePreferences_DashboardLayouts{
222222
ApiKey: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_LIST,
223223
},
224+
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
225+
Seen: []ttnpb.Tutorial{ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW},
226+
},
224227
},
225228
}, mask)
226229
if a.So(err, should.BeNil) && a.So(updated, should.NotBeNil) {
@@ -248,6 +251,9 @@ func (st *StoreTest) TestUserStoreCRUD(t *T) {
248251
DashboardLayouts: &ttnpb.UserConsolePreferences_DashboardLayouts{
249252
ApiKey: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_LIST,
250253
},
254+
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
255+
Seen: []ttnpb.Tutorial{ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW},
256+
},
251257
},
252258
)
253259
a.So(*ttnpb.StdTime(updated.CreatedAt), should.Equal, *ttnpb.StdTime(created.CreatedAt))

pkg/identityserver/user_registry_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,18 @@ func TestUsersCRUD(t *testing.T) {
424424
User: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_GRID,
425425
Overview: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_GRID,
426426
},
427+
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
428+
Seen: []ttnpb.Tutorial{
429+
ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW,
430+
},
431+
},
427432
},
428433
},
429434
FieldMask: ttnpb.FieldMask(
430435
"console_preferences.console_theme",
431436
"console_preferences.dashboard_layouts",
432437
"console_preferences.sort_by",
438+
"console_preferences.tutorials",
433439
),
434440
}, creds)
435441
if a.So(err, should.BeNil) {
@@ -457,6 +463,15 @@ func TestUsersCRUD(t *testing.T) {
457463
Overview: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_GRID,
458464
},
459465
)
466+
a.So(
467+
got.ConsolePreferences.GetTutorials(),
468+
should.Resemble,
469+
&ttnpb.UserConsolePreferences_Tutorials{
470+
Seen: []ttnpb.Tutorial{
471+
ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW,
472+
},
473+
},
474+
)
460475
}
461476
})
462477
})

0 commit comments

Comments
 (0)