Skip to content

Commit

Permalink
fix(ui): Show empty dashboards state
Browse files Browse the repository at this point in the history
  • Loading branch information
Timmy Luong authored and Timmy Luong committed Nov 12, 2019
1 parent 7421836 commit e14d399
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions ui/cypress/e2e/dashboardsIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ describe('Dashboards', () => {
})
})

it('empty state should have a header with text and a button to create a dashboard', () => {
cy.getByTestID('page-contents').within(() => {
cy.getByTestID('empty-dashboards-list').within(() => {
cy.getByTestID('empty-state--text').should($t => {
expect($t).to.have.length(1)
expect($t).to.contain(
"Looks like you don't have any Dashboards, why not create one?"
)
})
cy.getByTestID('add-resource-dropdown--button').should($b => {
expect($b).to.have.length(1)
expect($b).to.contain('Create Dashboard')
})
})
})
})

it('can create a dashboard from empty state', () => {
cy.getByTestID('empty-dashboards-list').within(() => {
cy.getByTestID('add-resource-dropdown--button').click()
Expand Down
8 changes: 4 additions & 4 deletions ui/src/dashboards/components/dashboard_index/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class DashboardsTable extends PureComponent<Props, State> {
</ResourceList.Header>
<ResourceList.Body
emptyState={this.emptyState}
className="dashboards-card-grid"
className={dashboards.length ? 'dashboards-card-grid' : ''}
>
{!!dashboards.length && (
{dashboards.length ? (
<DashboardCards
dashboards={dashboards}
sortKey={sortKey}
Expand All @@ -85,7 +85,7 @@ class DashboardsTable extends PureComponent<Props, State> {
onUpdateDashboard={onUpdateDashboard}
onFilterChange={onFilterChange}
/>
)}
) : null}
</ResourceList.Body>
</ResourceList>
)
Expand Down Expand Up @@ -129,7 +129,7 @@ class DashboardsTable extends PureComponent<Props, State> {
return (
<EmptyState size={ComponentSize.Large} testID="empty-dashboards-list">
<EmptyState.Text>
Looks like you dont have any <b>Dashboards</b>, why not create one?
Looks like you don't have any <b>Dashboards</b>, why not create one?
</EmptyState.Text>
<AddResourceDropdown
onSelectNew={onCreateDashboard}
Expand Down

0 comments on commit e14d399

Please sign in to comment.