detail.tsx 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  1. import {cloneElement, Component, Fragment, isValidElement} from 'react';
  2. import styled from '@emotion/styled';
  3. import type {Location} from 'history';
  4. import isEqual from 'lodash/isEqual';
  5. import isEqualWith from 'lodash/isEqualWith';
  6. import omit from 'lodash/omit';
  7. import pick from 'lodash/pick';
  8. import {
  9. createDashboard,
  10. deleteDashboard,
  11. updateDashboard,
  12. updateDashboardPermissions,
  13. } from 'sentry/actionCreators/dashboards';
  14. import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
  15. import {openWidgetViewerModal} from 'sentry/actionCreators/modal';
  16. import type {Client} from 'sentry/api';
  17. import {hasEveryAccess} from 'sentry/components/acl/access';
  18. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  19. import HookOrDefault from 'sentry/components/hookOrDefault';
  20. import * as Layout from 'sentry/components/layouts/thirds';
  21. import {
  22. isWidgetViewerPath,
  23. WidgetViewerQueryField,
  24. } from 'sentry/components/modals/widgetViewerModal/utils';
  25. import NoProjectMessage from 'sentry/components/noProjectMessage';
  26. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  27. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  28. import {USING_CUSTOMER_DOMAIN} from 'sentry/constants';
  29. import {t} from 'sentry/locale';
  30. import {space} from 'sentry/styles/space';
  31. import type {PageFilters} from 'sentry/types/core';
  32. import type {PlainRoute, RouteComponentProps} from 'sentry/types/legacyReactRouter';
  33. import type {Organization, Team} from 'sentry/types/organization';
  34. import type {Project} from 'sentry/types/project';
  35. import type {User} from 'sentry/types/user';
  36. import {defined} from 'sentry/utils';
  37. import {trackAnalytics} from 'sentry/utils/analytics';
  38. import {browserHistory} from 'sentry/utils/browserHistory';
  39. import EventView from 'sentry/utils/discover/eventView';
  40. import {MetricsCardinalityProvider} from 'sentry/utils/performance/contexts/metricsCardinality';
  41. import {MetricsResultsMetaProvider} from 'sentry/utils/performance/contexts/metricsEnhancedPerformanceDataContext';
  42. import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  43. import {OnDemandControlProvider} from 'sentry/utils/performance/contexts/onDemandControl';
  44. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  45. import withApi from 'sentry/utils/withApi';
  46. import withOrganization from 'sentry/utils/withOrganization';
  47. import withPageFilters from 'sentry/utils/withPageFilters';
  48. import withProjects from 'sentry/utils/withProjects';
  49. import {defaultMetricWidget} from 'sentry/views/dashboards/metrics/utils';
  50. import {
  51. cloneDashboard,
  52. getCurrentPageFilters,
  53. getDashboardFiltersFromURL,
  54. hasUnsavedFilterChanges,
  55. isWidgetUsingTransactionName,
  56. resetPageFilters,
  57. } from 'sentry/views/dashboards/utils';
  58. import DevWidgetBuilder from 'sentry/views/dashboards/widgetBuilder/components/newWidgetBuilder';
  59. import {DataSet} from 'sentry/views/dashboards/widgetBuilder/utils';
  60. import {convertWidgetToBuilderStateParams} from 'sentry/views/dashboards/widgetBuilder/utils/convertWidgetToBuilderStateParams';
  61. import WidgetLegendNameEncoderDecoder from 'sentry/views/dashboards/widgetLegendNameEncoderDecoder';
  62. import {MetricsDataSwitcherAlert} from 'sentry/views/performance/landing/metricsDataSwitcherAlert';
  63. import {generatePerformanceEventView} from '../performance/data';
  64. import {MetricsDataSwitcher} from '../performance/landing/metricsDataSwitcher';
  65. import {DiscoverQueryPageSource} from '../performance/utils';
  66. import type {WidgetViewerContextProps} from './widgetViewer/widgetViewerContext';
  67. import {WidgetViewerContext} from './widgetViewer/widgetViewerContext';
  68. import Controls from './controls';
  69. import Dashboard from './dashboard';
  70. import {DEFAULT_STATS_PERIOD} from './data';
  71. import FiltersBar from './filtersBar';
  72. import {
  73. assignDefaultLayout,
  74. assignTempId,
  75. calculateColumnDepths,
  76. generateWidgetsAfterCompaction,
  77. getDashboardLayout,
  78. } from './layoutUtils';
  79. import DashboardTitle from './title';
  80. import type {
  81. DashboardDetails,
  82. DashboardFilters,
  83. DashboardListItem,
  84. DashboardPermissions,
  85. Widget,
  86. } from './types';
  87. import {
  88. DashboardFilterKeys,
  89. DashboardState,
  90. DashboardWidgetSource,
  91. MAX_WIDGETS,
  92. WidgetType,
  93. } from './types';
  94. import WidgetLegendSelectionState from './widgetLegendSelectionState';
  95. const UNSAVED_MESSAGE = t('You have unsaved changes, are you sure you want to leave?');
  96. export const UNSAVED_FILTERS_MESSAGE = t(
  97. 'You have unsaved dashboard filters. You can save or discard them.'
  98. );
  99. const HookHeader = HookOrDefault({hookName: 'component:dashboards-header'});
  100. type RouteParams = {
  101. dashboardId?: string;
  102. templateId?: string;
  103. widgetId?: number | string;
  104. widgetIndex?: number;
  105. };
  106. type Props = RouteComponentProps<RouteParams, {}> & {
  107. api: Client;
  108. dashboard: DashboardDetails;
  109. dashboards: DashboardListItem[];
  110. initialState: DashboardState;
  111. organization: Organization;
  112. projects: Project[];
  113. route: PlainRoute;
  114. selection: PageFilters;
  115. children?: React.ReactNode;
  116. newWidget?: Widget;
  117. onDashboardUpdate?: (updatedDashboard: DashboardDetails) => void;
  118. onSetNewWidget?: () => void;
  119. };
  120. type State = {
  121. dashboardState: DashboardState;
  122. isWidgetBuilderOpen: boolean;
  123. modifiedDashboard: DashboardDetails | null;
  124. widgetLegendState: WidgetLegendSelectionState;
  125. widgetLimitReached: boolean;
  126. } & WidgetViewerContextProps;
  127. export function handleUpdateDashboardSplit({
  128. widgetId,
  129. splitDecision,
  130. dashboard,
  131. onDashboardUpdate,
  132. modifiedDashboard,
  133. stateSetter,
  134. }: {
  135. dashboard: DashboardDetails;
  136. modifiedDashboard: DashboardDetails | null;
  137. splitDecision: WidgetType;
  138. stateSetter: Component<Props, State, any>['setState'];
  139. widgetId: string;
  140. onDashboardUpdate?: (updatedDashboard: DashboardDetails) => void;
  141. }) {
  142. // The underlying dashboard needs to be updated with the split decision
  143. // because the backend has evaluated the query and stored that value
  144. const updatedDashboard = cloneDashboard(dashboard);
  145. const widgetIndex = updatedDashboard.widgets.findIndex(
  146. widget => widget.id === widgetId
  147. );
  148. if (widgetIndex >= 0) {
  149. updatedDashboard.widgets[widgetIndex].widgetType = splitDecision;
  150. }
  151. onDashboardUpdate?.(updatedDashboard);
  152. // The modified dashboard also needs to be updated because that dashboard
  153. // is rendered instead of the original dashboard when editing
  154. if (modifiedDashboard) {
  155. stateSetter(state => ({
  156. ...state,
  157. modifiedDashboard: {
  158. ...state.modifiedDashboard!,
  159. widgets: state.modifiedDashboard!.widgets.map(widget =>
  160. widget.id === widgetId ? {...widget, widgetType: splitDecision} : widget
  161. ),
  162. },
  163. }));
  164. }
  165. }
  166. /* Checks if current user has permissions to edit dashboard */
  167. export function checkUserHasEditAccess(
  168. currentUser: User,
  169. userTeams: Team[],
  170. organization: Organization,
  171. dashboardPermissions?: DashboardPermissions,
  172. dashboardCreator?: User
  173. ): boolean {
  174. if (
  175. !organization.features.includes('dashboards-edit-access') ||
  176. hasEveryAccess(['org:write'], {organization}) || // Managers and Owners
  177. !dashboardPermissions ||
  178. dashboardPermissions.isEditableByEveryone ||
  179. dashboardCreator?.id === currentUser.id
  180. ) {
  181. return true;
  182. }
  183. if (dashboardPermissions.teamsWithEditAccess?.length) {
  184. const userTeamIds = userTeams.map(team => Number(team.id));
  185. return dashboardPermissions.teamsWithEditAccess.some(teamId =>
  186. userTeamIds.includes(teamId)
  187. );
  188. }
  189. return false;
  190. }
  191. function getDashboardLocation({
  192. organization,
  193. dashboardId,
  194. location,
  195. }: {
  196. location: Location<any>;
  197. organization: Organization;
  198. dashboardId?: string;
  199. }) {
  200. // Preserve important filter params
  201. const filterParams = pick(location.query, [
  202. 'release',
  203. 'environment',
  204. 'project',
  205. 'statsPeriod',
  206. 'start',
  207. 'end',
  208. ]);
  209. const commonPath = defined(dashboardId)
  210. ? `/dashboard/${dashboardId}/`
  211. : `/dashboards/new/`;
  212. const dashboardUrl = USING_CUSTOMER_DOMAIN
  213. ? commonPath
  214. : `/organizations/${organization.slug}${commonPath}`;
  215. return normalizeUrl({
  216. pathname: dashboardUrl,
  217. query: filterParams,
  218. });
  219. }
  220. class DashboardDetail extends Component<Props, State> {
  221. state: State = {
  222. dashboardState: this.props.initialState,
  223. modifiedDashboard: this.updateModifiedDashboard(this.props.initialState),
  224. widgetLimitReached: this.props.dashboard.widgets.length >= MAX_WIDGETS,
  225. setData: data => {
  226. this.setState(data);
  227. },
  228. widgetLegendState: new WidgetLegendSelectionState({
  229. dashboard: this.props.dashboard,
  230. organization: this.props.organization,
  231. location: this.props.location,
  232. router: this.props.router,
  233. }),
  234. isWidgetBuilderOpen: this.isRedesignedWidgetBuilder,
  235. };
  236. componentDidMount() {
  237. this.checkIfShouldMountWidgetViewerModal();
  238. }
  239. componentDidUpdate(prevProps: Props) {
  240. this.checkIfShouldMountWidgetViewerModal();
  241. if (prevProps.initialState !== this.props.initialState) {
  242. // Widget builder can toggle Edit state when saving
  243. this.setState({dashboardState: this.props.initialState});
  244. }
  245. if (
  246. prevProps.organization !== this.props.organization ||
  247. prevProps.location !== this.props.location ||
  248. prevProps.router !== this.props.router ||
  249. prevProps.dashboard !== this.props.dashboard
  250. ) {
  251. this.setState({
  252. widgetLegendState: new WidgetLegendSelectionState({
  253. organization: this.props.organization,
  254. location: this.props.location,
  255. router: this.props.router,
  256. dashboard: this.props.dashboard,
  257. }),
  258. });
  259. }
  260. }
  261. checkIfShouldMountWidgetViewerModal() {
  262. const {
  263. params: {widgetId, dashboardId},
  264. organization,
  265. dashboard,
  266. location,
  267. router,
  268. } = this.props;
  269. const {seriesData, tableData, pageLinks, totalIssuesCount, seriesResultsType} =
  270. this.state;
  271. if (isWidgetViewerPath(location.pathname)) {
  272. const widget =
  273. defined(widgetId) &&
  274. (dashboard.widgets.find(({id}) => {
  275. // This ternary exists because widgetId is in some places typed as string, while
  276. // in other cases it is typed as number. Instead of changing the type everywhere,
  277. // we check for both cases at runtime as I am not sure which is the correct type.
  278. return typeof widgetId === 'number' ? id === String(widgetId) : id === widgetId;
  279. }) ??
  280. dashboard.widgets[widgetId]);
  281. if (widget) {
  282. openWidgetViewerModal({
  283. organization,
  284. widget,
  285. seriesData: WidgetLegendNameEncoderDecoder.modifyTimeseriesNames(
  286. widget,
  287. seriesData
  288. ),
  289. seriesResultsType,
  290. tableData,
  291. pageLinks,
  292. totalIssuesCount,
  293. widgetLegendState: this.state.widgetLegendState,
  294. dashboardFilters: getDashboardFiltersFromURL(location) ?? dashboard.filters,
  295. dashboardPermissions: dashboard.permissions,
  296. dashboardCreator: dashboard.createdBy,
  297. onMetricWidgetEdit: (updatedWidget: Widget) => {
  298. const widgets = [...dashboard.widgets];
  299. const widgetIndex = dashboard.widgets.indexOf(widget);
  300. widgets[widgetIndex] = {...widgets[widgetIndex], ...updatedWidget};
  301. this.handleUpdateWidgetList(widgets);
  302. },
  303. onClose: () => {
  304. // Filter out Widget Viewer Modal query params when exiting the Modal
  305. const query = omit(location.query, Object.values(WidgetViewerQueryField));
  306. router.push({
  307. pathname: location.pathname.replace(/widget\/[0-9]+\/$/, ''),
  308. query,
  309. });
  310. },
  311. onEdit: () => {
  312. const widgetIndex = dashboard.widgets.indexOf(widget);
  313. if (organization.features.includes('dashboards-widget-builder-redesign')) {
  314. this.onEditWidget(widget);
  315. return;
  316. }
  317. if (dashboardId) {
  318. const query = omit(location.query, Object.values(WidgetViewerQueryField));
  319. router.push(
  320. normalizeUrl({
  321. pathname: `/organizations/${organization.slug}/dashboard/${dashboardId}/widget/${widgetIndex}/edit/`,
  322. query: {
  323. ...query,
  324. source: DashboardWidgetSource.DASHBOARDS,
  325. },
  326. })
  327. );
  328. return;
  329. }
  330. },
  331. });
  332. trackAnalytics('dashboards_views.widget_viewer.open', {
  333. organization,
  334. widget_type: widget.widgetType ?? WidgetType.DISCOVER,
  335. display_type: widget.displayType,
  336. });
  337. } else {
  338. // Replace the URL if the widget isn't found and raise an error in toast
  339. router.replace(
  340. normalizeUrl({
  341. pathname: `/organizations/${organization.slug}/dashboard/${dashboard.id}/`,
  342. query: location.query,
  343. })
  344. );
  345. addErrorMessage(t('Widget not found'));
  346. }
  347. }
  348. }
  349. updateModifiedDashboard(dashboardState: DashboardState) {
  350. const {dashboard} = this.props;
  351. switch (dashboardState) {
  352. case DashboardState.PREVIEW:
  353. case DashboardState.CREATE:
  354. case DashboardState.EDIT:
  355. return cloneDashboard(dashboard);
  356. default: {
  357. return null;
  358. }
  359. }
  360. }
  361. get isPreview() {
  362. const {dashboardState} = this.state;
  363. return DashboardState.PREVIEW === dashboardState;
  364. }
  365. get isEditingDashboard() {
  366. const {dashboardState} = this.state;
  367. return [
  368. DashboardState.EDIT,
  369. DashboardState.CREATE,
  370. DashboardState.PENDING_DELETE,
  371. ].includes(dashboardState);
  372. }
  373. get isWidgetBuilderRouter() {
  374. const {location, params, organization} = this.props;
  375. const {dashboardId, widgetIndex} = params;
  376. const widgetBuilderRoutes = [
  377. `/organizations/${organization.slug}/dashboards/new/widget/new/`,
  378. `/organizations/${organization.slug}/dashboard/${dashboardId}/widget/new/`,
  379. `/organizations/${organization.slug}/dashboards/new/widget/${widgetIndex}/edit/`,
  380. `/organizations/${organization.slug}/dashboard/${dashboardId}/widget/${widgetIndex}/edit/`,
  381. ];
  382. if (USING_CUSTOMER_DOMAIN) {
  383. // TODO: replace with url generation later on.
  384. widgetBuilderRoutes.push(
  385. ...[
  386. `/dashboards/new/widget/new/`,
  387. `/dashboard/${dashboardId}/widget/new/`,
  388. `/dashboards/new/widget/${widgetIndex}/edit/`,
  389. `/dashboard/${dashboardId}/widget/${widgetIndex}/edit/`,
  390. ]
  391. );
  392. }
  393. return widgetBuilderRoutes.includes(location.pathname);
  394. }
  395. get isRedesignedWidgetBuilder() {
  396. const {organization, location, params} = this.props;
  397. const {dashboardId, widgetIndex} = params;
  398. if (!organization.features.includes('dashboards-widget-builder-redesign')) {
  399. return false;
  400. }
  401. const widgetBuilderRoutes = [
  402. `/organizations/${organization.slug}/dashboard/new/widget-builder/widget/new/`,
  403. `/organizations/${organization.slug}/dashboard/${dashboardId}/widget-builder/widget/new/`,
  404. `/organizations/${organization.slug}/dashboard/new/widget-builder/widget/${widgetIndex}/edit/`,
  405. `/organizations/${organization.slug}/dashboard/${dashboardId}/widget-builder/widget/${widgetIndex}/edit/`,
  406. ];
  407. if (USING_CUSTOMER_DOMAIN) {
  408. widgetBuilderRoutes.push(
  409. ...[
  410. `/dashboards/new/widget-builder/widget/new/`,
  411. `/dashboard/${dashboardId}/widget-builder/widget/new/`,
  412. `/dashboards/new/widget-builder/widget/${widgetIndex}/edit/`,
  413. `/dashboard/${dashboardId}/widget-builder/widget/${widgetIndex}/edit/`,
  414. ]
  415. );
  416. }
  417. return widgetBuilderRoutes.includes(location.pathname);
  418. }
  419. get dashboardTitle() {
  420. const {dashboard} = this.props;
  421. const {modifiedDashboard} = this.state;
  422. return modifiedDashboard ? modifiedDashboard.title : dashboard.title;
  423. }
  424. onEdit = () => {
  425. const {dashboard, organization} = this.props;
  426. trackAnalytics('dashboards2.edit.start', {organization});
  427. this.setState({
  428. dashboardState: DashboardState.EDIT,
  429. modifiedDashboard: cloneDashboard(dashboard),
  430. });
  431. };
  432. onDelete = (dashboard: State['modifiedDashboard']) => () => {
  433. const {api, organization, location} = this.props;
  434. if (!dashboard?.id) {
  435. return;
  436. }
  437. const previousDashboardState = this.state.dashboardState;
  438. this.setState({dashboardState: DashboardState.PENDING_DELETE}, () => {
  439. deleteDashboard(api, organization.slug, dashboard.id)
  440. .then(() => {
  441. addSuccessMessage(t('Dashboard deleted'));
  442. trackAnalytics('dashboards2.delete', {organization});
  443. browserHistory.replace({
  444. pathname: `/organizations/${organization.slug}/dashboards/`,
  445. query: location.query,
  446. });
  447. })
  448. .catch(() => {
  449. this.setState({
  450. dashboardState: previousDashboardState,
  451. });
  452. });
  453. });
  454. };
  455. onCancel = () => {
  456. const {organization, dashboard, location, params} = this.props;
  457. const {modifiedDashboard} = this.state;
  458. let hasDashboardChanged = !isEqual(modifiedDashboard, dashboard);
  459. // If a dashboard has every layout undefined, then ignore the layout field
  460. // when checking equality because it is a dashboard from before the grid feature
  461. const isLegacyLayout = dashboard.widgets.every(({layout}) => !defined(layout));
  462. if (isLegacyLayout) {
  463. hasDashboardChanged = !isEqual(
  464. {
  465. ...modifiedDashboard,
  466. widgets: modifiedDashboard?.widgets.map(widget => omit(widget, 'layout')),
  467. },
  468. {...dashboard, widgets: dashboard.widgets.map(widget => omit(widget, 'layout'))}
  469. );
  470. }
  471. // Don't confirm preview cancellation regardless of dashboard state
  472. if (hasDashboardChanged && !this.isPreview) {
  473. // Ignore no-alert here, so that the confirm on cancel matches onUnload & onRouteLeave
  474. /* eslint no-alert:0 */
  475. if (!confirm(UNSAVED_MESSAGE)) {
  476. return;
  477. }
  478. }
  479. if (params.dashboardId) {
  480. trackAnalytics('dashboards2.edit.cancel', {organization});
  481. this.setState({
  482. dashboardState: DashboardState.VIEW,
  483. modifiedDashboard: null,
  484. });
  485. return;
  486. }
  487. trackAnalytics('dashboards2.create.cancel', {organization});
  488. browserHistory.replace(
  489. normalizeUrl({
  490. pathname: `/organizations/${organization.slug}/dashboards/`,
  491. query: location.query,
  492. })
  493. );
  494. };
  495. handleChangeFilter = (activeFilters: DashboardFilters) => {
  496. const {dashboard, location} = this.props;
  497. const {modifiedDashboard} = this.state;
  498. const newModifiedDashboard = modifiedDashboard || dashboard;
  499. if (
  500. Object.keys(activeFilters).every(
  501. key => !newModifiedDashboard.filters?.[key] && activeFilters[key].length === 0
  502. )
  503. ) {
  504. return;
  505. }
  506. const filterParams: DashboardFilters = {};
  507. Object.keys(activeFilters).forEach(key => {
  508. filterParams[key] = activeFilters[key].length ? activeFilters[key] : '';
  509. });
  510. if (
  511. !isEqualWith(activeFilters, dashboard.filters, (a, b) => {
  512. // This is to handle the case where dashboard filters has release:[] and the new filter is release:""
  513. if (a.length === 0 && b.length === 0) {
  514. return a === b;
  515. }
  516. return undefined;
  517. })
  518. ) {
  519. browserHistory.push({
  520. ...location,
  521. query: {
  522. ...location.query,
  523. ...filterParams,
  524. },
  525. });
  526. }
  527. };
  528. handleUpdateWidgetList = (widgets: Widget[]) => {
  529. const {organization, dashboard, api, onDashboardUpdate, location} = this.props;
  530. const {modifiedDashboard} = this.state;
  531. // Use the new widgets for calculating layout because widgets has
  532. // the most up to date information in edit state
  533. const currentLayout = getDashboardLayout(widgets);
  534. const layoutColumnDepths = calculateColumnDepths(currentLayout);
  535. const newModifiedDashboard = {
  536. ...cloneDashboard(modifiedDashboard || dashboard),
  537. widgets: assignDefaultLayout(widgets, layoutColumnDepths),
  538. };
  539. this.setState({
  540. modifiedDashboard: newModifiedDashboard,
  541. widgetLimitReached: widgets.length >= MAX_WIDGETS,
  542. });
  543. if (this.isEditingDashboard || this.isPreview) {
  544. return null;
  545. }
  546. return updateDashboard(api, organization.slug, newModifiedDashboard).then(
  547. (newDashboard: DashboardDetails) => {
  548. if (onDashboardUpdate) {
  549. onDashboardUpdate(newDashboard);
  550. this.setState({
  551. modifiedDashboard: null,
  552. });
  553. }
  554. const legendQuery =
  555. this.state.widgetLegendState.setMultipleWidgetSelectionStateURL(newDashboard);
  556. if (dashboard && newDashboard.id !== dashboard.id) {
  557. this.props.router.replace(
  558. normalizeUrl({
  559. pathname: `/organizations/${organization.slug}/dashboard/${newDashboard.id}/`,
  560. query: {
  561. ...location.query,
  562. unselectedSeries: legendQuery,
  563. },
  564. })
  565. );
  566. } else {
  567. browserHistory.replace(
  568. normalizeUrl({
  569. pathname: `/organizations/${organization.slug}/dashboard/${dashboard.id}/`,
  570. query: {
  571. ...location.query,
  572. unselectedSeries: legendQuery,
  573. },
  574. })
  575. );
  576. }
  577. addSuccessMessage(t('Dashboard updated'));
  578. return newDashboard;
  579. },
  580. // `updateDashboard` does its own error handling
  581. () => undefined
  582. );
  583. };
  584. handleAddCustomWidget = (widget: Widget) => {
  585. const {dashboard} = this.props;
  586. const {modifiedDashboard} = this.state;
  587. const newModifiedDashboard = modifiedDashboard || dashboard;
  588. this.onUpdateWidget([...newModifiedDashboard.widgets, widget]);
  589. };
  590. handleAddMetricWidget = (layout?: Widget['layout']) => {
  591. const widgetCopy = assignTempId({
  592. layout,
  593. ...defaultMetricWidget(),
  594. });
  595. const currentWidgets =
  596. this.state.modifiedDashboard?.widgets ?? this.props.dashboard.widgets;
  597. openWidgetViewerModal({
  598. organization: this.props.organization,
  599. widget: widgetCopy,
  600. widgetLegendState: this.state.widgetLegendState,
  601. onMetricWidgetEdit: widget => {
  602. const nextList = generateWidgetsAfterCompaction([...currentWidgets, widget]);
  603. this.onUpdateWidget(nextList);
  604. this.handleUpdateWidgetList(nextList);
  605. },
  606. });
  607. };
  608. onAddWidget = (dataset?: DataSet) => {
  609. const {
  610. organization,
  611. dashboard,
  612. router,
  613. location,
  614. params: {dashboardId},
  615. } = this.props;
  616. const {modifiedDashboard} = this.state;
  617. if (dataset === DataSet.METRICS) {
  618. this.handleAddMetricWidget();
  619. return;
  620. }
  621. if (organization.features.includes('dashboards-widget-builder-redesign')) {
  622. this.setState(
  623. {
  624. modifiedDashboard: cloneDashboard(modifiedDashboard ?? dashboard),
  625. },
  626. () => {
  627. this.setState({isWidgetBuilderOpen: true});
  628. let pathname = `/organizations/${organization.slug}/dashboard/${dashboardId}/widget-builder/widget/new/`;
  629. if (!defined(dashboardId)) {
  630. pathname = `/organizations/${organization.slug}/dashboards/new/widget-builder/widget/new/`;
  631. }
  632. router.push(
  633. normalizeUrl({
  634. // TODO: Replace with the old widget builder path when swapping over
  635. pathname,
  636. query: {
  637. ...location.query,
  638. dataset,
  639. },
  640. })
  641. );
  642. }
  643. );
  644. return;
  645. }
  646. this.setState(
  647. {
  648. modifiedDashboard: cloneDashboard(dashboard),
  649. },
  650. () => {
  651. if (dashboardId) {
  652. router.push(
  653. normalizeUrl({
  654. pathname: `/organizations/${organization.slug}/dashboard/${dashboardId}/widget/new/`,
  655. query: {
  656. ...location.query,
  657. source: DashboardWidgetSource.DASHBOARDS,
  658. dataset,
  659. },
  660. })
  661. );
  662. }
  663. }
  664. );
  665. };
  666. onEditWidget = (widget: Widget) => {
  667. const {router, organization, params, location, dashboard} = this.props;
  668. const {dashboardId} = params;
  669. const widgetIndex = dashboard.widgets.indexOf(widget);
  670. this.setState({
  671. isWidgetBuilderOpen: true,
  672. });
  673. const path = defined(dashboardId)
  674. ? `/organizations/${organization.slug}/dashboard/${dashboardId}/widget-builder/widget/${widgetIndex}/edit/`
  675. : `/organizations/${organization.slug}/dashboards/new/widget-builder/widget/${widgetIndex}/edit/`;
  676. router.push(
  677. normalizeUrl({
  678. pathname: path,
  679. query: {
  680. ...location.query,
  681. ...convertWidgetToBuilderStateParams(widget),
  682. },
  683. })
  684. );
  685. };
  686. /* Handles POST request for Edit Access Selector Changes */
  687. onChangeEditAccess = (newDashboardPermissions: DashboardPermissions) => {
  688. const {dashboard, api, organization} = this.props;
  689. const dashboardCopy = cloneDashboard(dashboard);
  690. dashboardCopy.permissions = newDashboardPermissions;
  691. updateDashboardPermissions(api, organization.slug, dashboardCopy).then(
  692. (newDashboard: DashboardDetails) => {
  693. addSuccessMessage(t('Dashboard Edit Access updated.'));
  694. this.props.onDashboardUpdate?.(newDashboard);
  695. this.setState({
  696. modifiedDashboard: null,
  697. });
  698. return newDashboard;
  699. }
  700. );
  701. };
  702. onCommit = () => {
  703. const {api, organization, location, dashboard, onDashboardUpdate} = this.props;
  704. const {modifiedDashboard, dashboardState} = this.state;
  705. switch (dashboardState) {
  706. case DashboardState.PREVIEW:
  707. case DashboardState.CREATE: {
  708. if (modifiedDashboard) {
  709. if (this.isPreview) {
  710. trackAnalytics('dashboards_manage.templates.add', {
  711. organization,
  712. dashboard_id: dashboard.id,
  713. dashboard_title: dashboard.title,
  714. was_previewed: true,
  715. });
  716. }
  717. const newModifiedDashboard = {
  718. ...cloneDashboard(modifiedDashboard),
  719. ...getCurrentPageFilters(location),
  720. filters: getDashboardFiltersFromURL(location) ?? modifiedDashboard.filters,
  721. };
  722. createDashboard(
  723. api,
  724. organization.slug,
  725. newModifiedDashboard,
  726. this.isPreview
  727. ).then(
  728. (newDashboard: DashboardDetails) => {
  729. addSuccessMessage(t('Dashboard created'));
  730. trackAnalytics('dashboards2.create.complete', {organization});
  731. this.setState(
  732. {
  733. dashboardState: DashboardState.VIEW,
  734. },
  735. () => {
  736. // redirect to new dashboard
  737. browserHistory.replace(
  738. normalizeUrl({
  739. pathname: `/organizations/${organization.slug}/dashboard/${newDashboard.id}/`,
  740. query: {
  741. query: omit(location.query, Object.values(DashboardFilterKeys)),
  742. },
  743. })
  744. );
  745. }
  746. );
  747. },
  748. () => undefined
  749. );
  750. }
  751. break;
  752. }
  753. case DashboardState.EDIT: {
  754. // only update the dashboard if there are changes
  755. if (modifiedDashboard) {
  756. if (isEqual(dashboard, modifiedDashboard)) {
  757. this.setState({
  758. dashboardState: DashboardState.VIEW,
  759. modifiedDashboard: null,
  760. });
  761. return;
  762. }
  763. updateDashboard(api, organization.slug, modifiedDashboard).then(
  764. (newDashboard: DashboardDetails) => {
  765. if (onDashboardUpdate) {
  766. onDashboardUpdate(newDashboard);
  767. }
  768. addSuccessMessage(t('Dashboard updated'));
  769. trackAnalytics('dashboards2.edit.complete', {organization});
  770. this.setState(
  771. {
  772. dashboardState: DashboardState.VIEW,
  773. modifiedDashboard: null,
  774. },
  775. () => {
  776. if (dashboard && newDashboard.id !== dashboard.id) {
  777. browserHistory.replace(
  778. normalizeUrl({
  779. pathname: `/organizations/${organization.slug}/dashboard/${newDashboard.id}/`,
  780. query: {
  781. ...location.query,
  782. },
  783. })
  784. );
  785. }
  786. }
  787. );
  788. },
  789. // `updateDashboard` does its own error handling
  790. () => undefined
  791. );
  792. return;
  793. }
  794. this.setState({
  795. dashboardState: DashboardState.VIEW,
  796. modifiedDashboard: null,
  797. });
  798. break;
  799. }
  800. case DashboardState.VIEW:
  801. default: {
  802. this.setState({
  803. dashboardState: DashboardState.VIEW,
  804. modifiedDashboard: null,
  805. });
  806. break;
  807. }
  808. }
  809. };
  810. setModifiedDashboard = (dashboard: DashboardDetails) => {
  811. this.setState({
  812. modifiedDashboard: dashboard,
  813. });
  814. };
  815. onUpdateWidget = (widgets: Widget[]) => {
  816. this.setState((state: State) => ({
  817. ...state,
  818. widgetLimitReached: widgets.length >= MAX_WIDGETS,
  819. modifiedDashboard: {
  820. ...(state.modifiedDashboard || this.props.dashboard),
  821. widgets,
  822. },
  823. }));
  824. };
  825. renderWidgetBuilder = () => {
  826. const {children, dashboard, onDashboardUpdate} = this.props;
  827. const {modifiedDashboard} = this.state;
  828. return (
  829. <Fragment>
  830. {isValidElement(children)
  831. ? cloneElement<any>(children, {
  832. dashboard: modifiedDashboard ?? dashboard,
  833. onSave: this.isEditingDashboard
  834. ? this.onUpdateWidget
  835. : this.handleUpdateWidgetList,
  836. updateDashboardSplitDecision: (
  837. widgetId: string,
  838. splitDecision: WidgetType
  839. ) => {
  840. handleUpdateDashboardSplit({
  841. widgetId,
  842. splitDecision,
  843. dashboard,
  844. modifiedDashboard,
  845. stateSetter: this.setState.bind(this),
  846. onDashboardUpdate,
  847. });
  848. },
  849. })
  850. : children}
  851. </Fragment>
  852. );
  853. };
  854. renderDefaultDashboardDetail() {
  855. const {organization, dashboard, dashboards, params, router, location} = this.props;
  856. const {modifiedDashboard, dashboardState, widgetLimitReached} = this.state;
  857. const {dashboardId} = params;
  858. return (
  859. <PageFiltersContainer
  860. disablePersistence
  861. defaultSelection={{
  862. datetime: {
  863. start: null,
  864. end: null,
  865. utc: false,
  866. period: DEFAULT_STATS_PERIOD,
  867. },
  868. }}
  869. >
  870. <Layout.Page withPadding>
  871. <OnDemandControlProvider location={location}>
  872. <MetricsResultsMetaProvider>
  873. <NoProjectMessage organization={organization}>
  874. <StyledPageHeader>
  875. <Layout.Title>
  876. <DashboardTitle
  877. dashboard={modifiedDashboard ?? dashboard}
  878. onUpdate={this.setModifiedDashboard}
  879. isEditingDashboard={this.isEditingDashboard}
  880. />
  881. </Layout.Title>
  882. <Controls
  883. organization={organization}
  884. dashboards={dashboards}
  885. dashboard={dashboard}
  886. onEdit={this.onEdit}
  887. onCancel={this.onCancel}
  888. onCommit={this.onCommit}
  889. onAddWidget={this.onAddWidget}
  890. onChangeEditAccess={this.onChangeEditAccess}
  891. onDelete={this.onDelete(dashboard)}
  892. dashboardState={dashboardState}
  893. widgetLimitReached={widgetLimitReached}
  894. />
  895. </StyledPageHeader>
  896. <HookHeader organization={organization} />
  897. <FiltersBar
  898. dashboardPermissions={dashboard.permissions}
  899. dashboardCreator={dashboard.createdBy}
  900. filters={{}} // Default Dashboards don't have filters set
  901. location={location}
  902. hasUnsavedChanges={false}
  903. isEditingDashboard={false}
  904. isPreview={false}
  905. onDashboardFilterChange={this.handleChangeFilter}
  906. />
  907. <MetricsCardinalityProvider
  908. organization={organization}
  909. location={location}
  910. >
  911. <MetricsDataSwitcher
  912. organization={organization}
  913. eventView={EventView.fromLocation(location)}
  914. location={location}
  915. >
  916. {metricsDataSide => (
  917. <MEPSettingProvider
  918. location={location}
  919. forceTransactions={metricsDataSide.forceTransactionsOnly}
  920. >
  921. <Dashboard
  922. paramDashboardId={dashboardId}
  923. dashboard={modifiedDashboard ?? dashboard}
  924. organization={organization}
  925. isEditingDashboard={this.isEditingDashboard}
  926. widgetLimitReached={widgetLimitReached}
  927. onUpdate={this.onUpdateWidget}
  928. handleUpdateWidgetList={this.handleUpdateWidgetList}
  929. handleAddCustomWidget={this.handleAddCustomWidget}
  930. handleAddMetricWidget={this.handleAddMetricWidget}
  931. isPreview={this.isPreview}
  932. router={router}
  933. location={location}
  934. widgetLegendState={this.state.widgetLegendState}
  935. />
  936. </MEPSettingProvider>
  937. )}
  938. </MetricsDataSwitcher>
  939. </MetricsCardinalityProvider>
  940. </NoProjectMessage>
  941. </MetricsResultsMetaProvider>
  942. </OnDemandControlProvider>
  943. </Layout.Page>
  944. </PageFiltersContainer>
  945. );
  946. }
  947. getBreadcrumbLabel() {
  948. const {dashboardState} = this.state;
  949. let label = this.dashboardTitle;
  950. if (dashboardState === DashboardState.CREATE) {
  951. label = t('Create Dashboard');
  952. } else if (this.isPreview) {
  953. label = t('Preview Dashboard');
  954. }
  955. return label;
  956. }
  957. renderDashboardDetail() {
  958. const {
  959. api,
  960. organization,
  961. dashboard,
  962. dashboards,
  963. params,
  964. router,
  965. location,
  966. newWidget,
  967. onSetNewWidget,
  968. onDashboardUpdate,
  969. projects,
  970. } = this.props;
  971. const {modifiedDashboard, dashboardState, widgetLimitReached, seriesData, setData} =
  972. this.state;
  973. const {dashboardId} = params;
  974. const hasUnsavedFilters =
  975. dashboard.id !== 'default-overview' &&
  976. dashboardState !== DashboardState.CREATE &&
  977. hasUnsavedFilterChanges(dashboard, location);
  978. const eventView = generatePerformanceEventView(location, projects, {}, organization);
  979. const isDashboardUsingTransaction = dashboard.widgets.some(
  980. isWidgetUsingTransactionName
  981. );
  982. return (
  983. <SentryDocumentTitle title={dashboard.title} orgSlug={organization.slug}>
  984. <PageFiltersContainer
  985. disablePersistence
  986. defaultSelection={{
  987. datetime: {
  988. start: null,
  989. end: null,
  990. utc: false,
  991. period: DEFAULT_STATS_PERIOD,
  992. },
  993. }}
  994. >
  995. <Layout.Page>
  996. <OnDemandControlProvider location={location}>
  997. <MetricsResultsMetaProvider>
  998. <NoProjectMessage organization={organization}>
  999. <Layout.Header>
  1000. <Layout.HeaderContent>
  1001. <Breadcrumbs
  1002. crumbs={[
  1003. {
  1004. label: t('Dashboards'),
  1005. to: `/organizations/${organization.slug}/dashboards/`,
  1006. },
  1007. {
  1008. label: this.getBreadcrumbLabel(),
  1009. },
  1010. ]}
  1011. />
  1012. <Layout.Title>
  1013. <DashboardTitle
  1014. dashboard={modifiedDashboard ?? dashboard}
  1015. onUpdate={this.setModifiedDashboard}
  1016. isEditingDashboard={this.isEditingDashboard}
  1017. />
  1018. </Layout.Title>
  1019. </Layout.HeaderContent>
  1020. <Layout.HeaderActions>
  1021. <Controls
  1022. organization={organization}
  1023. dashboards={dashboards}
  1024. dashboard={dashboard}
  1025. hasUnsavedFilters={hasUnsavedFilters}
  1026. onEdit={this.onEdit}
  1027. onCancel={this.onCancel}
  1028. onCommit={this.onCommit}
  1029. onAddWidget={this.onAddWidget}
  1030. onDelete={this.onDelete(dashboard)}
  1031. onChangeEditAccess={this.onChangeEditAccess}
  1032. dashboardState={dashboardState}
  1033. widgetLimitReached={widgetLimitReached}
  1034. />
  1035. </Layout.HeaderActions>
  1036. </Layout.Header>
  1037. <Layout.Body>
  1038. <Layout.Main fullWidth>
  1039. <MetricsCardinalityProvider
  1040. organization={organization}
  1041. location={location}
  1042. >
  1043. <MetricsDataSwitcher
  1044. organization={organization}
  1045. eventView={eventView}
  1046. location={location}
  1047. >
  1048. {metricsDataSide => (
  1049. <MEPSettingProvider
  1050. location={location}
  1051. forceTransactions={metricsDataSide.forceTransactionsOnly}
  1052. >
  1053. {isDashboardUsingTransaction ? (
  1054. <MetricsDataSwitcherAlert
  1055. organization={organization}
  1056. eventView={eventView}
  1057. projects={projects}
  1058. location={location}
  1059. router={router}
  1060. source={DiscoverQueryPageSource.DISCOVER}
  1061. {...metricsDataSide}
  1062. />
  1063. ) : null}
  1064. <FiltersBar
  1065. filters={(modifiedDashboard ?? dashboard).filters}
  1066. dashboardPermissions={dashboard.permissions}
  1067. dashboardCreator={dashboard.createdBy}
  1068. location={location}
  1069. hasUnsavedChanges={hasUnsavedFilters}
  1070. isEditingDashboard={
  1071. dashboardState !== DashboardState.CREATE &&
  1072. this.isEditingDashboard
  1073. }
  1074. isPreview={this.isPreview}
  1075. onDashboardFilterChange={this.handleChangeFilter}
  1076. onCancel={() => {
  1077. resetPageFilters(dashboard, location);
  1078. trackAnalytics('dashboards2.filter.cancel', {
  1079. organization,
  1080. });
  1081. this.setState({
  1082. modifiedDashboard: {
  1083. ...(modifiedDashboard ?? dashboard),
  1084. filters: dashboard.filters,
  1085. },
  1086. });
  1087. }}
  1088. onSave={() => {
  1089. const newModifiedDashboard = {
  1090. ...cloneDashboard(modifiedDashboard ?? dashboard),
  1091. ...getCurrentPageFilters(location),
  1092. filters:
  1093. getDashboardFiltersFromURL(location) ??
  1094. (modifiedDashboard ?? dashboard).filters,
  1095. };
  1096. updateDashboard(
  1097. api,
  1098. organization.slug,
  1099. newModifiedDashboard
  1100. ).then(
  1101. (newDashboard: DashboardDetails) => {
  1102. addSuccessMessage(t('Dashboard filters updated'));
  1103. trackAnalytics('dashboards2.filter.save', {
  1104. organization,
  1105. });
  1106. const navigateToDashboard = () => {
  1107. browserHistory.replace(
  1108. normalizeUrl({
  1109. pathname: `/organizations/${organization.slug}/dashboard/${newDashboard.id}/`,
  1110. query: omit(
  1111. location.query,
  1112. Object.values(DashboardFilterKeys)
  1113. ),
  1114. })
  1115. );
  1116. };
  1117. if (onDashboardUpdate) {
  1118. onDashboardUpdate(newDashboard);
  1119. this.setState(
  1120. {
  1121. modifiedDashboard: null,
  1122. },
  1123. () => {
  1124. // Wait for modifiedDashboard state to update before navigating
  1125. navigateToDashboard();
  1126. }
  1127. );
  1128. return;
  1129. }
  1130. navigateToDashboard();
  1131. },
  1132. // `updateDashboard` does its own error handling
  1133. () => undefined
  1134. );
  1135. }}
  1136. />
  1137. <WidgetViewerContext.Provider value={{seriesData, setData}}>
  1138. <Fragment>
  1139. <Dashboard
  1140. paramDashboardId={dashboardId}
  1141. dashboard={modifiedDashboard ?? dashboard}
  1142. organization={organization}
  1143. isEditingDashboard={this.isEditingDashboard}
  1144. widgetLimitReached={widgetLimitReached}
  1145. onUpdate={this.onUpdateWidget}
  1146. handleUpdateWidgetList={this.handleUpdateWidgetList}
  1147. handleAddCustomWidget={this.handleAddCustomWidget}
  1148. handleAddMetricWidget={this.handleAddMetricWidget}
  1149. router={router}
  1150. location={location}
  1151. newWidget={newWidget}
  1152. onSetNewWidget={onSetNewWidget}
  1153. isPreview={this.isPreview}
  1154. widgetLegendState={this.state.widgetLegendState}
  1155. onAddWidget={this.onAddWidget}
  1156. onEditWidget={this.onEditWidget}
  1157. />
  1158. <DevWidgetBuilder
  1159. isOpen={this.state.isWidgetBuilderOpen}
  1160. onClose={() => {
  1161. this.setState({isWidgetBuilderOpen: false});
  1162. router.push(
  1163. getDashboardLocation({
  1164. organization,
  1165. dashboardId,
  1166. location,
  1167. })
  1168. );
  1169. }}
  1170. />
  1171. </Fragment>
  1172. </WidgetViewerContext.Provider>
  1173. </MEPSettingProvider>
  1174. )}
  1175. </MetricsDataSwitcher>
  1176. </MetricsCardinalityProvider>
  1177. </Layout.Main>
  1178. </Layout.Body>
  1179. </NoProjectMessage>
  1180. </MetricsResultsMetaProvider>
  1181. </OnDemandControlProvider>
  1182. </Layout.Page>
  1183. </PageFiltersContainer>
  1184. </SentryDocumentTitle>
  1185. );
  1186. }
  1187. render() {
  1188. const {organization} = this.props;
  1189. if (this.isWidgetBuilderRouter) {
  1190. return this.renderWidgetBuilder();
  1191. }
  1192. if (organization.features.includes('dashboards-edit')) {
  1193. return this.renderDashboardDetail();
  1194. }
  1195. return this.renderDefaultDashboardDetail();
  1196. }
  1197. }
  1198. const StyledPageHeader = styled('div')`
  1199. display: grid;
  1200. grid-template-columns: minmax(0, 1fr);
  1201. grid-row-gap: ${space(2)};
  1202. align-items: center;
  1203. margin-bottom: ${space(2)};
  1204. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  1205. grid-template-columns: minmax(0, 1fr) max-content;
  1206. grid-column-gap: ${space(2)};
  1207. height: 40px;
  1208. }
  1209. `;
  1210. export default withPageFilters(withProjects(withApi(withOrganization(DashboardDetail))));