Skip to content

Commit 3e77535

Browse files
committed
fixed some issues, rendering dashboard successfully
1 parent 4e1627b commit 3e77535

File tree

12 files changed

+514
-243
lines changed

12 files changed

+514
-243
lines changed

conf/defaults.ini

-11
Original file line numberDiff line numberDiff line change
@@ -1568,17 +1568,6 @@ index_update_interval = 10s
15681568
[navigation.app_standalone_pages]
15691569

15701570

1571-
#################################### Secure Socks5 Datasource Proxy #####################################
1572-
[secure_socks_datasource_proxy]
1573-
enabled = false
1574-
root_ca_cert =
1575-
client_key =
1576-
client_cert =
1577-
server_name =
1578-
# The address of the socks5 proxy datasources should connect to
1579-
proxy_address =
1580-
1581-
15821571
#################################### Secure Socks5 Datasource Proxy #####################################
15831572
[secure_socks_datasource_proxy]
15841573
enabled = false

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@
256256
"dependencies": {
257257
"@daybrush/utils": "1.13.0",
258258
"@emotion/css": "11.11.2",
259-
"@emotion/react": "11.11.1",
259+
"@emotion/react": "^11.11.1",
260+
"@emotion/styled": "^11.11.0",
260261
"@glideapps/glide-data-grid": "^5.2.1",
261262
"@grafana/aws-sdk": "0.0.44",
262263
"@grafana/data": "workspace:*",
@@ -279,6 +280,7 @@
279280
"@locker/near-membrane-dom": "^0.12.15",
280281
"@locker/near-membrane-shared": "^0.12.15",
281282
"@locker/near-membrane-shared-dom": "^0.12.15",
283+
"@mui/material": "^5.14.13",
282284
"@opentelemetry/api": "1.4.0",
283285
"@opentelemetry/exporter-collector": "0.25.0",
284286
"@opentelemetry/semantic-conventions": "1.15.0",
@@ -371,6 +373,7 @@
371373
"prismjs": "1.29.0",
372374
"prop-types": "15.8.1",
373375
"pseudoizer": "^0.1.0",
376+
"query-string": "^8.1.0",
374377
"rc-cascader": "3.12.1",
375378
"rc-drawer": "6.3.0",
376379
"rc-slider": "10.2.1",

packages/grafana-ui/src/themes/GlobalStyles/elements.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export function getElementStyles(theme: GrafanaTheme2) {
1010
MsOverflowStyle: 'scrollbar',
1111
WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
1212
height: '100%',
13-
fontSize: `${theme.typography.htmlFontSize}px`,
1413
fontFamily: theme.typography.fontFamily,
1514
lineHeight: theme.typography.body.lineHeight,
1615
fontKerning: 'normal',

pkg/api/static/static.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func staticHandler(ctx *web.Context, log log.Logger, opt StaticOptions) bool {
149149
log.Error("Failed to close file", "error", err)
150150
}
151151
}()
152+
httpFile := f
152153

153154
fi, err := f.Stat()
154155
if err != nil {
@@ -183,10 +184,11 @@ func staticHandler(ctx *web.Context, log log.Logger, opt StaticOptions) bool {
183184
}
184185
}()
185186

186-
fi, err = f.Stat()
187+
fi, err = indexFile.Stat()
187188
if err != nil || fi.IsDir() {
188189
return true
189190
}
191+
httpFile = indexFile
190192
}
191193

192194
if !opt.SkipLogging {
@@ -198,7 +200,7 @@ func staticHandler(ctx *web.Context, log log.Logger, opt StaticOptions) bool {
198200
opt.AddHeaders(ctx)
199201
}
200202

201-
http.ServeContent(ctx.Resp, ctx.Req, file, fi.ModTime(), f)
203+
http.ServeContent(ctx.Resp, ctx.Req, file, fi.ModTime(), httpFile)
202204
return true
203205
}
204206

@@ -210,4 +212,4 @@ func Static(directory string, staticOpt ...StaticOptions) web.Handler {
210212
return func(ctx *web.Context) {
211213
staticHandler(ctx, logger, opt)
212214
}
213-
}
215+
}

public/app/core/services/backend_srv.ts

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class BackendSrv implements BackendService {
6161
private readonly fetchQueue: FetchQueue;
6262
private readonly responseQueue: ResponseQueue;
6363
private _tokenRotationInProgress?: Observable<FetchResponse> | null = null;
64+
private grafanaPrefix: boolean;
6465

6566
private dependencies: BackendSrvDependencies = {
6667
fromFetch: fromFetch,

public/app/features/dashboard/containers/DashboardPage.tsx

+83-52
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cx } from '@emotion/css';
22
import React, { PureComponent } from 'react';
3-
import { connect, ConnectedProps } from 'react-redux';
3+
import { connect, ConnectedProps, MapDispatchToProps, MapStateToProps } from 'react-redux';
44

55
import { NavModel, NavModelItem, TimeRange, PageLayoutType, locationUtil } from '@grafana/data';
66
import { selectors } from '@grafana/e2e-selectors';
@@ -13,11 +13,13 @@ import { GrafanaContext, GrafanaContextType } from 'app/core/context/GrafanaCont
1313
import { createErrorNotification } from 'app/core/copy/appNotification';
1414
import { getKioskMode } from 'app/core/navigation/kiosk';
1515
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
16+
import { FnGlobalState } from 'app/core/reducers/fn-slice';
1617
import { getNavModel } from 'app/core/selectors/navModel';
1718
import { PanelModel } from 'app/features/dashboard/state';
1819
import { dashboardWatcher } from 'app/features/live/dashboard/dashboardWatcher';
1920
import { getPageNavFromSlug, getRootContentNavModel } from 'app/features/storage/StorageFolderPage';
20-
import { DashboardRoutes, KioskMode, StoreState } from 'app/types';
21+
import { FNDashboardProps } from 'app/fn-app/types';
22+
import { DashboardRoutes, DashboardState, KioskMode, StoreState } from 'app/types';
2123
import { PanelEditEnteredEvent, PanelEditExitedEvent } from 'app/types/events';
2224

2325
import { cancelVariables, templateVarsChangedInUrl } from '../../variables/state/actions';
@@ -26,6 +28,7 @@ import { AddWidgetModal } from '../components/AddWidgetModal/AddWidgetModal';
2628
import { DashNav } from '../components/DashNav';
2729
import { DashboardFailed } from '../components/DashboardLoading/DashboardFailed';
2830
import { DashboardLoading } from '../components/DashboardLoading/DashboardLoading';
31+
import { FnLoader } from '../components/DashboardLoading/FnLoader';
2932
import { DashboardPrompt } from '../components/DashboardPrompt/DashboardPrompt';
3033
import { DashboardSettings } from '../components/DashboardSettings';
3134
import { PanelInspector } from '../components/Inspector/PanelInspector';
@@ -52,7 +55,7 @@ export type DashboardPageRouteSearchParams = {
5255
editPanel?: string;
5356
viewPanel?: string;
5457
editview?: string;
55-
addWidget?: boolean;
58+
shareView?: string;
5659
panelType?: string;
5760
inspect?: string;
5861
from?: string;
@@ -61,14 +64,34 @@ export type DashboardPageRouteSearchParams = {
6164
kiosk?: string | true;
6265
};
6366

64-
export const mapStateToProps = (state: StoreState) => ({
67+
export type MapStateToDashboardPageProps = MapStateToProps<
68+
Pick<DashboardState, 'initPhase' | 'initError'> & { dashboard: ReturnType<DashboardState['getModel']> } & Pick<
69+
FnGlobalState,
70+
'FNDashboard'
71+
>,
72+
OwnProps,
73+
StoreState
74+
>;
75+
76+
export type MapDispatchToDashboardPageProps = MapDispatchToProps<MappedDispatch, OwnProps>;
77+
78+
export type MappedDispatch = {
79+
initDashboard: typeof initDashboard;
80+
cleanUpDashboardAndVariables: typeof cleanUpDashboardAndVariables;
81+
notifyApp: typeof notifyApp;
82+
cancelVariables: typeof cancelVariables;
83+
templateVarsChangedInUrl: typeof templateVarsChangedInUrl;
84+
};
85+
86+
export const mapStateToProps: MapStateToDashboardPageProps = (state) => ({
6587
initPhase: state.dashboard.initPhase,
6688
initError: state.dashboard.initError,
6789
dashboard: state.dashboard.getModel(),
6890
navIndex: state.navIndex,
91+
FNDashboard: state.fnGlobalState.FNDashboard,
6992
});
7093

71-
const mapDispatchToProps = {
94+
const mapDispatchToProps: MapDispatchToDashboardPageProps = {
7295
initDashboard,
7396
cleanUpDashboardAndVariables,
7497
notifyApp,
@@ -78,6 +101,16 @@ const mapDispatchToProps = {
78101

79102
const connector = connect(mapStateToProps, mapDispatchToProps);
80103

104+
type OwnProps = {
105+
isPublic?: boolean;
106+
controlsContainer?: string | null;
107+
version?: FNDashboardProps['version'];
108+
isLoading?: FNDashboardProps['isLoading'];
109+
};
110+
111+
export type DashboardPageProps = OwnProps &
112+
GrafanaRouteComponentProps<DashboardPageRouteParams, DashboardPageRouteSearchParams>;
113+
81114
export type Props = Themeable2 &
82115
GrafanaRouteComponentProps<DashboardPageRouteParams, DashboardPageRouteSearchParams> &
83116
ConnectedProps<typeof connector>;
@@ -114,7 +147,11 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
114147

115148
componentDidMount() {
116149
this.initDashboard();
117-
this.forceRouteReloadCounter = (this.props.history.location.state as any)?.routeReloadCounter || 0;
150+
const { FNDashboard } = this.props;
151+
152+
if (!FNDashboard) {
153+
this.forceRouteReloadCounter = (this.props.history.location?.state as any)?.routeReloadCounter || 0;
154+
}
118155
}
119156

120157
componentWillUnmount() {
@@ -127,7 +164,7 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
127164
}
128165

129166
initDashboard() {
130-
const { dashboard, match, queryParams } = this.props;
167+
const { dashboard, match, queryParams, FNDashboard } = this.props;
131168

132169
if (dashboard) {
133170
this.closeDashboard();
@@ -140,30 +177,34 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
140177
urlFolderUid: queryParams.folderUid,
141178
panelType: queryParams.panelType,
142179
routeName: this.props.route.routeName,
143-
fixUrl: true,
180+
fixUrl: !FNDashboard,
144181
accessToken: match.params.accessToken,
145-
keybindingSrv: this.context?.keybindings,
182+
keybindingSrv: this.context.keybindings,
146183
});
147184

148185
// small delay to start live updates
149186
setTimeout(this.updateLiveTimer, 250);
150187
}
151188

152189
componentDidUpdate(prevProps: Props, prevState: State) {
153-
const { dashboard, match, templateVarsChangedInUrl } = this.props;
154-
const routeReloadCounter = (this.props.history.location.state as any)?.routeReloadCounter;
190+
const { dashboard, match, templateVarsChangedInUrl, FNDashboard } = this.props;
155191

156192
if (!dashboard) {
157193
return;
158194
}
159195

160-
if (
161-
prevProps.match.params.uid !== match.params.uid ||
162-
(routeReloadCounter !== undefined && this.forceRouteReloadCounter !== routeReloadCounter)
163-
) {
164-
this.initDashboard();
165-
this.forceRouteReloadCounter = routeReloadCounter;
166-
return;
196+
if (!FNDashboard) {
197+
const routeReloadCounter = (this.props.history.location?.state as any)?.routeReloadCounter;
198+
199+
if (
200+
prevProps.match.params.uid !== match.params.uid ||
201+
prevProps.match.params.version !== match.params.version ||
202+
(routeReloadCounter !== undefined && this.forceRouteReloadCounter !== routeReloadCounter)
203+
) {
204+
this.initDashboard();
205+
this.forceRouteReloadCounter = routeReloadCounter;
206+
return;
207+
}
167208
}
168209

169210
if (prevProps.location.search !== this.props.location.search) {
@@ -332,18 +373,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
332373
}
333374

334375
render() {
335-
const { dashboard, initError, queryParams } = this.props;
376+
const { dashboard, initError, queryParams, FNDashboard } = this.props;
336377
const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state;
337378
const kioskMode = getKioskMode(this.props.queryParams);
338379

339-
if (!dashboard || !pageNav || !sectionNav) {
340-
return <DashboardLoading initPhase={this.props.initPhase} />;
380+
if (!dashboard) {
381+
return FNDashboard ? <FnLoader /> : <DashboardLoading initPhase={this.props.initPhase} />;
341382
}
342383

343384
const inspectPanel = this.getInspectPanel();
344385
const showSubMenu = !editPanel && !kioskMode && !this.props.queryParams.editview;
345386

346-
const showToolbar = kioskMode !== KioskMode.Full && !queryParams.editview;
387+
const showToolbar = FNDashboard || (kioskMode !== KioskMode.Full && !queryParams.editview);
347388

348389
const pageClassName = cx({
349390
'panel-in-fullscreen': Boolean(viewPanel),
@@ -381,23 +422,23 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
381422
/>
382423
</header>
383424
)}
384-
<DashboardPrompt dashboard={dashboard} />
425+
{!FNDashboard && <DashboardPrompt dashboard={dashboard} />}
385426
{initError && <DashboardFailed />}
386-
{showSubMenu && (
427+
{showSubMenu && !FNDashboard && (
387428
<section aria-label={selectors.pages.Dashboard.SubMenu.submenu}>
388429
<SubMenu dashboard={dashboard} annotations={dashboard.annotations.list} links={dashboard.links} />
389430
</section>
390431
)}
391432
<DashboardGrid
392433
dashboard={dashboard}
393-
isEditable={!!dashboard.meta.canEdit}
434+
isEditable={!!dashboard.meta.canEdit && !FNDashboard}
394435
viewPanel={viewPanel}
395436
editPanel={editPanel}
396437
/>
397438

398-
{inspectPanel && <PanelInspector dashboard={dashboard} panel={inspectPanel} />}
439+
{inspectPanel && !FNDashboard && <PanelInspector dashboard={dashboard} panel={inspectPanel} />}
399440
</Page>
400-
{editPanel && (
441+
{editPanel && !FNDashboard && (
401442
<PanelEditor
402443
dashboard={dashboard}
403444
sourcePanel={editPanel}
@@ -406,31 +447,31 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
406447
pageNav={pageNav}
407448
/>
408449
)}
409-
{queryParams.editview && (
450+
{queryParams.editview && !FNDashboard && (
410451
<DashboardSettings
411452
dashboard={dashboard}
412453
editview={queryParams.editview}
413454
pageNav={pageNav}
414455
sectionNav={sectionNav}
415456
/>
416457
)}
417-
{queryParams.addWidget && config.featureToggles.vizAndWidgetSplit && <AddWidgetModal />}
458+
{!FNDashboard && queryParams.addWidget && config.featureToggles.vizAndWidgetSplit && <AddWidgetModal />}
418459
</>
419460
);
420461
}
421462
}
422463

423464
function updateStatePageNavFromProps(props: Props, state: State): State {
424-
const { dashboard, navIndex } = props;
465+
const { dashboard, FNDashboard } = props;
425466

426-
if (!dashboard) {
467+
if (!dashboard || FNDashboard) {
427468
return state;
428469
}
429470

430471
let pageNav = state.pageNav;
431472
let sectionNav = state.sectionNav;
432473

433-
if (!pageNav || dashboard.title !== pageNav.text || dashboard.meta.folderUrl !== pageNav.parentItem?.url) {
474+
if (!pageNav || dashboard.title !== pageNav.text) {
434475
pageNav = {
435476
text: dashboard.title,
436477
url: locationUtil.getUrlForPartial(props.history.location, {
@@ -441,26 +482,16 @@ function updateStatePageNavFromProps(props: Props, state: State): State {
441482
};
442483
}
443484

485+
// Check if folder changed
444486
const { folderTitle, folderUid } = dashboard.meta;
445-
if (folderUid && pageNav) {
446-
if (config.featureToggles.nestedFolders) {
447-
const folderNavModel = getNavModel(navIndex, `folder-dashboards-${folderUid}`).main;
448-
pageNav = {
449-
...pageNav,
450-
parentItem: folderNavModel,
451-
};
452-
} else {
453-
// Check if folder changed
454-
if (folderTitle && pageNav.parentItem?.text !== folderTitle) {
455-
pageNav = {
456-
...pageNav,
457-
parentItem: {
458-
text: folderTitle,
459-
url: `/dashboards/f/${dashboard.meta.folderUid}`,
460-
},
461-
};
462-
}
463-
}
487+
if (folderTitle && folderUid && pageNav && pageNav.parentItem?.text !== folderTitle) {
488+
pageNav = {
489+
...pageNav,
490+
parentItem: {
491+
text: folderTitle,
492+
url: `/dashboards/f/${dashboard.meta.folderUid}`,
493+
},
494+
};
464495
}
465496

466497
if (props.route.routeName === DashboardRoutes.Path) {
@@ -470,7 +501,7 @@ function updateStatePageNavFromProps(props: Props, state: State): State {
470501
pageNav.parentItem = pageNav.parentItem;
471502
}
472503
} else {
473-
sectionNav = getNavModel(props.navIndex, 'dashboards/browse');
504+
sectionNav = getNavModel(props.navIndex, config.featureToggles.topnav ? 'dashboards/browse' : 'dashboards');
474505
}
475506

476507
if (state.editPanel || state.viewPanel) {

0 commit comments

Comments
 (0)