Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new tutorials field to UserConsolePreferences #7385

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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` | [`Tutorial`](#ttn.lorawan.v3.Tutorial) | repeated | |

#### Field Rules

| Field | Validations |
| ----- | ----------- |
| `seen` | <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 |
Expand Down Expand Up @@ -11738,6 +11753,15 @@ 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 |
| ---- | ------ | ----------- |
| `TUTORIAL_UNKNOWN` | 0 | |
| `TUTORIAL_LIVE_DATA_SPLIT_VIEW` | 1 | |

## <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>
Expand Down
23 changes: 23 additions & 0 deletions api/ttn/lorawan/v3/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -19010,6 +19010,17 @@
},
"description": "SortBy defines the field to which the Console will sort the display of entities."
},
"UserConsolePreferencesTutorials": {
"type": "object",
"properties": {
"seen": {
"type": "array",
"items": {
"$ref": "#/definitions/v3Tutorial"
}
}
}
},
"UserRegistrationAdminApproval": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -29036,6 +29047,15 @@
}
}
},
"v3Tutorial": {
"type": "string",
"enum": [
"TUTORIAL_UNKNOWN",
"TUTORIAL_LIVE_DATA_SPLIT_VIEW"
],
"default": "TUTORIAL_UNKNOWN",
"description": "Tutorial is a set of possible tutorials in the Console."
},
"v3TxAcknowledgment": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -29383,6 +29403,9 @@
},
"sort_by": {
"$ref": "#/definitions/UserConsolePreferencesSortBy"
},
"tutorials": {
"$ref": "#/definitions/UserConsolePreferencesTutorials"
}
},
"description": "UserConsolePreferences is the message that defines the user preferences for the Console."
Expand Down
18 changes: 18 additions & 0 deletions api/ttn/lorawan/v3/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ 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};

TUTORIAL_UNKNOWN = 0;
TUTORIAL_LIVE_DATA_SPLIT_VIEW = 1;
}

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

message Tutorials {
repeated Tutorial seen = 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.
Expand Down
3 changes: 3 additions & 0 deletions pkg/identityserver/bunstore/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/identityserver/storetest/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func (st *StoreTest) TestUserStoreCRUD(t *T) {
DashboardLayouts: &ttnpb.UserConsolePreferences_DashboardLayouts{
ApiKey: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_LIST,
},
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
Seen: []ttnpb.Tutorial{ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW},
},
},
}, mask)
if a.So(err, should.BeNil) && a.So(updated, should.NotBeNil) {
Expand Down Expand Up @@ -248,6 +251,9 @@ func (st *StoreTest) TestUserStoreCRUD(t *T) {
DashboardLayouts: &ttnpb.UserConsolePreferences_DashboardLayouts{
ApiKey: ttnpb.DashboardLayout_DASHBOARD_LAYOUT_LIST,
},
Tutorials: &ttnpb.UserConsolePreferences_Tutorials{
Seen: []ttnpb.Tutorial{ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW},
},
},
)
a.So(*ttnpb.StdTime(updated.CreatedAt), should.Equal, *ttnpb.StdTime(created.CreatedAt))
Expand Down
15 changes: 15 additions & 0 deletions pkg/identityserver/user_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Seen: []ttnpb.Tutorial{
ttnpb.Tutorial_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) {
Expand Down Expand Up @@ -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{
Seen: []ttnpb.Tutorial{
ttnpb.Tutorial_TUTORIAL_LIVE_DATA_SPLIT_VIEW,
},
},
)
}
})
})
Expand Down
Loading
Loading