mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Playlist: Split PlaylistItem into standalone TS type (#56343)
* playlist: Split PlaylistItem into standalone TS type * update playlist model * actually set the title Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
parent
2c1c98f3b6
commit
ba97b268d0
@ -76,7 +76,10 @@ export {
|
|||||||
} from './veneer/dashboard.types';
|
} from './veneer/dashboard.types';
|
||||||
|
|
||||||
// Raw generated types from playlist entity type.
|
// Raw generated types from playlist entity type.
|
||||||
export type { Playlist } from './raw/playlist/x/playlist.gen';
|
export type {
|
||||||
|
Playlist,
|
||||||
|
PlaylistItem
|
||||||
|
} from './raw/playlist/x/playlist.gen';
|
||||||
|
|
||||||
// Raw generated default consts from playlist entity type.
|
// Raw generated default consts from playlist entity type.
|
||||||
export { defaultPlaylist } from './raw/playlist/x/playlist.gen';
|
export { defaultPlaylist } from './raw/playlist/x/playlist.gen';
|
||||||
|
@ -6,6 +6,28 @@
|
|||||||
//
|
//
|
||||||
// Run `make gen-cue` from repository root to regenerate.
|
// Run `make gen-cue` from repository root to regenerate.
|
||||||
|
|
||||||
|
export interface PlaylistItem {
|
||||||
|
/**
|
||||||
|
* Title is an unused property -- it will be removed in the future
|
||||||
|
*/
|
||||||
|
title?: string;
|
||||||
|
/**
|
||||||
|
* Type of the item.
|
||||||
|
*/
|
||||||
|
type: ('dashboard_by_uid' | 'dashboard_by_id' | 'dashboard_by_tag');
|
||||||
|
/**
|
||||||
|
* Value depends on type and describes the playlist item.
|
||||||
|
*
|
||||||
|
* - dashboard_by_id: The value is an internal numerical identifier set by Grafana. This
|
||||||
|
* is not portable as the numerical identifier is non-deterministic between different instances.
|
||||||
|
* Will be replaced by dashboard_by_uid in the future. (deprecated)
|
||||||
|
* - dashboard_by_tag: The value is a tag which is set on any number of dashboards. All
|
||||||
|
* dashboards behind the tag will be added to the playlist.
|
||||||
|
* - dashboard_by_uid: The value is the dashboard UID
|
||||||
|
*/
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Playlist {
|
export interface Playlist {
|
||||||
/**
|
/**
|
||||||
* Interval sets the time between switching views in a playlist.
|
* Interval sets the time between switching views in a playlist.
|
||||||
@ -15,27 +37,7 @@ export interface Playlist {
|
|||||||
/**
|
/**
|
||||||
* The ordered list of items that the playlist will iterate over.
|
* The ordered list of items that the playlist will iterate over.
|
||||||
*/
|
*/
|
||||||
items?: Array<{
|
items?: Array<PlaylistItem>;
|
||||||
/**
|
|
||||||
* Type of the item.
|
|
||||||
*/
|
|
||||||
type: ('dashboard_by_uid' | 'dashboard_by_id' | 'dashboard_by_tag');
|
|
||||||
/**
|
|
||||||
* Value depends on type and describes the playlist item.
|
|
||||||
*
|
|
||||||
* - dashboard_by_id: The value is an internal numerical identifier set by Grafana. This
|
|
||||||
* is not portable as the numerical identifier is non-deterministic between different instances.
|
|
||||||
* Will be replaced by dashboard_by_uid in the future. (deprecated)
|
|
||||||
* - dashboard_by_tag: The value is a tag which is set on any number of dashboards. All
|
|
||||||
* dashboards behind the tag will be added to the playlist.
|
|
||||||
* - dashboard_by_uid: The value is the dashboard UID
|
|
||||||
*/
|
|
||||||
value: string;
|
|
||||||
/**
|
|
||||||
* Title is an unused property -- it will be removed in the future
|
|
||||||
*/
|
|
||||||
title: string;
|
|
||||||
}>;
|
|
||||||
/**
|
/**
|
||||||
* Name of the playlist.
|
* Name of the playlist.
|
||||||
*/
|
*/
|
||||||
|
@ -39,10 +39,10 @@ seqs: [
|
|||||||
// dashboards behind the tag will be added to the playlist.
|
// dashboards behind the tag will be added to the playlist.
|
||||||
// - dashboard_by_uid: The value is the dashboard UID
|
// - dashboard_by_uid: The value is the dashboard UID
|
||||||
value: string
|
value: string
|
||||||
|
|
||||||
// Title is an unused property -- it will be removed in the future
|
// Title is an unused property -- it will be removed in the future
|
||||||
title: string
|
title?: string
|
||||||
}
|
} @cuetsy(kind="interface")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ type Model struct {
|
|||||||
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
|
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
|
||||||
type PlaylistItem struct {
|
type PlaylistItem struct {
|
||||||
// Title is an unused property -- it will be removed in the future
|
// Title is an unused property -- it will be removed in the future
|
||||||
Title string `json:"title"`
|
Title *string `json:"title,omitempty"`
|
||||||
|
|
||||||
// Type of the item.
|
// Type of the item.
|
||||||
Type PlaylistItemType `json:"type"`
|
Type PlaylistItemType `json:"type"`
|
||||||
|
@ -55,6 +55,12 @@ func (s *Service) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*
|
|||||||
for i := 0; i < len(rawItems); i++ {
|
for i := 0; i < len(rawItems); i++ {
|
||||||
items[i].Type = playlist.PlaylistItemType(rawItems[i].Type)
|
items[i].Type = playlist.PlaylistItemType(rawItems[i].Type)
|
||||||
items[i].Value = rawItems[i].Value
|
items[i].Value = rawItems[i].Value
|
||||||
|
|
||||||
|
// Add the unused title to the result
|
||||||
|
title := rawItems[i].Title
|
||||||
|
if title != "" {
|
||||||
|
items[i].Title = &title
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &playlist.PlaylistDTO{
|
return &playlist.PlaylistDTO{
|
||||||
Uid: v.UID,
|
Uid: v.UID,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { PlaylistItem as PlaylistItemFromSchema } from '@grafana/schema/src/raw/playlist/x/playlist.gen';
|
||||||
|
|
||||||
import { DashboardQueryResult } from '../search/service';
|
import { DashboardQueryResult } from '../search/service';
|
||||||
|
|
||||||
export type PlaylistMode = boolean | 'tv';
|
export type PlaylistMode = boolean | 'tv';
|
||||||
@ -16,10 +18,7 @@ export interface Playlist {
|
|||||||
items?: PlaylistItem[];
|
items?: PlaylistItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlaylistItem {
|
export interface PlaylistItem extends PlaylistItemFromSchema {
|
||||||
type: 'dashboard_by_tag' | 'dashboard_by_uid' | 'dashboard_by_id'; // _by_id is deprecated
|
|
||||||
value: string; // tag or uid
|
|
||||||
|
|
||||||
// Loaded in the frontend
|
// Loaded in the frontend
|
||||||
dashboards?: DashboardQueryResult[];
|
dashboards?: DashboardQueryResult[];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user