diff --git a/docs/sources/developers/kinds/core/dashboard/schema-reference.md b/docs/sources/developers/kinds/core/dashboard/schema-reference.md index 61e08de0f56..1ad3b38a530 100644 --- a/docs/sources/developers/kinds/core/dashboard/schema-reference.md +++ b/docs/sources/developers/kinds/core/dashboard/schema-reference.md @@ -79,7 +79,7 @@ extraFields is reserved for any fields that are pulled from the API server metad | `description` | string | No | | Description of dashboard. | | `fiscalYearStartMonth` | integer | No | `0` | The month that the fiscal year starts on. 0 = January, 11 = December
Constraint: `>=0 & <12`. | | `gnetId` | string | No | | ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal | -| `id` | integer | No | | Unique numeric identifier for the dashboard.
`id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. | +| `id` | integer or null | No | | Unique numeric identifier for the dashboard.
`id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. | | `links` | [DashboardLink](#dashboardlink)[] | No | | Links with references to other dashboards or external websites. | | `liveNow` | boolean | No | | When set to true, the dashboard will redraw panels at an interval matching the pixel width.
This will keep data "moving left" regardless of the query refresh rate. This setting helps
avoid dashboards presenting stale live data | | `panels` | [object](#panels)[] | No | | List of dashboard panels | diff --git a/docs/sources/developers/kinds/core/preferences/schema-reference.md b/docs/sources/developers/kinds/core/preferences/schema-reference.md index 6c64554ad4d..16058084094 100644 --- a/docs/sources/developers/kinds/core/preferences/schema-reference.md +++ b/docs/sources/developers/kinds/core/preferences/schema-reference.md @@ -69,14 +69,38 @@ extraFields is reserved for any fields that are pulled from the API server metad ### Spec -| Property | Type | Required | Default | Description | -|--------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------| -| `homeDashboardUID` | string | No | | UID for the home dashboard | -| `language` | string | No | | Selected language (beta) | -| `queryHistory` | [QueryHistoryPreference](#queryhistorypreference) | No | | | -| `theme` | string | No | | light, dark, empty is default | -| `timezone` | string | No | | The timezone selection
TODO: this should use the timezone defined in common | -| `weekStart` | string | No | | day of the week (sunday, monday, etc) | +| Property | Type | Required | Default | Description | +|---------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------| +| `cookiePreferences` | [CookiePreferences](#cookiepreferences) | No | | | +| `homeDashboardUID` | string | No | | UID for the home dashboard | +| `language` | string | No | | Selected language (beta) | +| `queryHistory` | [QueryHistoryPreference](#queryhistorypreference) | No | | | +| `theme` | string | No | | light, dark, empty is default | +| `timezone` | string | No | | The timezone selection
TODO: this should use the timezone defined in common | +| `weekStart` | string | No | | day of the week (sunday, monday, etc) | + +### CookiePreferences + +| Property | Type | Required | Default | Description | +|---------------|------------------------|----------|---------|-------------| +| `analytics` | [object](#analytics) | No | | | +| `functional` | [object](#functional) | No | | | +| `performance` | [object](#performance) | No | | | + +### Analytics + +| Property | Type | Required | Default | Description | +|----------|------|----------|---------|-------------| + +### Functional + +| Property | Type | Required | Default | Description | +|----------|------|----------|---------|-------------| + +### Performance + +| Property | Type | Required | Default | Description | +|----------|------|----------|---------|-------------| ### QueryHistoryPreference diff --git a/kinds/dashboard/dashboard_kind.cue b/kinds/dashboard/dashboard_kind.cue index 6be812f7220..2cbaae5c3eb 100644 --- a/kinds/dashboard/dashboard_kind.cue +++ b/kinds/dashboard/dashboard_kind.cue @@ -17,7 +17,7 @@ lineage: schemas: [{ spec: { // Unique numeric identifier for the dashboard. // `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. - id?: int64 + id?: int64 | null // TODO eliminate this null option // Unique dashboard identifier that can be generated by anyone. string (8-40) uid?: string diff --git a/kinds/preferences/preferences_kind.cue b/kinds/preferences/preferences_kind.cue index ac43fdbca08..b6f189178c2 100644 --- a/kinds/preferences/preferences_kind.cue +++ b/kinds/preferences/preferences_kind.cue @@ -27,11 +27,20 @@ lineage: schemas: [{ // Explore query history preferences queryHistory?: #QueryHistoryPreference + + // Cookie preferences + cookiePreferences?: #CookiePreferences } @cuetsy(kind="interface") #QueryHistoryPreference: { // one of: '' | 'query' | 'starred'; homeTab?: string } @cuetsy(kind="interface") + + #CookiePreferences: { + analytics?: {} + performance?: {} + functional?: {} + } @cuetsy(kind="interface") } }] diff --git a/packages/grafana-schema/src/index.gen.ts b/packages/grafana-schema/src/index.gen.ts index d768fcc5bd6..e47906f4c77 100644 --- a/packages/grafana-schema/src/index.gen.ts +++ b/packages/grafana-schema/src/index.gen.ts @@ -137,7 +137,8 @@ export { defaultPlaylist } from './raw/playlist/x/playlist_types.gen'; // Raw generated types from Preferences kind. export type { Preferences, - QueryHistoryPreference + QueryHistoryPreference, + CookiePreferences } from './raw/preferences/x/preferences_types.gen'; // Raw generated types from PublicDashboard kind. diff --git a/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts b/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts index b67e646f01f..7c3f3d5b6ce 100644 --- a/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts +++ b/packages/grafana-schema/src/raw/dashboard/x/dashboard_types.gen.ts @@ -1021,7 +1021,7 @@ export interface Dashboard { * Unique numeric identifier for the dashboard. * `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. */ - id?: number; + id?: (number | null); // TODO eliminate this null option /** * Links with references to other dashboards or external websites. */ diff --git a/packages/grafana-schema/src/raw/preferences/x/preferences_types.gen.ts b/packages/grafana-schema/src/raw/preferences/x/preferences_types.gen.ts index 8921226ac94..d240e057545 100644 --- a/packages/grafana-schema/src/raw/preferences/x/preferences_types.gen.ts +++ b/packages/grafana-schema/src/raw/preferences/x/preferences_types.gen.ts @@ -15,7 +15,17 @@ export interface QueryHistoryPreference { homeTab?: string; } +export interface CookiePreferences { + analytics?: Record; + functional?: Record; + performance?: Record; +} + export interface Preferences { + /** + * Cookie preferences + */ + cookiePreferences?: CookiePreferences; /** * UID for the home dashboard */ diff --git a/pkg/codegen/jenny_go_resources.go b/pkg/codegen/jenny_go_resources.go index 13216f0d6c2..72a3dfa5f6b 100644 --- a/pkg/codegen/jenny_go_resources.go +++ b/pkg/codegen/jenny_go_resources.go @@ -49,7 +49,7 @@ func (ag *ResourceGoTypesJenny) Generate(kind kindsys.Kind) (*codejen.File, erro if err := tmpls.Lookup("core_resource.tmpl").Execute(buf, tvars_resource{ PackageName: mname, KindName: kind.Props().Common().Name, - Version: sch.Version().String(), + Version: strings.Replace(sfg.Schema.Version().String(), ".", "-", -1), SubresourceNames: subr, }); err != nil { return nil, fmt.Errorf("failed executing core resource template: %w", err) diff --git a/pkg/kinds/accesspolicy/accesspolicy_gen.go b/pkg/kinds/accesspolicy/accesspolicy_gen.go index b2833e0fd94..2c843382788 100644 --- a/pkg/kinds/accesspolicy/accesspolicy_gen.go +++ b/pkg/kinds/accesspolicy/accesspolicy_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "AccessPolicy", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/dashboard/dashboard_gen.go b/pkg/kinds/dashboard/dashboard_gen.go index 100a4683644..3022cd93658 100644 --- a/pkg/kinds/dashboard/dashboard_gen.go +++ b/pkg/kinds/dashboard/dashboard_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "Dashboard", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/dashboard/dashboard_spec_gen.go b/pkg/kinds/dashboard/dashboard_spec_gen.go index 437e9ec96b9..5b28cf46d00 100644 --- a/pkg/kinds/dashboard/dashboard_spec_gen.go +++ b/pkg/kinds/dashboard/dashboard_spec_gen.go @@ -740,7 +740,7 @@ type Spec struct { // Unique numeric identifier for the dashboard. // `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances. - Id *int64 `json:"id,omitempty"` + Id *int64 `json:"id"` // Links with references to other dashboards or external websites. Links []Link `json:"links,omitempty"` diff --git a/pkg/kinds/folder/folder_gen.go b/pkg/kinds/folder/folder_gen.go index c0d9f669d22..7b5a4d26500 100644 --- a/pkg/kinds/folder/folder_gen.go +++ b/pkg/kinds/folder/folder_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "Folder", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/librarypanel/librarypanel_gen.go b/pkg/kinds/librarypanel/librarypanel_gen.go index 92a8bb9c220..051a738b9f1 100644 --- a/pkg/kinds/librarypanel/librarypanel_gen.go +++ b/pkg/kinds/librarypanel/librarypanel_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "LibraryPanel", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/playlist/playlist_gen.go b/pkg/kinds/playlist/playlist_gen.go index b0ec8a23ca3..289e3cb5785 100644 --- a/pkg/kinds/playlist/playlist_gen.go +++ b/pkg/kinds/playlist/playlist_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "Playlist", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/preferences/preferences_gen.go b/pkg/kinds/preferences/preferences_gen.go index 16606278917..aec2fc93fbd 100644 --- a/pkg/kinds/preferences/preferences_gen.go +++ b/pkg/kinds/preferences/preferences_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "Preferences", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/preferences/preferences_spec_gen.go b/pkg/kinds/preferences/preferences_spec_gen.go index 8ac8df1ed1c..803e588e8c4 100644 --- a/pkg/kinds/preferences/preferences_spec_gen.go +++ b/pkg/kinds/preferences/preferences_spec_gen.go @@ -9,6 +9,13 @@ package preferences +// CookiePreferences defines model for CookiePreferences. +type CookiePreferences struct { + Analytics map[string]any `json:"analytics,omitempty"` + Functional map[string]any `json:"functional,omitempty"` + Performance map[string]any `json:"performance,omitempty"` +} + // QueryHistoryPreference defines model for QueryHistoryPreference. type QueryHistoryPreference struct { // HomeTab one of: '' | 'query' | 'starred'; @@ -17,6 +24,8 @@ type QueryHistoryPreference struct { // Spec defines model for Spec. type Spec struct { + CookiePreferences *CookiePreferences `json:"cookiePreferences,omitempty"` + // UID for the home dashboard HomeDashboardUID *string `json:"homeDashboardUID,omitempty"` diff --git a/pkg/kinds/publicdashboard/publicdashboard_gen.go b/pkg/kinds/publicdashboard/publicdashboard_gen.go index ab3789a6241..158fe87cf63 100644 --- a/pkg/kinds/publicdashboard/publicdashboard_gen.go +++ b/pkg/kinds/publicdashboard/publicdashboard_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "PublicDashboard", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/role/role_gen.go b/pkg/kinds/role/role_gen.go index 312653b71cb..a3bfb86a502 100644 --- a/pkg/kinds/role/role_gen.go +++ b/pkg/kinds/role/role_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "Role", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/rolebinding/rolebinding_gen.go b/pkg/kinds/rolebinding/rolebinding_gen.go index c0395ed55bc..c5177cafb9a 100644 --- a/pkg/kinds/rolebinding/rolebinding_gen.go +++ b/pkg/kinds/rolebinding/rolebinding_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "RoleBinding", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/kinds/team/team_gen.go b/pkg/kinds/team/team_gen.go index 39aec6e3939..c09d04fdf36 100644 --- a/pkg/kinds/team/team_gen.go +++ b/pkg/kinds/team/team_gen.go @@ -20,7 +20,7 @@ type K8sResource = kinds.GrafanaResource[Spec, Status] func NewK8sResource(name string, s *Spec) K8sResource { return K8sResource{ Kind: "Team", - APIVersion: "v0.0-alpha", + APIVersion: "v0-0-alpha", Metadata: kinds.GrafanaResourceMetadata{ Name: name, Annotations: make(map[string]string), diff --git a/pkg/services/dashboards/models_test.go b/pkg/services/dashboards/models_test.go index a799114cd44..dbacb303b86 100644 --- a/pkg/services/dashboards/models_test.go +++ b/pkg/services/dashboards/models_test.go @@ -114,7 +114,7 @@ func TestResourceConversion(t *testing.T) { require.NoError(t, err) fmt.Printf("%s", string(out)) require.JSONEq(t, `{ - "apiVersion": "v0.0-alpha", + "apiVersion": "v0-0-alpha", "kind": "Dashboard", "metadata": { "name": "TheUID", diff --git a/pkg/services/libraryelements/model/model_test.go b/pkg/services/libraryelements/model/model_test.go index acf7b975446..9ef45cf9e29 100644 --- a/pkg/services/libraryelements/model/model_test.go +++ b/pkg/services/libraryelements/model/model_test.go @@ -39,7 +39,7 @@ func TestLibaryPanelConversion(t *testing.T) { require.NoError(t, err) fmt.Printf("%s", string(out)) require.JSONEq(t, `{ - "apiVersion": "v0.0-alpha", + "apiVersion": "v0-0-alpha", "kind": "LibraryPanel", "metadata": { "name": "TheUID", diff --git a/pkg/services/playlist/model_test.go b/pkg/services/playlist/model_test.go index 34cc6f5ab04..f0eb722e10f 100644 --- a/pkg/services/playlist/model_test.go +++ b/pkg/services/playlist/model_test.go @@ -32,7 +32,7 @@ func TestPlaylistConversion(t *testing.T) { require.NoError(t, err) fmt.Printf("%s", string(out)) require.JSONEq(t, `{ - "apiVersion": "v0.0-alpha", + "apiVersion": "v0-0-alpha", "kind": "Playlist", "metadata": { "name": "abc", diff --git a/pkg/services/team/model_test.go b/pkg/services/team/model_test.go index bb4efd5de3b..e2c61a8e8b5 100644 --- a/pkg/services/team/model_test.go +++ b/pkg/services/team/model_test.go @@ -28,7 +28,7 @@ func TestTeamConversion(t *testing.T) { require.NoError(t, err) fmt.Printf("%s", string(out)) require.JSONEq(t, `{ - "apiVersion": "v0.0-alpha", + "apiVersion": "v0-0-alpha", "kind": "Team", "metadata": { "name": "abc",