-
Notifications
You must be signed in to change notification settings - Fork 12.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboards: Add alert and panel icon for dashboards that use Angular plugins #70951
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
2699779
Add angularDeprecationUI feature toggle
xnyo a24c027
Add angular notice in angular panel header
xnyo d90a1a6
Show angular notice for angular datasources
xnyo f620b2e
Show angular notice at the top of the dashboard
xnyo e31186b
Changed Angular deprecation messages
xnyo deefb45
Fix angular deprecation alert displayed for new dashboards
xnyo 7b92ad9
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo 42167f4
re-generate feature flags
xnyo 04769b9
Removed unnecessary changes
xnyo 6e0312a
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo f45ade8
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo eeba481
Add angular deprecation dashboard notice tests
xnyo 5e4b3d6
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo a3ae948
Add test for angular deprecation panel icon
xnyo 98272dd
Update test suite name
xnyo f7edb15
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo 03c584e
Moved isAngularDatasourcePlugin to app/features/plugins/angularDeprec…
xnyo 92293c0
Add hasAngularPlugins to DashboardModel
xnyo 21e1abc
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo bbff4fb
re-generate feature toggles
xnyo b158f11
Fix tests
xnyo b03b20c
Fix data source spelling
xnyo b4e3910
Merge remote-tracking branch 'origin/main' into giuseppe/angular-depr…
xnyo d4b6d8c
Fix typing issues
xnyo 30e1127
Extract plugin type into a separate function
xnyo e41d759
re-generate feature flags
xnyo 1ec452b
reportInteraction on angular dashboard notice dismiss
xnyo ab7aa12
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo 4fa06ca
re-generate feature flags
xnyo 7da7b3b
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo 5b7f023
Re-generate feature flags
xnyo ced643e
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo 49f57c2
Merge branch 'main' into giuseppe/angular-deprecation/dashboard
xnyo db6d1bf
lint
xnyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderTitleItems.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { LoadingState, TimeRange } from '@grafana/data'; | ||
|
||
import { AngularNotice, PanelHeaderTitleItems } from './PanelHeaderTitleItems'; | ||
|
||
function renderComponent(angularNoticeOverride?: Partial<AngularNotice>) { | ||
render( | ||
<PanelHeaderTitleItems | ||
data={{ | ||
series: [], | ||
state: LoadingState.Done, | ||
timeRange: {} as TimeRange, | ||
}} | ||
panelId={1} | ||
angularNotice={{ | ||
...{ | ||
show: true, | ||
isAngularDatasource: false, | ||
isAngularPanel: false, | ||
}, | ||
...angularNoticeOverride, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
describe('PanelHeaderTitleItems angular deprecation', () => { | ||
const iconSelector = 'angular-deprecation-icon'; | ||
it('should render angular warning icon for angular plugins', () => { | ||
renderComponent(); | ||
expect(screen.getByTestId(iconSelector)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not render angular warning icon for non-angular plugins', () => { | ||
renderComponent({ show: false }); | ||
expect(screen.queryByTestId(iconSelector)).not.toBeInTheDocument(); | ||
}); | ||
|
||
describe('Tooltip text', () => { | ||
const tests = [ | ||
{ | ||
name: 'panel', | ||
isAngularPanel: true, | ||
isAngularDatasource: false, | ||
expect: /This panel requires Angular/i, | ||
}, | ||
{ | ||
name: 'datasource', | ||
isAngularPanel: false, | ||
isAngularDatasource: true, | ||
expect: /This data source requires Angular/i, | ||
}, | ||
{ | ||
name: 'unknown (generic)', | ||
isAngularPanel: false, | ||
isAngularDatasource: false, | ||
expect: /This panel or data source requires Angular/i, | ||
}, | ||
]; | ||
tests.forEach((test) => { | ||
it(`should render the correct tooltip depending on plugin type for {test.name}`, async () => { | ||
renderComponent({ | ||
isAngularDatasource: test.isAngularDatasource, | ||
isAngularPanel: test.isAngularPanel, | ||
}); | ||
await userEvent.hover(screen.getByTestId(iconSelector)); | ||
await waitFor(() => { | ||
expect(screen.getByText(test.expect)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
public/app/features/plugins/angularDeprecation/AngularDeprecationNotice.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { reportInteraction } from '@grafana/runtime'; | ||
|
||
import { AngularDeprecationNotice } from './AngularDeprecationNotice'; | ||
|
||
jest.mock('@grafana/runtime', () => ({ | ||
...jest.requireActual('@grafana/runtime'), | ||
reportInteraction: jest.fn(), | ||
})); | ||
|
||
function localStorageKey(dsUid: string) { | ||
return `grafana.angularDeprecation.dashboardNotice.isDismissed.${dsUid}`; | ||
} | ||
|
||
describe('AngularDeprecationNotice', () => { | ||
const noticeText = /This dashboard depends on Angular/i; | ||
const dsUid = 'abc'; | ||
|
||
afterAll(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
window.localStorage.clear(); | ||
}); | ||
|
||
it('should render', () => { | ||
render(<AngularDeprecationNotice dashboardUid={dsUid} />); | ||
expect(screen.getByText(noticeText)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should be dismissable', async () => { | ||
render(<AngularDeprecationNotice dashboardUid={dsUid} />); | ||
const closeButton = screen.getByRole('button'); | ||
expect(closeButton).toBeInTheDocument(); | ||
await userEvent.click(closeButton); | ||
expect(screen.queryByText(noticeText)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should persist dismission status in localstorage', async () => { | ||
render(<AngularDeprecationNotice dashboardUid={dsUid} />); | ||
expect(window.localStorage.getItem(localStorageKey(dsUid))).toBeNull(); | ||
const closeButton = screen.getByRole('button'); | ||
expect(closeButton).toBeInTheDocument(); | ||
await userEvent.click(closeButton); | ||
expect(window.localStorage.getItem(localStorageKey(dsUid))).toBe('true'); | ||
}); | ||
|
||
it('should not re-render alert if already dismissed', () => { | ||
window.localStorage.setItem(localStorageKey(dsUid), 'true'); | ||
render(<AngularDeprecationNotice dashboardUid={dsUid} />); | ||
expect(screen.queryByText(noticeText)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should call reportInteraction when dismissing', async () => { | ||
render(<AngularDeprecationNotice dashboardUid={dsUid} />); | ||
const closeButton = screen.getByRole('button'); | ||
expect(closeButton).toBeInTheDocument(); | ||
await userEvent.click(closeButton); | ||
expect(reportInteraction).toHaveBeenCalledWith('angular_deprecation_notice_dismissed'); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have a check here that this is only shown to dashboard users who have edit permissions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could but then it makes it difficult for a viewer to discover that a dashboard they rely on has this issue