-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(widget-builder): Add filters bar to widget builder (#81467)
Adding the same filters bar that's on the dashboards detail page to the slide-out. Not connected with any hooks yet. It automatically has url query parameter functionality built in so that works without hooks. It looks like this so far: <img width="1507" alt="image" src="https://github.com/user-attachments/assets/5b6f817c-69a9-4dd6-ac09-4f9697de07fa">
- Loading branch information
1 parent
cf5b4d2
commit 9bd46be
Showing
4 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
static/app/views/dashboards/widgetBuilder/components/filtersBar.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,43 @@ | ||
import {DatePageFilter} from 'sentry/components/organizations/datePageFilter'; | ||
import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter'; | ||
import PageFilterBar from 'sentry/components/organizations/pageFilterBar'; | ||
import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container'; | ||
import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter'; | ||
import {DEFAULT_STATS_PERIOD} from 'sentry/constants'; | ||
import {ReleasesProvider} from 'sentry/utils/releases/releasesProvider'; | ||
import useOrganization from 'sentry/utils/useOrganization'; | ||
import usePageFilters from 'sentry/utils/usePageFilters'; | ||
import ReleasesSelectControl from 'sentry/views/dashboards/releasesSelectControl'; | ||
|
||
function WidgetBuilderFilterBar() { | ||
const organization = useOrganization(); | ||
const {selection} = usePageFilters(); | ||
return ( | ||
<PageFiltersContainer | ||
disablePersistence | ||
defaultSelection={{ | ||
datetime: { | ||
start: null, | ||
end: null, | ||
utc: false, | ||
period: DEFAULT_STATS_PERIOD, | ||
}, | ||
}} | ||
> | ||
<PageFilterBar> | ||
<ProjectPageFilter disabled onChange={() => {}} /> | ||
<EnvironmentPageFilter disabled onChange={() => {}} /> | ||
<DatePageFilter disabled onChange={() => {}} /> | ||
<ReleasesProvider organization={organization} selection={selection}> | ||
<ReleasesSelectControl | ||
isDisabled | ||
handleChangeFilter={() => {}} | ||
selectedReleases={[]} | ||
/> | ||
</ReleasesProvider> | ||
</PageFilterBar> | ||
</PageFiltersContainer> | ||
); | ||
} | ||
|
||
export default WidgetBuilderFilterBar; |
62 changes: 61 additions & 1 deletion
62
static/app/views/dashboards/widgetBuilder/components/newWidgetBuilder.spec.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 |
---|---|---|
@@ -1,14 +1,74 @@ | ||
import {initializeOrg} from 'sentry-test/initializeOrg'; | ||
import {render, screen} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import OrganizationStore from 'sentry/stores/organizationStore'; | ||
import PageFiltersStore from 'sentry/stores/pageFiltersStore'; | ||
import ProjectsStore from 'sentry/stores/projectsStore'; | ||
import DevWidgetBuilder from 'sentry/views/dashboards/widgetBuilder/components/newWidgetBuilder'; | ||
|
||
const {organization, projects, router} = initializeOrg({ | ||
organization: {features: ['global-views', 'open-membership']}, | ||
projects: [ | ||
{id: '1', slug: 'project-1', isMember: true}, | ||
{id: '2', slug: 'project-2', isMember: true}, | ||
{id: '3', slug: 'project-3', isMember: false}, | ||
], | ||
router: { | ||
location: { | ||
pathname: '/organizations/org-slug/dashboard/1/', | ||
query: {project: '-1'}, | ||
}, | ||
params: {}, | ||
}, | ||
}); | ||
|
||
describe('NewWidgetBuiler', function () { | ||
const onCloseMock = jest.fn(); | ||
|
||
beforeEach(function () { | ||
OrganizationStore.init(); | ||
|
||
PageFiltersStore.init(); | ||
PageFiltersStore.onInitializeUrlState( | ||
{ | ||
projects: [], | ||
environments: [], | ||
datetime: {start: null, end: null, period: '14d', utc: null}, | ||
}, | ||
new Set(['projects']) | ||
); | ||
|
||
OrganizationStore.onUpdate(organization, {replace: true}); | ||
ProjectsStore.loadInitialData(projects); | ||
|
||
MockApiClient.addMockResponse({ | ||
url: '/organizations/org-slug/releases/', | ||
body: [], | ||
}); | ||
|
||
MockApiClient.addMockResponse({ | ||
url: '/organizations/org-slug/dashboard/1/', | ||
body: [], | ||
}); | ||
}); | ||
|
||
afterEach(() => PageFiltersStore.reset()); | ||
|
||
it('renders', async function () { | ||
render(<DevWidgetBuilder isOpen onClose={onCloseMock} />); | ||
render(<DevWidgetBuilder isOpen onClose={onCloseMock} />, { | ||
router, | ||
organization, | ||
}); | ||
|
||
expect(await screen.findByText('Create Custom Widget')).toBeInTheDocument(); | ||
|
||
expect(await screen.findByLabelText('Close Widget Builder')).toBeInTheDocument(); | ||
|
||
expect(await screen.findByRole('button', {name: 'All Projects'})).toBeInTheDocument(); | ||
expect(await screen.findByRole('button', {name: 'All Envs'})).toBeInTheDocument(); | ||
expect(await screen.findByRole('button', {name: '14D'})).toBeInTheDocument(); | ||
expect(await screen.findByRole('button', {name: 'All Releases'})).toBeInTheDocument(); | ||
|
||
expect(await screen.findByText('TEST WIDGET')).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