mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: Revert Time range setting added (#60698)
Revert "PublicDashboards: Time range setting added (#60487)"
This reverts commit 6f609dbced
.
This commit is contained in:
parent
e9fe9baf66
commit
9c3ddda99b
@ -188,7 +188,6 @@ export const Pages = {
|
|||||||
CostIncreaseCheckbox: 'data-testid public dashboard cost may increase checkbox',
|
CostIncreaseCheckbox: 'data-testid public dashboard cost may increase checkbox',
|
||||||
EnableSwitch: 'data-testid public dashboard on off switch',
|
EnableSwitch: 'data-testid public dashboard on off switch',
|
||||||
EnableAnnotationsSwitch: 'data-testid public dashboard on off switch for annotations',
|
EnableAnnotationsSwitch: 'data-testid public dashboard on off switch for annotations',
|
||||||
EnableTimeRangeSwitch: 'data-testid public dashboard on off switch for time range',
|
|
||||||
SaveConfigButton: 'data-testid public dashboard save config button',
|
SaveConfigButton: 'data-testid public dashboard save config button',
|
||||||
DeleteButton: 'data-testid public dashboard delete button',
|
DeleteButton: 'data-testid public dashboard delete button',
|
||||||
CopyUrlInput: 'data-testid public dashboard copy url input',
|
CopyUrlInput: 'data-testid public dashboard copy url input',
|
||||||
|
@ -101,10 +101,9 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
hasPublicDashboard = false
|
hasPublicDashboard = false
|
||||||
publicDashboardEnabled = false
|
publicDashboardEnabled = false
|
||||||
publicDashboardTimeSelectionEnabled = false
|
err error
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// If public dashboards is enabled and we have a public dashboard, update meta
|
// If public dashboards is enabled and we have a public dashboard, update meta
|
||||||
@ -117,7 +116,6 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
|||||||
|
|
||||||
if publicDashboard != nil {
|
if publicDashboard != nil {
|
||||||
hasPublicDashboard = true
|
hasPublicDashboard = true
|
||||||
publicDashboardTimeSelectionEnabled = publicDashboard.TimeSelectionEnabled
|
|
||||||
publicDashboardEnabled = publicDashboard.IsEnabled
|
publicDashboardEnabled = publicDashboard.IsEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,28 +167,27 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
meta := dtos.DashboardMeta{
|
meta := dtos.DashboardMeta{
|
||||||
IsStarred: isStarred,
|
IsStarred: isStarred,
|
||||||
Slug: dash.Slug,
|
Slug: dash.Slug,
|
||||||
Type: models.DashTypeDB,
|
Type: models.DashTypeDB,
|
||||||
CanStar: c.IsSignedIn,
|
CanStar: c.IsSignedIn,
|
||||||
CanSave: canSave,
|
CanSave: canSave,
|
||||||
CanEdit: canEdit,
|
CanEdit: canEdit,
|
||||||
CanAdmin: canAdmin,
|
CanAdmin: canAdmin,
|
||||||
CanDelete: canDelete,
|
CanDelete: canDelete,
|
||||||
Created: dash.Created,
|
Created: dash.Created,
|
||||||
Updated: dash.Updated,
|
Updated: dash.Updated,
|
||||||
UpdatedBy: updater,
|
UpdatedBy: updater,
|
||||||
CreatedBy: creator,
|
CreatedBy: creator,
|
||||||
Version: dash.Version,
|
Version: dash.Version,
|
||||||
HasACL: dash.HasACL,
|
HasACL: dash.HasACL,
|
||||||
IsFolder: dash.IsFolder,
|
IsFolder: dash.IsFolder,
|
||||||
FolderId: dash.FolderId,
|
FolderId: dash.FolderId,
|
||||||
Url: dash.GetUrl(),
|
Url: dash.GetUrl(),
|
||||||
FolderTitle: "General",
|
FolderTitle: "General",
|
||||||
AnnotationsPermissions: annotationPermissions,
|
AnnotationsPermissions: annotationPermissions,
|
||||||
PublicDashboardEnabled: publicDashboardEnabled,
|
PublicDashboardEnabled: publicDashboardEnabled,
|
||||||
HasPublicDashboard: hasPublicDashboard,
|
HasPublicDashboard: hasPublicDashboard,
|
||||||
PublicDashboardTimeSelectionEnabled: publicDashboardTimeSelectionEnabled,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup folder title
|
// lookup folder title
|
||||||
|
@ -7,36 +7,35 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DashboardMeta struct {
|
type DashboardMeta struct {
|
||||||
IsStarred bool `json:"isStarred,omitempty"`
|
IsStarred bool `json:"isStarred,omitempty"`
|
||||||
IsSnapshot bool `json:"isSnapshot,omitempty"`
|
IsSnapshot bool `json:"isSnapshot,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
CanSave bool `json:"canSave"`
|
CanSave bool `json:"canSave"`
|
||||||
CanEdit bool `json:"canEdit"`
|
CanEdit bool `json:"canEdit"`
|
||||||
CanAdmin bool `json:"canAdmin"`
|
CanAdmin bool `json:"canAdmin"`
|
||||||
CanStar bool `json:"canStar"`
|
CanStar bool `json:"canStar"`
|
||||||
CanDelete bool `json:"canDelete"`
|
CanDelete bool `json:"canDelete"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
Expires time.Time `json:"expires"`
|
Expires time.Time `json:"expires"`
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
Updated time.Time `json:"updated"`
|
Updated time.Time `json:"updated"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
||||||
IsFolder bool `json:"isFolder"`
|
IsFolder bool `json:"isFolder"`
|
||||||
FolderId int64 `json:"folderId"`
|
FolderId int64 `json:"folderId"`
|
||||||
FolderUid string `json:"folderUid"`
|
FolderUid string `json:"folderUid"`
|
||||||
FolderTitle string `json:"folderTitle"`
|
FolderTitle string `json:"folderTitle"`
|
||||||
FolderUrl string `json:"folderUrl"`
|
FolderUrl string `json:"folderUrl"`
|
||||||
Provisioned bool `json:"provisioned"`
|
Provisioned bool `json:"provisioned"`
|
||||||
ProvisionedExternalId string `json:"provisionedExternalId"`
|
ProvisionedExternalId string `json:"provisionedExternalId"`
|
||||||
AnnotationsPermissions *AnnotationPermission `json:"annotationsPermissions"`
|
AnnotationsPermissions *AnnotationPermission `json:"annotationsPermissions"`
|
||||||
HasPublicDashboard bool `json:"hasPublicDashboard"`
|
HasPublicDashboard bool `json:"hasPublicDashboard"`
|
||||||
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
|
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
|
||||||
PublicDashboardUID string `json:"publicDashboardUid"`
|
PublicDashboardUID string `json:"publicDashboardUid"`
|
||||||
PublicDashboardEnabled bool `json:"publicDashboardEnabled"`
|
PublicDashboardEnabled bool `json:"publicDashboardEnabled"`
|
||||||
PublicDashboardTimeSelectionEnabled bool `json:"publicDashboardTimeSelectionEnabled"`
|
|
||||||
}
|
}
|
||||||
type AnnotationPermission struct {
|
type AnnotationPermission struct {
|
||||||
Dashboard AnnotationActions `json:"dashboard"`
|
Dashboard AnnotationActions `json:"dashboard"`
|
||||||
|
@ -29,21 +29,20 @@ func (api *Api) ViewPublicDashboard(c *models.ReqContext) response.Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
meta := dtos.DashboardMeta{
|
meta := dtos.DashboardMeta{
|
||||||
Slug: dash.Slug,
|
Slug: dash.Slug,
|
||||||
Type: models.DashTypeDB,
|
Type: models.DashTypeDB,
|
||||||
CanStar: false,
|
CanStar: false,
|
||||||
CanSave: false,
|
CanSave: false,
|
||||||
CanEdit: false,
|
CanEdit: false,
|
||||||
CanAdmin: false,
|
CanAdmin: false,
|
||||||
CanDelete: false,
|
CanDelete: false,
|
||||||
Created: dash.Created,
|
Created: dash.Created,
|
||||||
Updated: dash.Updated,
|
Updated: dash.Updated,
|
||||||
Version: dash.Version,
|
Version: dash.Version,
|
||||||
IsFolder: false,
|
IsFolder: false,
|
||||||
FolderId: dash.FolderId,
|
FolderId: dash.FolderId,
|
||||||
PublicDashboardAccessToken: pubdash.AccessToken,
|
PublicDashboardAccessToken: pubdash.AccessToken,
|
||||||
PublicDashboardUID: pubdash.Uid,
|
PublicDashboardUID: pubdash.Uid,
|
||||||
PublicDashboardTimeSelectionEnabled: pubdash.TimeSelectionEnabled,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dto := dtos.DashboardFullWithMeta{Meta: meta, Dashboard: dash.Data}
|
dto := dtos.DashboardFullWithMeta{Meta: meta, Dashboard: dash.Data}
|
||||||
|
@ -70,7 +70,6 @@ export const publicDashboardApi = createApi({
|
|||||||
hasPublicDashboard: true,
|
hasPublicDashboard: true,
|
||||||
publicDashboardUid: data.uid,
|
publicDashboardUid: data.uid,
|
||||||
publicDashboardEnabled: data.isEnabled,
|
publicDashboardEnabled: data.isEnabled,
|
||||||
publicDashboardTimeSelectionEnabled: data.timeSelectionEnabled,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
invalidatesTags: (result, error, { payload }) => [{ type: 'PublicDashboard', id: payload.dashboardUid }],
|
invalidatesTags: (result, error, { payload }) => [{ type: 'PublicDashboard', id: payload.dashboardUid }],
|
||||||
@ -91,7 +90,6 @@ export const publicDashboardApi = createApi({
|
|||||||
hasPublicDashboard: true,
|
hasPublicDashboard: true,
|
||||||
publicDashboardUid: data.uid,
|
publicDashboardUid: data.uid,
|
||||||
publicDashboardEnabled: data.isEnabled,
|
publicDashboardEnabled: data.isEnabled,
|
||||||
publicDashboardTimeSelectionEnabled: data.timeSelectionEnabled,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
invalidatesTags: (result, error, { payload }) => [{ type: 'PublicDashboard', id: payload.dashboardUid }],
|
invalidatesTags: (result, error, { payload }) => [{ type: 'PublicDashboard', id: payload.dashboardUid }],
|
||||||
|
@ -36,7 +36,6 @@ describe('Public dashboard title tag', () => {
|
|||||||
isFullscreen={false}
|
isFullscreen={false}
|
||||||
onAddPanel={() => {}}
|
onAddPanel={() => {}}
|
||||||
title="test"
|
title="test"
|
||||||
isPublic={false}
|
|
||||||
/>
|
/>
|
||||||
</Router>
|
</Router>
|
||||||
</GrafanaContext.Provider>
|
</GrafanaContext.Provider>
|
||||||
|
@ -58,7 +58,6 @@ export interface OwnProps {
|
|||||||
title: string;
|
title: string;
|
||||||
shareModalActiveTab?: string;
|
shareModalActiveTab?: string;
|
||||||
onAddPanel: () => void;
|
onAddPanel: () => void;
|
||||||
isPublic: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DashNavButtonModel {
|
interface DashNavButtonModel {
|
||||||
@ -199,7 +198,7 @@ export const DashNav = React.memo<Props>((props) => {
|
|||||||
const { canStar, canShare, isStarred } = dashboard.meta;
|
const { canStar, canShare, isStarred } = dashboard.meta;
|
||||||
const buttons: ReactNode[] = [];
|
const buttons: ReactNode[] = [];
|
||||||
|
|
||||||
if (kioskMode || isPlaylistRunning() || props.isPublic) {
|
if (kioskMode || isPlaylistRunning()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,10 +321,6 @@ export const DashNav = React.memo<Props>((props) => {
|
|||||||
return [renderPlaylistControls(), renderTimeControls()];
|
return [renderPlaylistControls(), renderTimeControls()];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.isPublic && !!props.dashboard.meta.publicDashboardTimeSelectionEnabled) {
|
|
||||||
return [renderTimeControls()];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kioskMode === KioskMode.TV) {
|
if (kioskMode === KioskMode.TV) {
|
||||||
return [renderTimeControls(), tvButton];
|
return [renderTimeControls(), tvButton];
|
||||||
}
|
}
|
||||||
@ -423,8 +418,8 @@ export const DashNav = React.memo<Props>((props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageToolbar
|
<PageToolbar
|
||||||
pageIcon={isFullscreen || props.isPublic ? undefined : 'apps'}
|
pageIcon={isFullscreen ? undefined : 'apps'}
|
||||||
title={props.isPublic ? undefined : title}
|
title={title}
|
||||||
parent={folderTitle}
|
parent={folderTitle}
|
||||||
titleHref={titleHref}
|
titleHref={titleHref}
|
||||||
parentHref={parentHref}
|
parentHref={parentHref}
|
||||||
|
@ -34,15 +34,9 @@ export const Configuration = ({
|
|||||||
<FieldSet disabled={disabled} className={styles.dashboardConfig}>
|
<FieldSet disabled={disabled} className={styles.dashboardConfig}>
|
||||||
<VerticalGroup spacing="md">
|
<VerticalGroup spacing="md">
|
||||||
<Layout orientation={isDesktop ? 0 : 1} spacing="xs" justify="space-between">
|
<Layout orientation={isDesktop ? 0 : 1} spacing="xs" justify="space-between">
|
||||||
<Label description="The public dashboard uses the default time settings of the dashboard">
|
<Label description="The public dashboard uses the default time settings of the dashboard">Time range</Label>
|
||||||
Default time range
|
|
||||||
</Label>
|
|
||||||
<TimeRangeInput value={timeRange} disabled onChange={() => {}} />
|
<TimeRangeInput value={timeRange} disabled onChange={() => {}} />
|
||||||
</Layout>
|
</Layout>
|
||||||
<Layout orientation={isDesktop ? 0 : 1} spacing="xs" justify="space-between">
|
|
||||||
<Label description="Allow viewers to change time range">Time range picker enabled</Label>
|
|
||||||
<Switch {...register('isTimeRangeEnabled')} data-testid={selectors.EnableTimeRangeSwitch} />
|
|
||||||
</Layout>
|
|
||||||
<Layout orientation={isDesktop ? 0 : 1} spacing="xs" justify="space-between">
|
<Layout orientation={isDesktop ? 0 : 1} spacing="xs" justify="space-between">
|
||||||
<Label description="Show annotations on public dashboard">Show annotations</Label>
|
<Label description="Show annotations on public dashboard">Show annotations</Label>
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -19,8 +19,6 @@ import { configureStore } from 'app/store/configureStore';
|
|||||||
|
|
||||||
import { ShareModal } from '../ShareModal';
|
import { ShareModal } from '../ShareModal';
|
||||||
|
|
||||||
import { PublicDashboard } from './SharePublicDashboardUtils';
|
|
||||||
|
|
||||||
const server = setupServer();
|
const server = setupServer();
|
||||||
|
|
||||||
jest.mock('@grafana/runtime', () => ({
|
jest.mock('@grafana/runtime', () => ({
|
||||||
@ -162,7 +160,6 @@ describe('SharePublic', () => {
|
|||||||
expect(screen.getByTestId(selectors.LimitedDSCheckbox)).toBeDisabled();
|
expect(screen.getByTestId(selectors.LimitedDSCheckbox)).toBeDisabled();
|
||||||
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeDisabled();
|
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeDisabled();
|
||||||
expect(screen.getByTestId(selectors.EnableSwitch)).toBeDisabled();
|
expect(screen.getByTestId(selectors.EnableSwitch)).toBeDisabled();
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeDisabled();
|
|
||||||
expect(screen.getByTestId(selectors.SaveConfigButton)).toBeDisabled();
|
expect(screen.getByTestId(selectors.SaveConfigButton)).toBeDisabled();
|
||||||
expect(screen.queryByTestId(selectors.DeleteButton)).not.toBeInTheDocument();
|
expect(screen.queryByTestId(selectors.DeleteButton)).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@ -181,7 +178,6 @@ describe('SharePublic', () => {
|
|||||||
expect(screen.getByTestId(selectors.LimitedDSCheckbox)).toBeDisabled();
|
expect(screen.getByTestId(selectors.LimitedDSCheckbox)).toBeDisabled();
|
||||||
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeDisabled();
|
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeDisabled();
|
||||||
expect(screen.getByTestId(selectors.EnableSwitch)).toBeDisabled();
|
expect(screen.getByTestId(selectors.EnableSwitch)).toBeDisabled();
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeDisabled();
|
|
||||||
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeDisabled();
|
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeDisabled();
|
||||||
expect(screen.getByText('Save public dashboard')).toBeInTheDocument();
|
expect(screen.getByText('Save public dashboard')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId(selectors.SaveConfigButton)).toBeDisabled();
|
expect(screen.getByTestId(selectors.SaveConfigButton)).toBeDisabled();
|
||||||
@ -224,7 +220,6 @@ describe('SharePublic - New config setup', () => {
|
|||||||
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeEnabled();
|
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeEnabled();
|
||||||
expect(screen.getByTestId(selectors.EnableSwitch)).toBeEnabled();
|
expect(screen.getByTestId(selectors.EnableSwitch)).toBeEnabled();
|
||||||
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeEnabled();
|
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeEnabled();
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeEnabled();
|
|
||||||
expect(screen.queryByTestId(selectors.DeleteButton)).not.toBeInTheDocument();
|
expect(screen.queryByTestId(selectors.DeleteButton)).not.toBeInTheDocument();
|
||||||
|
|
||||||
expect(screen.getByText('Create public dashboard')).toBeInTheDocument();
|
expect(screen.getByText('Create public dashboard')).toBeInTheDocument();
|
||||||
@ -259,15 +254,6 @@ describe('SharePublic - New config setup', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('SharePublic - Already persisted', () => {
|
describe('SharePublic - Already persisted', () => {
|
||||||
const pubdashResponse: PublicDashboard = {
|
|
||||||
isEnabled: true,
|
|
||||||
annotationsEnabled: true,
|
|
||||||
timeSelectionEnabled: true,
|
|
||||||
uid: 'a-uid',
|
|
||||||
dashboardUid: '',
|
|
||||||
accessToken: 'an-access-token',
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockDashboard.meta.hasPublicDashboard = true;
|
mockDashboard.meta.hasPublicDashboard = true;
|
||||||
server.use(
|
server.use(
|
||||||
@ -275,8 +261,11 @@ describe('SharePublic - Already persisted', () => {
|
|||||||
return res(
|
return res(
|
||||||
ctx.status(200),
|
ctx.status(200),
|
||||||
ctx.json({
|
ctx.json({
|
||||||
...pubdashResponse,
|
isEnabled: true,
|
||||||
|
annotationsEnabled: true,
|
||||||
|
uid: 'a-uid',
|
||||||
dashboardUid: req.params.dashboardUid,
|
dashboardUid: req.params.dashboardUid,
|
||||||
|
accessToken: 'an-access-token',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -305,33 +294,6 @@ describe('SharePublic - Already persisted', () => {
|
|||||||
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeEnabled();
|
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeEnabled();
|
||||||
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeChecked();
|
expect(screen.getByTestId(selectors.EnableAnnotationsSwitch)).toBeChecked();
|
||||||
});
|
});
|
||||||
it('when modal is opened, then time range switch is enabled and checked when its checked in the db', async () => {
|
|
||||||
await renderSharePublicDashboard({ panel: mockPanel, dashboard: mockDashboard, onDismiss: () => {} });
|
|
||||||
await waitForElementToBeRemoved(screen.getAllByTestId('Spinner'));
|
|
||||||
|
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeEnabled();
|
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeChecked();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('when modal is opened, then time range switch is enabled and not checked when its not checked in the db', async () => {
|
|
||||||
server.use(
|
|
||||||
rest.get('/api/dashboards/uid/:dashboardUid/public-dashboards', (req, res, ctx) => {
|
|
||||||
return res(
|
|
||||||
ctx.status(200),
|
|
||||||
ctx.json({
|
|
||||||
...pubdashResponse,
|
|
||||||
timeSelectionEnabled: false,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
await renderSharePublicDashboard({ panel: mockPanel, dashboard: mockDashboard, onDismiss: () => {} });
|
|
||||||
await waitForElementToBeRemoved(screen.getAllByTestId('Spinner'));
|
|
||||||
|
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeEnabled();
|
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).not.toBeChecked();
|
|
||||||
});
|
|
||||||
it('when fetch is done, then loader spinner is gone, inputs are disabled and save button is enabled', async () => {
|
it('when fetch is done, then loader spinner is gone, inputs are disabled and save button is enabled', async () => {
|
||||||
await renderSharePublicDashboard({ panel: mockPanel, dashboard: mockDashboard, onDismiss: () => {} });
|
await renderSharePublicDashboard({ panel: mockPanel, dashboard: mockDashboard, onDismiss: () => {} });
|
||||||
await waitForElementToBeRemoved(screen.getAllByTestId('Spinner'));
|
await waitForElementToBeRemoved(screen.getAllByTestId('Spinner'));
|
||||||
@ -341,7 +303,6 @@ describe('SharePublic - Already persisted', () => {
|
|||||||
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeDisabled();
|
expect(screen.getByTestId(selectors.CostIncreaseCheckbox)).toBeDisabled();
|
||||||
|
|
||||||
expect(screen.getByTestId(selectors.EnableSwitch)).toBeEnabled();
|
expect(screen.getByTestId(selectors.EnableSwitch)).toBeEnabled();
|
||||||
expect(screen.getByTestId(selectors.EnableTimeRangeSwitch)).toBeEnabled();
|
|
||||||
expect(screen.getByText('Save public dashboard')).toBeInTheDocument();
|
expect(screen.getByText('Save public dashboard')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId(selectors.SaveConfigButton)).toBeEnabled();
|
expect(screen.getByTestId(selectors.SaveConfigButton)).toBeEnabled();
|
||||||
expect(screen.getByTestId(selectors.DeleteButton)).toBeEnabled();
|
expect(screen.getByTestId(selectors.DeleteButton)).toBeEnabled();
|
||||||
|
@ -53,7 +53,6 @@ type SharePublicDashboardAcknowledgmentInputs = {
|
|||||||
|
|
||||||
export type SharePublicDashboardInputs = {
|
export type SharePublicDashboardInputs = {
|
||||||
isAnnotationsEnabled: boolean;
|
isAnnotationsEnabled: boolean;
|
||||||
isTimeRangeEnabled: boolean;
|
|
||||||
enabledSwitch: boolean;
|
enabledSwitch: boolean;
|
||||||
} & SharePublicDashboardAcknowledgmentInputs;
|
} & SharePublicDashboardAcknowledgmentInputs;
|
||||||
|
|
||||||
@ -89,7 +88,6 @@ export const SharePublicDashboard = (props: Props) => {
|
|||||||
dataSourcesAcknowledgment: false,
|
dataSourcesAcknowledgment: false,
|
||||||
usageAcknowledgment: false,
|
usageAcknowledgment: false,
|
||||||
isAnnotationsEnabled: false,
|
isAnnotationsEnabled: false,
|
||||||
isTimeRangeEnabled: false,
|
|
||||||
enabledSwitch: false,
|
enabledSwitch: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -112,7 +110,6 @@ export const SharePublicDashboard = (props: Props) => {
|
|||||||
dataSourcesAcknowledgment: isPublicDashboardPersisted,
|
dataSourcesAcknowledgment: isPublicDashboardPersisted,
|
||||||
usageAcknowledgment: isPublicDashboardPersisted,
|
usageAcknowledgment: isPublicDashboardPersisted,
|
||||||
isAnnotationsEnabled: publicDashboard?.annotationsEnabled,
|
isAnnotationsEnabled: publicDashboard?.annotationsEnabled,
|
||||||
isTimeRangeEnabled: publicDashboard?.timeSelectionEnabled,
|
|
||||||
enabledSwitch: publicDashboard?.isEnabled,
|
enabledSwitch: publicDashboard?.isEnabled,
|
||||||
});
|
});
|
||||||
}, [publicDashboard, reset]);
|
}, [publicDashboard, reset]);
|
||||||
@ -154,7 +151,6 @@ export const SharePublicDashboard = (props: Props) => {
|
|||||||
...publicDashboard!,
|
...publicDashboard!,
|
||||||
isEnabled: values.enabledSwitch,
|
isEnabled: values.enabledSwitch,
|
||||||
annotationsEnabled: values.isAnnotationsEnabled,
|
annotationsEnabled: values.isAnnotationsEnabled,
|
||||||
timeSelectionEnabled: values.isTimeRangeEnabled,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ export interface PublicDashboard {
|
|||||||
uid: string;
|
uid: string;
|
||||||
dashboardUid: string;
|
dashboardUid: string;
|
||||||
timeSettings?: object;
|
timeSettings?: object;
|
||||||
timeSelectionEnabled: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DashboardResponse {
|
export interface DashboardResponse {
|
||||||
|
@ -336,19 +336,4 @@ describe('DashboardPage', () => {
|
|||||||
expect(screen.queryAllByLabelText(selectors.pages.Dashboard.SubMenu.submenu)).toHaveLength(0);
|
expect(screen.queryAllByLabelText(selectors.pages.Dashboard.SubMenu.submenu)).toHaveLength(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
dashboardPageScenario('When dashboard is public and timeSelection is enabled', (ctx) => {
|
|
||||||
ctx.setup(() => {
|
|
||||||
locationService.partial({ kiosk: false });
|
|
||||||
ctx.mount({
|
|
||||||
queryParams: {},
|
|
||||||
dashboard: getTestDashboard(null, { publicDashboardTimeSelectionEnabled: true }),
|
|
||||||
});
|
|
||||||
ctx.rerender({ dashboard: ctx.dashboard, isPublic: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render page toolbar because timeSelection is enabled, but not submenu', () => {
|
|
||||||
expect(screen.queryAllByTestId(selectors.pages.Dashboard.DashNav.navV2)).toHaveLength(1);
|
|
||||||
expect(screen.queryAllByLabelText(selectors.pages.Dashboard.SubMenu.submenu)).toHaveLength(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -352,8 +352,7 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
|
|||||||
const inspectPanel = this.getInspectPanel();
|
const inspectPanel = this.getInspectPanel();
|
||||||
const showSubMenu = !editPanel && !kioskMode && !this.props.queryParams.editview;
|
const showSubMenu = !editPanel && !kioskMode && !this.props.queryParams.editview;
|
||||||
|
|
||||||
const toolbar = ((kioskMode !== KioskMode.Full && !queryParams.editview) ||
|
const toolbar = kioskMode !== KioskMode.Full && !queryParams.editview && (
|
||||||
(isPublic && !!this.props.dashboard?.meta.publicDashboardTimeSelectionEnabled)) && (
|
|
||||||
<header data-testid={selectors.pages.Dashboard.DashNav.navV2}>
|
<header data-testid={selectors.pages.Dashboard.DashNav.navV2}>
|
||||||
<DashNav
|
<DashNav
|
||||||
dashboard={dashboard}
|
dashboard={dashboard}
|
||||||
@ -364,7 +363,6 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
|
|||||||
kioskMode={kioskMode}
|
kioskMode={kioskMode}
|
||||||
hideTimePicker={dashboard.timepicker.hidden}
|
hideTimePicker={dashboard.timepicker.hidden}
|
||||||
shareModalActiveTab={this.props.queryParams.shareView}
|
shareModalActiveTab={this.props.queryParams.shareView}
|
||||||
isPublic={!!isPublic}
|
|
||||||
/>
|
/>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
import { DataQueryRequest, DataSourceInstanceSettings, DataSourceRef, dateTime, TimeRange } from '@grafana/data';
|
import { DataQueryRequest, DataSourceInstanceSettings, DataSourceRef, TimeRange } from '@grafana/data';
|
||||||
import { BackendSrvRequest, BackendSrv, DataSourceWithBackend } from '@grafana/runtime';
|
import { BackendSrvRequest, BackendSrv, DataSourceWithBackend } from '@grafana/runtime';
|
||||||
import { GrafanaQueryType } from 'app/plugins/datasource/grafana/types';
|
import { GrafanaQueryType } from 'app/plugins/datasource/grafana/types';
|
||||||
import { MIXED_DATASOURCE_NAME } from 'app/plugins/datasource/mixed/MixedDataSource';
|
import { MIXED_DATASOURCE_NAME } from 'app/plugins/datasource/mixed/MixedDataSource';
|
||||||
@ -115,14 +115,6 @@ describe('PublicDashboardDatasource', () => {
|
|||||||
intervalMs: 5000,
|
intervalMs: 5000,
|
||||||
targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: 'sample' } }],
|
targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: 'sample' } }],
|
||||||
panelId,
|
panelId,
|
||||||
range: {
|
|
||||||
from: dateTime('2022-01-01T15:55:00Z'),
|
|
||||||
to: dateTime('2022-07-12T15:55:00Z'),
|
|
||||||
raw: {
|
|
||||||
from: 'now-15m',
|
|
||||||
to: 'now',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
publicDashboardAccessToken,
|
publicDashboardAccessToken,
|
||||||
} as DataQueryRequest);
|
} as DataQueryRequest);
|
||||||
|
|
||||||
|
@ -80,14 +80,7 @@ export class PublicDashboardDataSource extends DataSourceApi<DataQuery, DataSour
|
|||||||
* Ideally final -- any other implementation may not work as expected
|
* Ideally final -- any other implementation may not work as expected
|
||||||
*/
|
*/
|
||||||
query(request: DataQueryRequest<DataQuery>): Observable<DataQueryResponse> {
|
query(request: DataQueryRequest<DataQuery>): Observable<DataQueryResponse> {
|
||||||
const {
|
const { intervalMs, maxDataPoints, requestId, publicDashboardAccessToken, panelId } = request;
|
||||||
intervalMs,
|
|
||||||
maxDataPoints,
|
|
||||||
requestId,
|
|
||||||
publicDashboardAccessToken,
|
|
||||||
panelId,
|
|
||||||
range: { from: fromRange, to: toRange },
|
|
||||||
} = request;
|
|
||||||
let queries: DataQuery[];
|
let queries: DataQuery[];
|
||||||
|
|
||||||
// Return early if no queries exist
|
// Return early if no queries exist
|
||||||
@ -107,11 +100,7 @@ export class PublicDashboardDataSource extends DataSourceApi<DataQuery, DataSour
|
|||||||
|
|
||||||
// Its a datasource query
|
// Its a datasource query
|
||||||
else {
|
else {
|
||||||
const body = {
|
const body = { intervalMs, maxDataPoints };
|
||||||
intervalMs,
|
|
||||||
maxDataPoints,
|
|
||||||
timeRange: { from: fromRange.valueOf().toString(), to: toRange.valueOf().toString() },
|
|
||||||
};
|
|
||||||
|
|
||||||
return getBackendSrv()
|
return getBackendSrv()
|
||||||
.fetch<BackendDataSourceResponse>({
|
.fetch<BackendDataSourceResponse>({
|
||||||
|
@ -280,6 +280,11 @@ export class TimeSrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTime(time: RawTimeRange, updateUrl = true) {
|
setTime(time: RawTimeRange, updateUrl = true) {
|
||||||
|
// If we are in a public dashboard ignore time range changes
|
||||||
|
if (config.isPublicDashboardView) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
extend(this.time, time);
|
extend(this.time, time);
|
||||||
|
|
||||||
// disable refresh if zoom in or zoom out
|
// disable refresh if zoom in or zoom out
|
||||||
|
@ -44,7 +44,6 @@ export interface DashboardMeta {
|
|||||||
publicDashboardAccessToken?: string;
|
publicDashboardAccessToken?: string;
|
||||||
publicDashboardUid?: string;
|
publicDashboardUid?: string;
|
||||||
publicDashboardEnabled?: boolean;
|
publicDashboardEnabled?: boolean;
|
||||||
publicDashboardTimeSelectionEnabled?: boolean;
|
|
||||||
hasPublicDashboard?: boolean;
|
hasPublicDashboard?: boolean;
|
||||||
dashboardNotFound?: boolean;
|
dashboardNotFound?: boolean;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user