Skip to content

Commit

Permalink
is: Add new tutorials field to console preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaplots committed Nov 15, 2024
1 parent dbbd34e commit 936d416
Showing 13 changed files with 1,119 additions and 546 deletions.
23 changes: 23 additions & 0 deletions api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
@@ -819,12 +819,14 @@
- [Message `UserConsolePreferences`](#ttn.lorawan.v3.UserConsolePreferences)
- [Message `UserConsolePreferences.DashboardLayouts`](#ttn.lorawan.v3.UserConsolePreferences.DashboardLayouts)
- [Message `UserConsolePreferences.SortBy`](#ttn.lorawan.v3.UserConsolePreferences.SortBy)
- [Message `UserConsolePreferences.Tutorials`](#ttn.lorawan.v3.UserConsolePreferences.Tutorials)
- [Message `UserSession`](#ttn.lorawan.v3.UserSession)
- [Message `UserSessionIdentifiers`](#ttn.lorawan.v3.UserSessionIdentifiers)
- [Message `UserSessions`](#ttn.lorawan.v3.UserSessions)
- [Message `Users`](#ttn.lorawan.v3.Users)
- [Enum `ConsoleTheme`](#ttn.lorawan.v3.ConsoleTheme)
- [Enum `DashboardLayout`](#ttn.lorawan.v3.DashboardLayout)
- [Enum `Tutorial`](#ttn.lorawan.v3.Tutorial)
- [File `ttn/lorawan/v3/user_services.proto`](#ttn/lorawan/v3/user_services.proto)
- [Service `UserAccess`](#ttn.lorawan.v3.UserAccess)
- [Service `UserBookmarkRegistry`](#ttn.lorawan.v3.UserBookmarkRegistry)
@@ -11634,6 +11636,7 @@ UserConsolePreferences is the message that defines the user preferences for the
| `console_theme` | [`ConsoleTheme`](#ttn.lorawan.v3.ConsoleTheme) | | |
| `dashboard_layouts` | [`UserConsolePreferences.DashboardLayouts`](#ttn.lorawan.v3.UserConsolePreferences.DashboardLayouts) | | |
| `sort_by` | [`UserConsolePreferences.SortBy`](#ttn.lorawan.v3.UserConsolePreferences.SortBy) | | |
| `tutorials` | [`UserConsolePreferences.Tutorials`](#ttn.lorawan.v3.UserConsolePreferences.Tutorials) | | |

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

@@ -11674,6 +11677,18 @@ SortBy defines the field to which the Console will sort the display of entities.
| `organization` | <p>`string.in`: `[ organization_id -organization_id name -name created_at -created_at]`</p> |
| `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> |

### <a name="ttn.lorawan.v3.UserConsolePreferences.Tutorials">Message `UserConsolePreferences.Tutorials`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `seen_tutorials` | [`Tutorial`](#ttn.lorawan.v3.Tutorial) | repeated | |

#### Field Rules

| Field | Validations |
| ----- | ----------- |
| `seen_tutorials` | <p>`repeated.unique`: `true`</p><p>`repeated.items.enum.defined_only`: `true`</p> |

### <a name="ttn.lorawan.v3.UserSession">Message `UserSession`</a>

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

### <a name="ttn.lorawan.v3.Tutorial">Enum `Tutorial`</a>

Tutorial is a set of possible tutorials in the Console.

| Name | Number | Description |
| ---- | ------ | ----------- |
| `LIVE_DATA_SPLIT_VIEW` | 0 | |

## <a name="ttn/lorawan/v3/user_services.proto">File `ttn/lorawan/v3/user_services.proto`</a>

### <a name="ttn.lorawan.v3.UserAccess">Service `UserAccess`</a>
22 changes: 22 additions & 0 deletions api/ttn/lorawan/v3/api.swagger.json
Original file line number Diff line number Diff line change
@@ -19010,6 +19010,17 @@
},
"description": "SortBy defines the field to which the Console will sort the display of entities."
},
"UserConsolePreferencesTutorials": {
"type": "object",
"properties": {
"seen_tutorials": {
"type": "array",
"items": {
"$ref": "#/definitions/v3Tutorial"
}
}
}
},
"UserRegistrationAdminApproval": {
"type": "object",
"properties": {
@@ -29036,6 +29047,14 @@
}
}
},
"v3Tutorial": {
"type": "string",
"enum": [
"LIVE_DATA_SPLIT_VIEW"
],
"default": "LIVE_DATA_SPLIT_VIEW",
"description": "Tutorial is a set of possible tutorials in the Console."
},
"v3TxAcknowledgment": {
"type": "object",
"properties": {
@@ -29383,6 +29402,9 @@
},
"sort_by": {
"$ref": "#/definitions/UserConsolePreferencesSortBy"
},
"tutorials": {
"$ref": "#/definitions/UserConsolePreferencesTutorials"
}
},
"description": "UserConsolePreferences is the message that defines the user preferences for the Console."
17 changes: 17 additions & 0 deletions api/ttn/lorawan/v3/user.proto
Original file line number Diff line number Diff line change
@@ -43,6 +43,13 @@ enum ConsoleTheme {
CONSOLE_THEME_DARK = 2;
}

// Tutorial is a set of possible tutorials in the Console.
enum Tutorial {
option (thethings.json.enum) = {marshal_as_string: true};

LIVE_DATA_SPLIT_VIEW = 0;
}

// DashboardLayout is a set of possible layout values to be used in the Console.
enum DashboardLayout {
option (thethings.json.enum) = {
@@ -171,6 +178,16 @@ message UserConsolePreferences {
}];
}
SortBy sort_by = 3;

message Tutorials {
repeated Tutorial seen_tutorials = 1 [(validate.rules).repeated = {
unique: true,
items: {
enum: {defined_only: true}
}
}];
}
Tutorials tutorials = 4;
}

// User is the message that defines a user on the network.
3 changes: 3 additions & 0 deletions pkg/identityserver/bunstore/user_store.go
Original file line number Diff line number Diff line change
@@ -597,6 +597,9 @@ func (s *userStore) updateUserModel( //nolint:gocyclo
case "console_preferences.sort_by":
updateConsolePreferences = true
consolePreferences.SortBy = pb.ConsolePreferences.GetSortBy()
case "console_preferences.tutorials":
updateConsolePreferences = true
consolePreferences.Tutorials = pb.ConsolePreferences.GetTutorials()
case "universal_rights":
columns = append(columns, "universal_rights")
}
6 changes: 6 additions & 0 deletions pkg/identityserver/storetest/user_store.go
Original file line number Diff line number Diff line change
@@ -221,6 +221,9 @@ func (st *StoreTest) TestUserStoreCRUD(t *T) {
DashboardLayouts: &ttnpb.UserConsolePreferences_DashboardLayouts{
ApiKey: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_LIST,
},
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
SeenTutorials: []ttnpb.Tutorial{ttnpb.Tutorial_LIVE_DATA_SPLIT_VIEW},
},
},
}, mask)
if a.So(err, should.BeNil) && a.So(updated, should.NotBeNil) {
@@ -248,6 +251,9 @@ func (st *StoreTest) TestUserStoreCRUD(t *T) {
DashboardLayouts: &ttnpb.UserConsolePreferences_DashboardLayouts{
ApiKey: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_LIST,
},
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
SeenTutorials: []ttnpb.Tutorial{ttnpb.Tutorial_LIVE_DATA_SPLIT_VIEW},
},
},
)
a.So(*ttnpb.StdTime(updated.CreatedAt), should.Equal, *ttnpb.StdTime(created.CreatedAt))
15 changes: 15 additions & 0 deletions pkg/identityserver/user_registry_test.go
Original file line number Diff line number Diff line change
@@ -424,12 +424,18 @@ func TestUsersCRUD(t *testing.T) {
User: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_GRID,
Overview: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_GRID,
},
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
SeenTutorials: []ttnpb.Tutorial{
ttnpb.Tutorial_LIVE_DATA_SPLIT_VIEW,
},
},
},
},
FieldMask: ttnpb.FieldMask(
"console_preferences.console_theme",
"console_preferences.dashboard_layouts",
"console_preferences.sort_by",
"console_preferences.tutorials",
),
}, creds)
if a.So(err, should.BeNil) {
@@ -457,6 +463,15 @@ func TestUsersCRUD(t *testing.T) {
Overview: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_GRID,
},
)
a.So(
got.ConsolePreferences.GetTutorials(),
should.Resemble,
&ttnpb.UserConsolePreferences_Tutorials{
SeenTutorials: []ttnpb.Tutorial{
ttnpb.Tutorial_LIVE_DATA_SPLIT_VIEW,
},
},
)
}
})
})
Loading

0 comments on commit 936d416

Please sign in to comment.