Merge pull request #13390 from zhulongcheng/rm-view-id

fix(http): remove viewID
pull/13391/head
Jade McGough 2019-04-13 22:05:44 -07:00 committed by GitHub
commit 5dfb7660f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 42 deletions

View File

@ -304,8 +304,6 @@ func (c *Client) createCellView(ctx context.Context, tx *bolt.Tx, dashID, cellID
// If not view exists create the view
view = &platform.View{}
}
// TODO: this is temporary until we can fully remove the view service.
view.ID = cellID
return c.putDashboardCellView(ctx, tx, dashID, cellID, view)
}

View File

@ -288,9 +288,8 @@ type View struct {
Properties ViewProperties
}
// ViewContents is the id and name of a specific view.
// ViewContents holds the non properties content of a View.
type ViewContents struct {
ID ID `json:"id,omitempty"`
Name string `json:"name"`
}

View File

@ -6,7 +6,6 @@ import (
"github.com/google/go-cmp/cmp"
platform "github.com/influxdata/influxdb"
platformtesting "github.com/influxdata/influxdb/testing"
)
func TestView_MarshalJSON(t *testing.T) {
@ -25,7 +24,6 @@ func TestView_MarshalJSON(t *testing.T) {
args: args{
view: platform.View{
ViewContents: platform.ViewContents{
ID: platformtesting.MustIDBase16("f01dab1ef005ba11"),
Name: "hello",
},
Properties: platform.XYViewProperties{
@ -36,7 +34,6 @@ func TestView_MarshalJSON(t *testing.T) {
wants: wants{
json: `
{
"id": "f01dab1ef005ba11",
"name": "hello",
"properties": {
"shape": "chronograf-v2",

View File

@ -266,7 +266,7 @@ func (r dashboardCellViewResponse) MarshalJSON() ([]byte, error) {
func newDashboardCellViewResponse(dashID, cellID platform.ID, v *platform.View) dashboardCellViewResponse {
return dashboardCellViewResponse{
Links: viewLinks{
Self: fmt.Sprintf("/api/v2/dashboards/%s/cells/%s", dashID, cellID),
Self: fmt.Sprintf("/api/v2/dashboards/%s/cells/%s/view", dashID, cellID),
},
View: *v,
}

View File

@ -6739,9 +6739,6 @@ components:
h:
type: integer
format: int32
viewID:
type: string
description: uses the view provided in the request
usingView:
type: string
description: makes a copy of the provided view
@ -6785,9 +6782,6 @@ components:
h:
type: integer
format: int32
viewID:
type: string
description: The reference to a view from the views API
Cells:
type: array
items:

View File

@ -154,8 +154,7 @@ func (s *Service) PutDashboard(ctx context.Context, d *platform.Dashboard) error
// PutCellView puts the view for a cell.
func (s *Service) PutCellView(ctx context.Context, cell *platform.Cell) error {
v := &platform.View{}
v.ID = cell.ID
return s.PutView(ctx, v)
return s.PutView(ctx, cell.ID, v)
}
// PutDashboardWithMeta sets a dashboard while updating the meta field of a dashboard.
@ -250,8 +249,7 @@ func (s *Service) AddDashboardCell(ctx context.Context, id platform.ID, cell *pl
func (s *Service) createCellView(ctx context.Context, cell *platform.Cell) *platform.Error {
// If not view exists create the view
view := &platform.View{}
view.ID = cell.ID
if err := s.PutView(ctx, view); err != nil {
if err := s.PutView(ctx, cell.ID, view); err != nil {
return &platform.Error{
Err: err,
}
@ -267,8 +265,7 @@ func (s *Service) PutDashboardCell(ctx context.Context, id platform.ID, cell *pl
return err
}
view := &platform.View{}
view.ID = cell.ID
if err := s.PutView(ctx, view); err != nil {
if err := s.PutView(ctx, cell.ID, view); err != nil {
return err
}
@ -436,7 +433,7 @@ func (s *Service) UpdateDashboardCellView(ctx context.Context, dashboardID, cell
}
}
if err := s.PutView(ctx, v); err != nil {
if err := s.PutView(ctx, cellID, v); err != nil {
return nil, &platform.Error{
Err: err,
Op: op,
@ -474,12 +471,12 @@ func (s *Service) FindViewByID(ctx context.Context, id platform.ID) (*platform.V
return v, nil
}
// PutView sets view with the current ID.
func (s *Service) PutView(ctx context.Context, c *platform.View) error {
if c.Properties == nil {
c.Properties = platform.EmptyViewProperties{}
// PutView sets view with the cell ID.
func (s *Service) PutView(ctx context.Context, cellID platform.ID, v *platform.View) error {
if v.Properties == nil {
v.Properties = platform.EmptyViewProperties{}
}
s.viewKV.Store(c.ID.String(), c)
s.viewKV.Store(cellID.String(), v)
return nil
}

View File

@ -332,8 +332,6 @@ func (s *Service) createCellView(ctx context.Context, tx Tx, dashID, cellID infl
// If not view exists create the view
view = &influxdb.View{}
}
// TODO: this is temporary until we can fully remove the view service.
view.ID = cellID
return s.putDashboardCellView(ctx, tx, dashID, cellID, view)
}

View File

@ -264,7 +264,7 @@ func AddDashboardCell(
Views: []*platform.View{
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashTwoID),
Name: "view2",
},
},
},
@ -312,7 +312,7 @@ func AddDashboardCell(
Views: []*platform.View{
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashTwoID),
Name: "view2",
},
},
},
@ -358,7 +358,7 @@ func AddDashboardCell(
Views: []*platform.View{
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashTwoID),
Name: "view2",
},
},
},
@ -1258,7 +1258,7 @@ func RemoveDashboardCell(
Views: []*platform.View{
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashTwoID),
Name: "view2",
},
},
},
@ -1546,12 +1546,12 @@ func ReplaceDashboardCells(
Views: []*platform.View{
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashTwoID),
Name: "view2",
},
},
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashOneID),
Name: "view1",
},
},
},
@ -1619,7 +1619,7 @@ func ReplaceDashboardCells(
Views: []*platform.View{
{
ViewContents: platform.ViewContents{
ID: MustIDBase16(dashTwoID),
Name: "view2",
},
},
},
@ -1734,10 +1734,8 @@ func GetDashboardCellView(
},
wants: wants{
view: &platform.View{
ViewContents: platform.ViewContents{
ID: 100,
},
Properties: platform.EmptyViewProperties{},
ViewContents: platform.ViewContents{},
Properties: platform.EmptyViewProperties{},
},
},
},
@ -1833,7 +1831,6 @@ func UpdateDashboardCellView(
wants: wants{
view: &platform.View{
ViewContents: platform.ViewContents{
ID: 100,
Name: "hello",
},
Properties: platform.EmptyViewProperties{},
@ -1859,6 +1856,7 @@ func UpdateDashboardCellView(
args: args{
dashboardID: 1,
cellID: 100,
name: "view100",
properties: platform.TableViewProperties{
Type: "table",
TimeFormat: "rfc3339",
@ -1867,7 +1865,7 @@ func UpdateDashboardCellView(
wants: wants{
view: &platform.View{
ViewContents: platform.ViewContents{
ID: 100,
Name: "view100",
},
Properties: platform.TableViewProperties{
Type: "table",
@ -1904,7 +1902,6 @@ func UpdateDashboardCellView(
wants: wants{
view: &platform.View{
ViewContents: platform.ViewContents{
ID: 100,
Name: "hello",
},
Properties: platform.TableViewProperties{