From 7ceb4b90f67f58bc93309adfd06a53a3eb6c097c Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 9 Oct 2025 15:38:52 +0300 Subject: [PATCH] Chore: Remove library panel thema (#112154) --- .github/CODEOWNERS | 1 - kinds/librarypanel/librarypanel_kind.cue | 63 ---------------- packages/grafana-schema/src/index.gen.ts | 17 ----- packages/grafana-schema/src/index.ts | 1 + .../librarypanel/x/librarypanel_types.gen.ts | 65 ---------------- .../src/veneer/librarypanel.types.ts | 54 +++++++++++++- pkg/kinds/librarypanel/librarypanel_gen.go | 43 ----------- .../librarypanel/librarypanel_metadata_gen.go | 42 ----------- .../librarypanel/librarypanel_spec_gen.go | 74 ------------------- .../librarypanel/librarypanel_status_gen.go | 74 ------------------- .../publicdashboard/publicdashboard_gen.go | 43 ----------- .../publicdashboard_metadata_gen.go | 42 ----------- .../publicdashboard_spec_gen.go | 32 -------- .../publicdashboard_status_gen.go | 74 ------------------- pkg/registry/schemas/core_kind.go | 9 --- pkg/services/libraryelements/api.go | 18 ++--- pkg/services/libraryelements/database.go | 21 +++--- .../libraryelements_create_test.go | 13 ++-- .../libraryelements_get_all_test.go | 65 ++++++++-------- .../libraryelements_get_test.go | 9 +-- .../libraryelements_patch_test.go | 12 ++- .../libraryelements/libraryelements_test.go | 3 +- pkg/services/libraryelements/model/model.go | 26 ++++--- .../librarypanels/librarypanels_test.go | 9 +-- .../panel-edit/PanelEditor.tsx | 2 +- .../scene/AddLibraryPanelDrawer.test.tsx | 2 +- .../variables/VariablesUnknownTable.tsx | 2 +- .../sharing/ExportButton/ResourceExport.tsx | 2 +- .../sharing/ShareExportTab.test.tsx | 2 +- .../sharing/ShareExportTab.tsx | 2 +- .../sharing/ShareLibraryPanelTab.tsx | 2 +- .../sharing/ShareSnapshotTab.tsx | 2 +- .../dashboard/components/ShareModal/types.ts | 2 +- .../AddLibraryPanelModal.tsx | 2 +- public/app/features/library-panels/types.ts | 3 +- 35 files changed, 149 insertions(+), 684 deletions(-) delete mode 100644 kinds/librarypanel/librarypanel_kind.cue delete mode 100644 packages/grafana-schema/src/raw/librarypanel/x/librarypanel_types.gen.ts delete mode 100644 pkg/kinds/librarypanel/librarypanel_gen.go delete mode 100644 pkg/kinds/librarypanel/librarypanel_metadata_gen.go delete mode 100644 pkg/kinds/librarypanel/librarypanel_spec_gen.go delete mode 100644 pkg/kinds/librarypanel/librarypanel_status_gen.go delete mode 100644 pkg/kinds/publicdashboard/publicdashboard_gen.go delete mode 100644 pkg/kinds/publicdashboard/publicdashboard_metadata_gen.go delete mode 100644 pkg/kinds/publicdashboard/publicdashboard_spec_gen.go delete mode 100644 pkg/kinds/publicdashboard/publicdashboard_status_gen.go diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 708740f5ce6..2af83368859 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -688,7 +688,6 @@ /packages/grafana-schema/src/**/grafanapyroscope @grafana/observability-traces-and-profiling /packages/grafana-schema/src/**/heatmap @grafana/dataviz-squad /packages/grafana-schema/src/**/histogram @grafana/dataviz-squad -/packages/grafana-schema/src/**/librarypanel @grafana/sharing-squad /packages/grafana-schema/src/**/logs @grafana/observability-logs /packages/grafana-schema/src/**/logsnew @grafana/observability-logs /packages/grafana-schema/src/**/loki @grafana/oss-big-tent @grafana/observability-logs diff --git a/kinds/librarypanel/librarypanel_kind.cue b/kinds/librarypanel/librarypanel_kind.cue deleted file mode 100644 index b87ceccb6fc..00000000000 --- a/kinds/librarypanel/librarypanel_kind.cue +++ /dev/null @@ -1,63 +0,0 @@ -package kind - -import ( - "strings" - "time" -) - -name: "LibraryPanel" -maturity: "experimental" -description: "A standalone panel" - -lineage: schemas: [{ - version: [0, 0] - schema: { - spec: { - // Folder UID - folderUid?: string @grafanamaturity(ToMetadata="sys") - - // Library element UID - uid: string - - // Panel name (also saved in the model) - name: string & strings.MinRunes(1) - - // Panel description - description?: string - - // The panel type (from inside the model) - type: string & strings.MinRunes(1) - - // Dashboard version when this was saved (zero if unknown) - schemaVersion?: uint16 - - // panel version, incremented each time the dashboard is updated. - version: int64 @grafanamaturity(NeedsExpertReview) - - // TODO: should be the same panel schema defined in dashboard - // Typescript: Omit; - model: {...} - - // Object storage metadata - meta?: #LibraryElementDTOMeta @grafanamaturity(ToMetadata="sys") - } @cuetsy(kind="interface") @grafana(TSVeneer="type") - - #LibraryElementDTOMetaUser: { - id: int64 - name: string - avatarUrl: string - } @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) - - #LibraryElementDTOMeta: { - folderName: string - folderUid: string @grafanamaturity(ToMetadata="sys") - connectedDashboards: int64 - - created: string & time.Time - updated: string & time.Time - - createdBy: #LibraryElementDTOMetaUser @grafanamaturity(ToMetadata="sys") - updatedBy: #LibraryElementDTOMetaUser @grafanamaturity(ToMetadata="sys") - } @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview) - } -}] diff --git a/packages/grafana-schema/src/index.gen.ts b/packages/grafana-schema/src/index.gen.ts index 5646058691b..87f2a3fd960 100644 --- a/packages/grafana-schema/src/index.gen.ts +++ b/packages/grafana-schema/src/index.gen.ts @@ -104,20 +104,3 @@ export { defaultFieldConfig, defaultRowPanel } from './veneer/dashboard.types'; - -// Raw generated types from LibraryPanel kind. -export type { - LibraryElementDTOMetaUser, - LibraryElementDTOMeta -} from './raw/librarypanel/x/librarypanel_types.gen'; - -// The following exported declarations correspond to types in the librarypanel@0.0 kind's -// schema with attribute @grafana(TSVeneer="type"). -// -// The handwritten file for these type and default veneers is expected to be at -// packages/grafana-schema/src/veneer/librarypanel.types.ts. -// This re-export declaration enforces that the handwritten veneer file exists, -// and exports all the symbols in the list. -// -// TODO generate code such that tsc enforces type compatibility between raw and veneer decls -export type { LibraryPanel } from './veneer/librarypanel.types'; diff --git a/packages/grafana-schema/src/index.ts b/packages/grafana-schema/src/index.ts index 505aded6a29..e7588ef48a1 100644 --- a/packages/grafana-schema/src/index.ts +++ b/packages/grafana-schema/src/index.ts @@ -4,4 +4,5 @@ * @packageDocumentation */ export * from './veneer/common.types'; +export * from './veneer/librarypanel.types'; export * from './index.gen'; diff --git a/packages/grafana-schema/src/raw/librarypanel/x/librarypanel_types.gen.ts b/packages/grafana-schema/src/raw/librarypanel/x/librarypanel_types.gen.ts deleted file mode 100644 index 97cba2a5c5e..00000000000 --- a/packages/grafana-schema/src/raw/librarypanel/x/librarypanel_types.gen.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// TSTypesJenny -// LatestMajorsOrXJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -export interface LibraryElementDTOMetaUser { - avatarUrl: string; - id: number; - name: string; -} - -export interface LibraryElementDTOMeta { - connectedDashboards: number; - created: string; - createdBy: LibraryElementDTOMetaUser; - folderName: string; - folderUid: string; - updated: string; - updatedBy: LibraryElementDTOMetaUser; -} - -export interface LibraryPanel { - /** - * Panel description - */ - description?: string; - /** - * Folder UID - */ - folderUid?: string; - /** - * Object storage metadata - */ - meta?: LibraryElementDTOMeta; - /** - * TODO: should be the same panel schema defined in dashboard - * Typescript: Omit; - */ - model: Record; - /** - * Panel name (also saved in the model) - */ - name: string; - /** - * Dashboard version when this was saved (zero if unknown) - */ - schemaVersion?: number; - /** - * The panel type (from inside the model) - */ - type: string; - /** - * Library element UID - */ - uid: string; - /** - * panel version, incremented each time the dashboard is updated. - */ - version: number; -} diff --git a/packages/grafana-schema/src/veneer/librarypanel.types.ts b/packages/grafana-schema/src/veneer/librarypanel.types.ts index 007bb085742..0065ebe25e2 100644 --- a/packages/grafana-schema/src/veneer/librarypanel.types.ts +++ b/packages/grafana-schema/src/veneer/librarypanel.types.ts @@ -1,7 +1,55 @@ -import * as raw from '../raw/librarypanel/x/librarypanel_types.gen'; - import { Panel } from './dashboard.types'; -export interface LibraryPanel extends raw.LibraryPanel { +export interface LibraryElementDTOMetaUser { + avatarUrl: string; + id: number; + name: string; +} + +export interface LibraryElementDTOMeta { + connectedDashboards: number; + created: string; + createdBy: LibraryElementDTOMetaUser; + folderName: string; + folderUid: string; + updated: string; + updatedBy: LibraryElementDTOMetaUser; +} + +export interface LibraryPanel { + /** + * Panel description + */ + description?: string; + /** + * Folder UID + */ + folderUid?: string; + /** + * Object storage metadata + */ + meta?: LibraryElementDTOMeta; + + // The panel model: Omit; + /** + * Panel name (also saved in the model) + */ + name: string; + /** + * Dashboard version when this was saved (zero if unknown) + */ + schemaVersion?: number; + /** + * The panel type (from inside the model) + */ + type: string; + /** + * Library element UID + */ + uid: string; + /** + * panel version, incremented each time the dashboard is updated. + */ + version: number; } diff --git a/pkg/kinds/librarypanel/librarypanel_gen.go b/pkg/kinds/librarypanel/librarypanel_gen.go deleted file mode 100644 index ea25be0ad4f..00000000000 --- a/pkg/kinds/librarypanel/librarypanel_gen.go +++ /dev/null @@ -1,43 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// K8ResourcesJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -package librarypanel - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/grafana/grafana/pkg/kinds" -) - -// Resource is the kubernetes style representation of LibraryPanel. (TODO be better) -type K8sResource = kinds.GrafanaResource[Spec, Status] - -// NewResource creates a new instance of the resource with a given name (UID) -func NewK8sResource(name string, s *Spec) K8sResource { - return K8sResource{ - TypeMeta: v1.TypeMeta{ - Kind: "LibraryPanel", - APIVersion: "v0-0-alpha", - }, - ObjectMeta: v1.ObjectMeta{ - Name: name, - Annotations: make(map[string]string), - Labels: make(map[string]string), - }, - Spec: s, - } -} - -// Resource is the wire representation of LibraryPanel. -// It currently will soon be merged into the k8s flavor (TODO be better) -type Resource struct { - Metadata Metadata `json:"metadata"` - Spec Spec `json:"spec"` - Status Status `json:"status"` -} diff --git a/pkg/kinds/librarypanel/librarypanel_metadata_gen.go b/pkg/kinds/librarypanel/librarypanel_metadata_gen.go deleted file mode 100644 index e899f28b1ff..00000000000 --- a/pkg/kinds/librarypanel/librarypanel_metadata_gen.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// K8ResourcesJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -package librarypanel - -import ( - "time" -) - -// Metadata defines model for Metadata. -type Metadata struct { - CreatedBy string `json:"createdBy"` - CreationTimestamp time.Time `json:"creationTimestamp"` - DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` - - // extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata - ExtraFields map[string]any `json:"extraFields"` - Finalizers []string `json:"finalizers"` - Labels map[string]string `json:"labels"` - ResourceVersion string `json:"resourceVersion"` - Uid string `json:"uid"` - UpdateTimestamp time.Time `json:"updateTimestamp"` - UpdatedBy string `json:"updatedBy"` -} - -// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field. -// It is not exhaustive and only includes fields which may be relevant to a kind's implementation, -// As it is also intended to be generic enough to function with any API Server. -type KubeObjectMetadata struct { - CreationTimestamp time.Time `json:"creationTimestamp"` - DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` - Finalizers []string `json:"finalizers"` - Labels map[string]string `json:"labels"` - ResourceVersion string `json:"resourceVersion"` - Uid string `json:"uid"` -} diff --git a/pkg/kinds/librarypanel/librarypanel_spec_gen.go b/pkg/kinds/librarypanel/librarypanel_spec_gen.go deleted file mode 100644 index cb5daf921a2..00000000000 --- a/pkg/kinds/librarypanel/librarypanel_spec_gen.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// GoResourceTypes -// -// Run 'make gen-cue' from repository root to regenerate. - -// Code generated - EDITING IS FUTILE. DO NOT EDIT. - -package librarypanel - -import ( - time "time" -) - -type Spec struct { - // Folder UID - FolderUid *string `json:"folderUid,omitempty"` - // Library element UID - Uid string `json:"uid"` - // Panel name (also saved in the model) - Name string `json:"name"` - // Panel description - Description *string `json:"description,omitempty"` - // The panel type (from inside the model) - Type string `json:"type"` - // Dashboard version when this was saved (zero if unknown) - SchemaVersion *uint16 `json:"schemaVersion,omitempty"` - // panel version, incremented each time the dashboard is updated. - Version int64 `json:"version"` - // TODO: should be the same panel schema defined in dashboard - // Typescript: Omit; - Model map[string]any `json:"model"` - // Object storage metadata - Meta *LibraryElementDTOMeta `json:"meta,omitempty"` -} - -// NewSpec creates a new Spec object. -func NewSpec() *Spec { - return &Spec{ - Model: map[string]any{}, - } -} - -type LibraryElementDTOMeta struct { - FolderName string `json:"folderName"` - FolderUid string `json:"folderUid"` - ConnectedDashboards int64 `json:"connectedDashboards"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - CreatedBy LibraryElementDTOMetaUser `json:"createdBy"` - UpdatedBy LibraryElementDTOMetaUser `json:"updatedBy"` -} - -// NewLibraryElementDTOMeta creates a new LibraryElementDTOMeta object. -func NewLibraryElementDTOMeta() *LibraryElementDTOMeta { - return &LibraryElementDTOMeta{ - CreatedBy: *NewLibraryElementDTOMetaUser(), - UpdatedBy: *NewLibraryElementDTOMetaUser(), - } -} - -type LibraryElementDTOMetaUser struct { - Id int64 `json:"id"` - Name string `json:"name"` - AvatarUrl string `json:"avatarUrl"` -} - -// NewLibraryElementDTOMetaUser creates a new LibraryElementDTOMetaUser object. -func NewLibraryElementDTOMetaUser() *LibraryElementDTOMetaUser { - return &LibraryElementDTOMetaUser{} -} diff --git a/pkg/kinds/librarypanel/librarypanel_status_gen.go b/pkg/kinds/librarypanel/librarypanel_status_gen.go deleted file mode 100644 index 69072c08dff..00000000000 --- a/pkg/kinds/librarypanel/librarypanel_status_gen.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// K8ResourcesJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -package librarypanel - -// Defines values for OperatorStateState. -const ( - OperatorStateStateFailed OperatorStateState = "failed" - OperatorStateStateInProgress OperatorStateState = "in_progress" - OperatorStateStateSuccess OperatorStateState = "success" -) - -// Defines values for StatusOperatorStateState. -const ( - StatusOperatorStateStateFailed StatusOperatorStateState = "failed" - StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress" - StatusOperatorStateStateSuccess StatusOperatorStateState = "success" -) - -// OperatorState defines model for OperatorState. -type OperatorState struct { - // descriptiveState is an optional more descriptive state field which has no requirements on format - DescriptiveState *string `json:"descriptiveState,omitempty"` - - // details contains any extra information that is operator-specific - Details map[string]any `json:"details,omitempty"` - - // lastEvaluation is the ResourceVersion last evaluated - LastEvaluation string `json:"lastEvaluation"` - - // state describes the state of the lastEvaluation. - // It is limited to three possible states for machine evaluation. - State OperatorStateState `json:"state"` -} - -// OperatorStateState state describes the state of the lastEvaluation. -// It is limited to three possible states for machine evaluation. -type OperatorStateState string - -// Status defines model for Status. -type Status struct { - // additionalFields is reserved for future use - AdditionalFields map[string]any `json:"additionalFields,omitempty"` - - // operatorStates is a map of operator ID to operator state evaluations. - // Any operator which consumes this kind SHOULD add its state evaluation information to this field. - OperatorStates map[string]StatusOperatorState `json:"operatorStates,omitempty"` -} - -// StatusOperatorState defines model for status.#OperatorState. -type StatusOperatorState struct { - // descriptiveState is an optional more descriptive state field which has no requirements on format - DescriptiveState *string `json:"descriptiveState,omitempty"` - - // details contains any extra information that is operator-specific - Details map[string]any `json:"details,omitempty"` - - // lastEvaluation is the ResourceVersion last evaluated - LastEvaluation string `json:"lastEvaluation"` - - // state describes the state of the lastEvaluation. - // It is limited to three possible states for machine evaluation. - State StatusOperatorStateState `json:"state"` -} - -// StatusOperatorStateState state describes the state of the lastEvaluation. -// It is limited to three possible states for machine evaluation. -type StatusOperatorStateState string diff --git a/pkg/kinds/publicdashboard/publicdashboard_gen.go b/pkg/kinds/publicdashboard/publicdashboard_gen.go deleted file mode 100644 index 68239e64690..00000000000 --- a/pkg/kinds/publicdashboard/publicdashboard_gen.go +++ /dev/null @@ -1,43 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// K8ResourcesJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -package publicdashboard - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/grafana/grafana/pkg/kinds" -) - -// Resource is the kubernetes style representation of PublicDashboard. (TODO be better) -type K8sResource = kinds.GrafanaResource[Spec, Status] - -// NewResource creates a new instance of the resource with a given name (UID) -func NewK8sResource(name string, s *Spec) K8sResource { - return K8sResource{ - TypeMeta: v1.TypeMeta{ - Kind: "PublicDashboard", - APIVersion: "v0-0-alpha", - }, - ObjectMeta: v1.ObjectMeta{ - Name: name, - Annotations: make(map[string]string), - Labels: make(map[string]string), - }, - Spec: s, - } -} - -// Resource is the wire representation of PublicDashboard. -// It currently will soon be merged into the k8s flavor (TODO be better) -type Resource struct { - Metadata Metadata `json:"metadata"` - Spec Spec `json:"spec"` - Status Status `json:"status"` -} diff --git a/pkg/kinds/publicdashboard/publicdashboard_metadata_gen.go b/pkg/kinds/publicdashboard/publicdashboard_metadata_gen.go deleted file mode 100644 index c5b84bf2700..00000000000 --- a/pkg/kinds/publicdashboard/publicdashboard_metadata_gen.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// K8ResourcesJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -package publicdashboard - -import ( - "time" -) - -// Metadata defines model for Metadata. -type Metadata struct { - CreatedBy string `json:"createdBy"` - CreationTimestamp time.Time `json:"creationTimestamp"` - DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` - - // extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata - ExtraFields map[string]any `json:"extraFields"` - Finalizers []string `json:"finalizers"` - Labels map[string]string `json:"labels"` - ResourceVersion string `json:"resourceVersion"` - Uid string `json:"uid"` - UpdateTimestamp time.Time `json:"updateTimestamp"` - UpdatedBy string `json:"updatedBy"` -} - -// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field. -// It is not exhaustive and only includes fields which may be relevant to a kind's implementation, -// As it is also intended to be generic enough to function with any API Server. -type KubeObjectMetadata struct { - CreationTimestamp time.Time `json:"creationTimestamp"` - DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` - Finalizers []string `json:"finalizers"` - Labels map[string]string `json:"labels"` - ResourceVersion string `json:"resourceVersion"` - Uid string `json:"uid"` -} diff --git a/pkg/kinds/publicdashboard/publicdashboard_spec_gen.go b/pkg/kinds/publicdashboard/publicdashboard_spec_gen.go deleted file mode 100644 index 667cf38cff1..00000000000 --- a/pkg/kinds/publicdashboard/publicdashboard_spec_gen.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// GoResourceTypes -// -// Run 'make gen-cue' from repository root to regenerate. - -// Code generated - EDITING IS FUTILE. DO NOT EDIT. - -package publicdashboard - -type Spec struct { - // Unique public dashboard identifier - Uid string `json:"uid"` - // Dashboard unique identifier referenced by this public dashboard - DashboardUid string `json:"dashboardUid"` - // Unique public access token - AccessToken *string `json:"accessToken,omitempty"` - // Flag that indicates if the public dashboard is enabled - IsEnabled bool `json:"isEnabled"` - // Flag that indicates if annotations are enabled - AnnotationsEnabled bool `json:"annotationsEnabled"` - // Flag that indicates if the time range picker is enabled - TimeSelectionEnabled bool `json:"timeSelectionEnabled"` -} - -// NewSpec creates a new Spec object. -func NewSpec() *Spec { - return &Spec{} -} diff --git a/pkg/kinds/publicdashboard/publicdashboard_status_gen.go b/pkg/kinds/publicdashboard/publicdashboard_status_gen.go deleted file mode 100644 index 95de4433cfe..00000000000 --- a/pkg/kinds/publicdashboard/publicdashboard_status_gen.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated - EDITING IS FUTILE. DO NOT EDIT. -// -// Generated by: -// kinds/gen.go -// Using jennies: -// K8ResourcesJenny -// -// Run 'make gen-cue' from repository root to regenerate. - -package publicdashboard - -// Defines values for OperatorStateState. -const ( - OperatorStateStateFailed OperatorStateState = "failed" - OperatorStateStateInProgress OperatorStateState = "in_progress" - OperatorStateStateSuccess OperatorStateState = "success" -) - -// Defines values for StatusOperatorStateState. -const ( - StatusOperatorStateStateFailed StatusOperatorStateState = "failed" - StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress" - StatusOperatorStateStateSuccess StatusOperatorStateState = "success" -) - -// OperatorState defines model for OperatorState. -type OperatorState struct { - // descriptiveState is an optional more descriptive state field which has no requirements on format - DescriptiveState *string `json:"descriptiveState,omitempty"` - - // details contains any extra information that is operator-specific - Details map[string]any `json:"details,omitempty"` - - // lastEvaluation is the ResourceVersion last evaluated - LastEvaluation string `json:"lastEvaluation"` - - // state describes the state of the lastEvaluation. - // It is limited to three possible states for machine evaluation. - State OperatorStateState `json:"state"` -} - -// OperatorStateState state describes the state of the lastEvaluation. -// It is limited to three possible states for machine evaluation. -type OperatorStateState string - -// Status defines model for Status. -type Status struct { - // additionalFields is reserved for future use - AdditionalFields map[string]any `json:"additionalFields,omitempty"` - - // operatorStates is a map of operator ID to operator state evaluations. - // Any operator which consumes this kind SHOULD add its state evaluation information to this field. - OperatorStates map[string]StatusOperatorState `json:"operatorStates,omitempty"` -} - -// StatusOperatorState defines model for status.#OperatorState. -type StatusOperatorState struct { - // descriptiveState is an optional more descriptive state field which has no requirements on format - DescriptiveState *string `json:"descriptiveState,omitempty"` - - // details contains any extra information that is operator-specific - Details map[string]any `json:"details,omitempty"` - - // lastEvaluation is the ResourceVersion last evaluated - LastEvaluation string `json:"lastEvaluation"` - - // state describes the state of the lastEvaluation. - // It is limited to three possible states for machine evaluation. - State StatusOperatorStateState `json:"state"` -} - -// StatusOperatorStateState state describes the state of the lastEvaluation. -// It is limited to three possible states for machine evaluation. -type StatusOperatorStateState string diff --git a/pkg/registry/schemas/core_kind.go b/pkg/registry/schemas/core_kind.go index c60b38d6161..1c8a9e37802 100644 --- a/pkg/registry/schemas/core_kind.go +++ b/pkg/registry/schemas/core_kind.go @@ -39,15 +39,6 @@ func GetCoreKinds() ([]CoreKind, error) { CueFile: dashboardCue, }) - librarypanelCue, err := loadCueFile(ctx, filepath.Join(root, "./kinds/librarypanel/librarypanel_kind.cue")) - if err != nil { - return nil, err - } - kinds = append(kinds, CoreKind{ - Name: "librarypanel", - CueFile: librarypanelCue, - }) - return kinds, nil } diff --git a/pkg/services/libraryelements/api.go b/pkg/services/libraryelements/api.go index 55ad2c01082..791cef618a9 100644 --- a/pkg/services/libraryelements/api.go +++ b/pkg/services/libraryelements/api.go @@ -8,13 +8,18 @@ import ( "net/http" "strings" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/dynamic" + dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" "github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/api/response" "github.com/grafana/grafana/pkg/api/routing" "github.com/grafana/grafana/pkg/apimachinery/utils" "github.com/grafana/grafana/pkg/infra/metrics" - "github.com/grafana/grafana/pkg/kinds/librarypanel" ac "github.com/grafana/grafana/pkg/services/accesscontrol" grafanaapiserver "github.com/grafana/grafana/pkg/services/apiserver" "github.com/grafana/grafana/pkg/services/apiserver/endpoints/request" @@ -28,11 +33,6 @@ import ( "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/util/errhttp" "github.com/grafana/grafana/pkg/web" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/dynamic" ) func (l *LibraryElementService) registerAPIEndpoints() { @@ -340,7 +340,7 @@ func (l *LibraryElementService) getConnectionsHandler(c *contextmodel.ReqContext ConnectionID: dashboard.ID, // nolint:staticcheck ConnectionUID: dashboard.UID, // returns the creation information of the library element, not the connection - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: element.Meta.CreatedBy.Id, Name: element.Meta.CreatedBy.Name, AvatarUrl: element.Meta.CreatedBy.AvatarUrl, @@ -713,7 +713,7 @@ func (lk8s *libraryElementsK8sHandler) unstructuredToLegacyLibraryPanelDTO(c *co } for _, user := range users { if user.UID == createdBy { - dto.Meta.CreatedBy = librarypanel.LibraryElementDTOMetaUser{ + dto.Meta.CreatedBy = model.LibraryElementDTOMetaUser{ Id: user.ID, Name: user.Login, AvatarUrl: dtos.GetGravatarUrl(lk8s.cfg, user.Email), @@ -721,7 +721,7 @@ func (lk8s *libraryElementsK8sHandler) unstructuredToLegacyLibraryPanelDTO(c *co } // not else because /api returns the same user for updated if it was never updated if user.UID == updatedBy { - dto.Meta.UpdatedBy = librarypanel.LibraryElementDTOMetaUser{ + dto.Meta.UpdatedBy = model.LibraryElementDTOMetaUser{ Id: user.ID, Name: user.Login, AvatarUrl: dtos.GetGravatarUrl(lk8s.cfg, user.Email), diff --git a/pkg/services/libraryelements/database.go b/pkg/services/libraryelements/database.go index 82531e39077..d4923ffa20a 100644 --- a/pkg/services/libraryelements/database.go +++ b/pkg/services/libraryelements/database.go @@ -12,7 +12,6 @@ import ( "github.com/grafana/grafana/pkg/apimachinery/identity" "github.com/grafana/grafana/pkg/infra/db" "github.com/grafana/grafana/pkg/infra/metrics" - "github.com/grafana/grafana/pkg/kinds/librarypanel" ac "github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/dashboards" "github.com/grafana/grafana/pkg/services/featuremgmt" @@ -200,12 +199,12 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn ConnectedDashboards: 0, Created: element.Created, Updated: element.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: element.CreatedBy, Name: signedInUser.GetLogin(), AvatarUrl: dtos.GetGravatarUrl(l.Cfg, signedInUser.GetEmail()), }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: element.UpdatedBy, Name: signedInUser.GetLogin(), AvatarUrl: dtos.GetGravatarUrl(l.Cfg, signedInUser.GetEmail()), @@ -363,12 +362,12 @@ func (l *LibraryElementService) getLibraryElements(c context.Context, store db.D ConnectedDashboards: libraryElement.ConnectedDashboards, Created: libraryElement.Created, Updated: libraryElement.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: libraryElement.CreatedBy, Name: libraryElement.CreatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, libraryElement.CreatedByEmail), }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: libraryElement.UpdatedBy, Name: libraryElement.UpdatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, libraryElement.UpdatedByEmail), @@ -509,12 +508,12 @@ func (l *LibraryElementService) getAllLibraryElements(c context.Context, signedI ConnectedDashboards: element.ConnectedDashboards, Created: element.Created, Updated: element.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: element.CreatedBy, Name: element.CreatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.CreatedByEmail), }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: element.UpdatedBy, Name: element.UpdatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.UpdatedByEmail), @@ -670,12 +669,12 @@ func (l *LibraryElementService) patchLibraryElement(c context.Context, signedInU ConnectedDashboards: elementInDB.ConnectedDashboards, Created: libraryElement.Created, Updated: libraryElement.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: elementInDB.CreatedBy, Name: elementInDB.CreatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, elementInDB.CreatedByEmail), }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: libraryElement.UpdatedBy, Name: signedInUser.GetLogin(), AvatarUrl: dtos.GetGravatarUrl(l.Cfg, signedInUser.GetEmail()), @@ -761,12 +760,12 @@ func (l *LibraryElementService) getElementsForDashboardID(c context.Context, das ConnectedDashboards: element.ConnectedDashboards, Created: element.Created, Updated: element.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: element.CreatedBy, Name: element.CreatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.CreatedByEmail), }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: element.UpdatedBy, Name: element.UpdatedByName, AvatarUrl: dtos.GetGravatarUrl(l.Cfg, element.UpdatedByEmail), diff --git a/pkg/services/libraryelements/libraryelements_create_test.go b/pkg/services/libraryelements/libraryelements_create_test.go index a4aea2e0241..36f2100308c 100644 --- a/pkg/services/libraryelements/libraryelements_create_test.go +++ b/pkg/services/libraryelements/libraryelements_create_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "github.com/grafana/grafana/pkg/kinds/librarypanel" "github.com/grafana/grafana/pkg/services/libraryelements/model" "github.com/grafana/grafana/pkg/util" "github.com/grafana/grafana/pkg/util/testutil" @@ -51,12 +50,12 @@ func TestIntegration_CreateLibraryElement(t *testing.T) { ConnectedDashboards: 0, Created: sc.initialResult.Result.Meta.Created, Updated: sc.initialResult.Result.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", @@ -102,12 +101,12 @@ func TestIntegration_CreateLibraryElement(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Meta.Created, Updated: result.Result.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", @@ -181,12 +180,12 @@ func TestIntegration_CreateLibraryElement(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Meta.Created, Updated: result.Result.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", diff --git a/pkg/services/libraryelements/libraryelements_get_all_test.go b/pkg/services/libraryelements/libraryelements_get_all_test.go index de58848ec15..612f5a9c279 100644 --- a/pkg/services/libraryelements/libraryelements_get_all_test.go +++ b/pkg/services/libraryelements/libraryelements_get_all_test.go @@ -7,7 +7,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "github.com/grafana/grafana/pkg/kinds/librarypanel" "github.com/grafana/grafana/pkg/services/folder" "github.com/grafana/grafana/pkg/services/libraryelements/model" "github.com/grafana/grafana/pkg/services/org" @@ -84,12 +83,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -120,12 +119,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[1].Meta.Created, Updated: result.Result.Elements[1].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -187,12 +186,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -223,12 +222,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[1].Meta.Created, Updated: result.Result.Elements[1].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -312,12 +311,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -348,12 +347,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[1].Meta.Created, Updated: result.Result.Elements[1].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -462,12 +461,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -562,12 +561,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -598,12 +597,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[1].Meta.Created, Updated: result.Result.Elements[1].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -665,12 +664,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -732,12 +731,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -800,12 +799,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -878,12 +877,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -954,12 +953,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -990,12 +989,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[1].Meta.Created, Updated: result.Result.Elements[1].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -1059,12 +1058,12 @@ func TestIntegration_GetAllLibraryElements(t *testing.T) { ConnectedDashboards: 0, Created: result.Result.Elements[0].Meta.Created, Updated: result.Result.Elements[0].Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, diff --git a/pkg/services/libraryelements/libraryelements_get_test.go b/pkg/services/libraryelements/libraryelements_get_test.go index 69fc7d24462..c85c22ee676 100644 --- a/pkg/services/libraryelements/libraryelements_get_test.go +++ b/pkg/services/libraryelements/libraryelements_get_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" "github.com/grafana/grafana/pkg/infra/db" - "github.com/grafana/grafana/pkg/kinds/librarypanel" "github.com/grafana/grafana/pkg/services/dashboards" "github.com/grafana/grafana/pkg/services/folder" "github.com/grafana/grafana/pkg/services/libraryelements/model" @@ -61,12 +60,12 @@ func TestIntegration_GetLibraryElement(t *testing.T) { ConnectedDashboards: 0, Created: res.Result.Meta.Created, Updated: res.Result.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, @@ -161,12 +160,12 @@ func TestIntegration_GetLibraryElement(t *testing.T) { ConnectedDashboards: 1, Created: res.Result.Meta.Created, Updated: res.Result.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, diff --git a/pkg/services/libraryelements/libraryelements_patch_test.go b/pkg/services/libraryelements/libraryelements_patch_test.go index a2bf31309f4..0cf29a83857 100644 --- a/pkg/services/libraryelements/libraryelements_patch_test.go +++ b/pkg/services/libraryelements/libraryelements_patch_test.go @@ -3,14 +3,12 @@ package libraryelements import ( "testing" - "github.com/grafana/grafana/pkg/kinds/librarypanel" - "github.com/grafana/grafana/pkg/services/folder" - "github.com/grafana/grafana/pkg/services/libraryelements/model" - "github.com/grafana/grafana/pkg/util" - "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" + "github.com/grafana/grafana/pkg/services/folder" + "github.com/grafana/grafana/pkg/services/libraryelements/model" + "github.com/grafana/grafana/pkg/util" "github.com/grafana/grafana/pkg/util/testutil" "github.com/grafana/grafana/pkg/web" ) @@ -83,12 +81,12 @@ func TestIntegration_PatchLibraryElement(t *testing.T) { ConnectedDashboards: 0, Created: sc.initialResult.Result.Meta.Created, Updated: result.Result.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: "signed_in_user", AvatarUrl: "/avatar/37524e1eb8b3e32850b57db0a19af93b", diff --git a/pkg/services/libraryelements/libraryelements_test.go b/pkg/services/libraryelements/libraryelements_test.go index 7a4faa08fbd..e782c20ac03 100644 --- a/pkg/services/libraryelements/libraryelements_test.go +++ b/pkg/services/libraryelements/libraryelements_test.go @@ -19,7 +19,6 @@ import ( "github.com/grafana/grafana/pkg/infra/db" "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/tracing" - "github.com/grafana/grafana/pkg/kinds/librarypanel" "github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/accesscontrol/acimpl" acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock" @@ -118,7 +117,7 @@ func TestIntegration_GetLibraryPanelConnections(t *testing.T) { ElementID: 1, ConnectionID: 1, Created: res.Result[0].Created, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, diff --git a/pkg/services/libraryelements/model/model.go b/pkg/services/libraryelements/model/model.go index 82b30fc6f60..6e2bdfdcc41 100644 --- a/pkg/services/libraryelements/model/model.go +++ b/pkg/services/libraryelements/model/model.go @@ -4,8 +4,6 @@ import ( "encoding/json" "errors" "time" - - "github.com/grafana/grafana/pkg/kinds/librarypanel" ) type LibraryConnectionKind int @@ -99,8 +97,8 @@ type LibraryElementDTOMeta struct { Created time.Time `json:"created"` Updated time.Time `json:"updated"` - CreatedBy librarypanel.LibraryElementDTOMetaUser `json:"createdBy"` - UpdatedBy librarypanel.LibraryElementDTOMetaUser `json:"updatedBy"` + CreatedBy LibraryElementDTOMetaUser `json:"createdBy"` + UpdatedBy LibraryElementDTOMetaUser `json:"updatedBy"` } // libraryElementConnection is the model for library element connections. @@ -126,16 +124,22 @@ type LibraryElementConnectionWithMeta struct { CreatedByEmail string } +type LibraryElementDTOMetaUser struct { + Id int64 `json:"id"` + Name string `json:"name"` + AvatarUrl string `json:"avatarUrl"` +} + // LibraryElementConnectionDTO is the frontend DTO for element connections. type LibraryElementConnectionDTO struct { // Deprecated: this field will be removed in the future - ID int64 `json:"id"` - Kind int64 `json:"kind"` - ElementID int64 `json:"elementId"` - ConnectionID int64 `json:"connectionId"` - ConnectionUID string `json:"connectionUid"` - Created time.Time `json:"created"` - CreatedBy librarypanel.LibraryElementDTOMetaUser `json:"createdBy"` + ID int64 `json:"id"` + Kind int64 `json:"kind"` + ElementID int64 `json:"elementId"` + ConnectionID int64 `json:"connectionId"` + ConnectionUID string `json:"connectionUid"` + Created time.Time `json:"created"` + CreatedBy LibraryElementDTOMetaUser `json:"createdBy"` } var ( diff --git a/pkg/services/librarypanels/librarypanels_test.go b/pkg/services/librarypanels/librarypanels_test.go index e47a9b6738d..a5ebd74d609 100644 --- a/pkg/services/librarypanels/librarypanels_test.go +++ b/pkg/services/librarypanels/librarypanels_test.go @@ -14,7 +14,6 @@ import ( "github.com/grafana/grafana/pkg/components/simplejson" "github.com/grafana/grafana/pkg/infra/db" "github.com/grafana/grafana/pkg/infra/tracing" - "github.com/grafana/grafana/pkg/kinds/librarypanel" "github.com/grafana/grafana/pkg/services/accesscontrol/actest" "github.com/grafana/grafana/pkg/services/dashboards" "github.com/grafana/grafana/pkg/services/featuremgmt" @@ -656,12 +655,12 @@ func toLibraryElement(t *testing.T, res model.LibraryElementDTO) libraryElement ConnectedDashboards: res.Meta.ConnectedDashboards, Created: res.Meta.Created, Updated: res.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: res.Meta.CreatedBy.Id, Name: res.Meta.CreatedBy.Name, AvatarUrl: res.Meta.CreatedBy.AvatarUrl, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: res.Meta.UpdatedBy.Id, Name: res.Meta.UpdatedBy.Name, AvatarUrl: res.Meta.UpdatedBy.AvatarUrl, @@ -694,12 +693,12 @@ func getExpected(t *testing.T, res model.LibraryElementDTO, UID string, name str ConnectedDashboards: 0, Created: res.Meta.Created, Updated: res.Meta.Updated, - CreatedBy: librarypanel.LibraryElementDTOMetaUser{ + CreatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, }, - UpdatedBy: librarypanel.LibraryElementDTOMetaUser{ + UpdatedBy: model.LibraryElementDTOMetaUser{ Id: 1, Name: userInDbName, AvatarUrl: userInDbAvatar, diff --git a/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx b/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx index fa8b5a601e8..1fe646ca69b 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelEditor.tsx @@ -17,7 +17,7 @@ import { VizPanel, isSceneObject, } from '@grafana/scenes'; -import { Panel } from '@grafana/schema/dist/esm/index.gen'; +import { Panel } from '@grafana/schema'; import { OptionFilter } from 'app/features/dashboard/components/PanelEditor/OptionsPaneOptions'; import { getLastUsedDatasourceFromStorage } from 'app/features/dashboard/utils/dashboard'; import { saveLibPanel } from 'app/features/library-panels/state/api'; diff --git a/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.test.tsx b/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.test.tsx index a1bbb12ac8c..06ccc67becf 100644 --- a/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.test.tsx +++ b/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.test.tsx @@ -1,5 +1,5 @@ import { SceneTimeRange, VizPanel } from '@grafana/scenes'; -import { LibraryPanel } from '@grafana/schema/dist/esm/index.gen'; +import { LibraryPanel } from '@grafana/schema'; import { activateFullSceneTree } from '../utils/test-utils'; diff --git a/public/app/features/dashboard-scene/settings/variables/VariablesUnknownTable.tsx b/public/app/features/dashboard-scene/settings/variables/VariablesUnknownTable.tsx index da216fd78ba..c392066b08f 100644 --- a/public/app/features/dashboard-scene/settings/variables/VariablesUnknownTable.tsx +++ b/public/app/features/dashboard-scene/settings/variables/VariablesUnknownTable.tsx @@ -6,7 +6,7 @@ import { GrafanaTheme2 } from '@grafana/data'; import { Trans, t } from '@grafana/i18n'; import { reportInteraction } from '@grafana/runtime'; import { SceneVariable, SceneVariableState } from '@grafana/scenes'; -import { Dashboard } from '@grafana/schema/dist/esm/index.gen'; +import { Dashboard } from '@grafana/schema'; import { CollapsableSection, Icon, Spinner, Stack, Tooltip, useStyles2 } from '@grafana/ui'; import { VariableUsagesButton } from '../../variables/VariableUsagesButton'; diff --git a/public/app/features/dashboard-scene/sharing/ExportButton/ResourceExport.tsx b/public/app/features/dashboard-scene/sharing/ExportButton/ResourceExport.tsx index 6543b641927..b58bf8377af 100644 --- a/public/app/features/dashboard-scene/sharing/ExportButton/ResourceExport.tsx +++ b/public/app/features/dashboard-scene/sharing/ExportButton/ResourceExport.tsx @@ -2,7 +2,7 @@ import { AsyncState } from 'react-use/lib/useAsync'; import { selectors as e2eSelectors } from '@grafana/e2e-selectors'; import { Trans, t } from '@grafana/i18n'; -import { Dashboard } from '@grafana/schema/dist/esm/index.gen'; +import { Dashboard } from '@grafana/schema'; import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2'; import { Alert, Label, RadioButtonGroup, Stack, Switch } from '@grafana/ui'; import { DashboardJson } from 'app/features/manage-dashboards/types'; diff --git a/public/app/features/dashboard-scene/sharing/ShareExportTab.test.tsx b/public/app/features/dashboard-scene/sharing/ShareExportTab.test.tsx index 8fa8c102ee6..1e7bee6b613 100644 --- a/public/app/features/dashboard-scene/sharing/ShareExportTab.test.tsx +++ b/public/app/features/dashboard-scene/sharing/ShareExportTab.test.tsx @@ -1,6 +1,6 @@ import { config } from '@grafana/runtime'; import { SceneTimeRange } from '@grafana/scenes'; -import { Dashboard } from '@grafana/schema/dist/esm/index.gen'; +import { Dashboard } from '@grafana/schema'; import { Spec as DashboardV2Spec, defaultQueryGroupKind, diff --git a/public/app/features/dashboard-scene/sharing/ShareExportTab.tsx b/public/app/features/dashboard-scene/sharing/ShareExportTab.tsx index ea52c8b0da3..0e9d6ad49c5 100644 --- a/public/app/features/dashboard-scene/sharing/ShareExportTab.tsx +++ b/public/app/features/dashboard-scene/sharing/ShareExportTab.tsx @@ -7,7 +7,7 @@ import AutoSizer from 'react-virtualized-auto-sizer'; import { Trans, t } from '@grafana/i18n'; import { config } from '@grafana/runtime'; import { SceneComponentProps, SceneObjectBase } from '@grafana/scenes'; -import { Dashboard } from '@grafana/schema/dist/esm/index.gen'; +import { Dashboard } from '@grafana/schema'; import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2'; import { Button, ClipboardButton, CodeEditor, Field, Modal, Stack, Switch } from '@grafana/ui'; import { ObjectMeta } from 'app/features/apiserver/types'; diff --git a/public/app/features/dashboard-scene/sharing/ShareLibraryPanelTab.tsx b/public/app/features/dashboard-scene/sharing/ShareLibraryPanelTab.tsx index 53a0a9dc222..4c882b60618 100644 --- a/public/app/features/dashboard-scene/sharing/ShareLibraryPanelTab.tsx +++ b/public/app/features/dashboard-scene/sharing/ShareLibraryPanelTab.tsx @@ -1,6 +1,6 @@ import { t } from '@grafana/i18n'; import { SceneComponentProps, SceneObjectBase, SceneObjectRef, VizPanel } from '@grafana/scenes'; -import { LibraryPanel } from '@grafana/schema/dist/esm/index.gen'; +import { LibraryPanel } from '@grafana/schema'; import { ShareLibraryPanel } from 'app/features/dashboard/components/ShareModal/ShareLibraryPanel'; import { shareDashboardType } from 'app/features/dashboard/components/ShareModal/utils'; import { DashboardModel } from 'app/features/dashboard/state/DashboardModel'; diff --git a/public/app/features/dashboard-scene/sharing/ShareSnapshotTab.tsx b/public/app/features/dashboard-scene/sharing/ShareSnapshotTab.tsx index e47aef533db..6c02dd93830 100644 --- a/public/app/features/dashboard-scene/sharing/ShareSnapshotTab.tsx +++ b/public/app/features/dashboard-scene/sharing/ShareSnapshotTab.tsx @@ -5,7 +5,7 @@ import { selectors as e2eSelectors } from '@grafana/e2e-selectors'; import { Trans, t } from '@grafana/i18n'; import { getBackendSrv } from '@grafana/runtime'; import { SceneComponentProps, sceneGraph, SceneObjectBase, SceneObjectRef, VizPanel } from '@grafana/scenes'; -import { Dashboard } from '@grafana/schema/dist/esm/index.gen'; +import { Dashboard } from '@grafana/schema'; import { Button, ClipboardButton, Field, Input, Modal, RadioButtonGroup, Stack } from '@grafana/ui'; import { notifyApp } from 'app/core/actions'; import { createSuccessNotification } from 'app/core/copy/appNotification'; diff --git a/public/app/features/dashboard/components/ShareModal/types.ts b/public/app/features/dashboard/components/ShareModal/types.ts index 54992ec1657..0dcfa36dc1e 100644 --- a/public/app/features/dashboard/components/ShareModal/types.ts +++ b/public/app/features/dashboard/components/ShareModal/types.ts @@ -1,7 +1,7 @@ import * as React from 'react'; import { NavModelItem } from '@grafana/data'; -import { LibraryPanel } from '@grafana/schema/dist/esm/index.gen'; +import { LibraryPanel } from '@grafana/schema'; import { DashboardModel } from 'app/features/dashboard/state/DashboardModel'; import { PanelModel } from 'app/features/dashboard/state/PanelModel'; diff --git a/public/app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal.tsx b/public/app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal.tsx index 753b01e8e15..57de268b917 100644 --- a/public/app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal.tsx +++ b/public/app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal.tsx @@ -3,7 +3,7 @@ import { useAsync, useDebounce } from 'react-use'; import { Trans, t } from '@grafana/i18n'; import { FetchError, isFetchError } from '@grafana/runtime'; -import { LibraryPanel } from '@grafana/schema/dist/esm/index.gen'; +import { LibraryPanel } from '@grafana/schema'; import { Button, Field, Input, Modal, Stack } from '@grafana/ui'; import { FolderPicker } from 'app/core/components/Select/FolderPicker'; diff --git a/public/app/features/library-panels/types.ts b/public/app/features/library-panels/types.ts index 5ce33b72620..5fc3883dba8 100644 --- a/public/app/features/library-panels/types.ts +++ b/public/app/features/library-panels/types.ts @@ -1,8 +1,7 @@ import { AnyAction } from '@reduxjs/toolkit'; import { Dispatch } from 'react'; -import { LibraryPanel } from '@grafana/schema'; -import { LibraryElementDTOMetaUser } from '@grafana/schema/src/raw/librarypanel/x/librarypanel_types.gen'; +import { LibraryPanel, LibraryElementDTOMetaUser } from '@grafana/schema'; import { PanelModel } from '../dashboard/state/PanelModel';