Skip to content

Commit

Permalink
Kiosk mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dhodgsonintergral committed Feb 7, 2024
1 parent d1fdd81 commit dfbd68d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 176 deletions.
125 changes: 5 additions & 120 deletions pkg/services/navtree/navtreeimpl/navtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/infra/kvstore"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models/roletype"
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/apikey"
"github.com/grafana/grafana/pkg/services/auth/identity"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/licensing"
"github.com/grafana/grafana/pkg/services/navtree"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
pref "github.com/grafana/grafana/pkg/services/preference"
Expand Down Expand Up @@ -128,24 +125,24 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Prefere
}

if setting.ProfileEnabled && c.IsSignedIn {
treeRoot.AddSection(s.getProfileNode(c))
//treeRoot.AddSection(s.getProfileNode(c))
}

_, uaIsDisabledForOrg := s.cfg.UnifiedAlerting.DisabledOrgs[c.SignedInUser.GetOrgID()]
uaVisibleForOrg := s.cfg.UnifiedAlerting.IsEnabled() && !uaIsDisabledForOrg

if setting.AlertingEnabled != nil && *setting.AlertingEnabled {
if legacyAlertSection := s.buildLegacyAlertNavLinks(c); legacyAlertSection != nil {
treeRoot.AddSection(legacyAlertSection)
//treeRoot.AddSection(legacyAlertSection)
}
} else if uaVisibleForOrg {
if alertingSection := s.buildAlertNavLinks(c); alertingSection != nil {
treeRoot.AddSection(alertingSection)
//treeRoot.AddSection(alertingSection)
}
}

if connectionsSection := s.buildDataConnectionsNavLink(c); connectionsSection != nil {
treeRoot.AddSection(connectionsSection)
//treeRoot.AddSection(connectionsSection)
}

orgAdminNode, err := s.getAdminNode(c)
Expand Down Expand Up @@ -401,125 +398,13 @@ func (s *ServiceImpl) buildDashboardNavLinks(c *contextmodel.ReqContext) []*navt
}

func (s *ServiceImpl) buildLegacyAlertNavLinks(c *contextmodel.ReqContext) *navtree.NavLink {
var alertChildNavs []*navtree.NavLink
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
Text: "Alert rules", Id: "alert-list", Url: s.cfg.AppSubURL + "/alerting/list", Icon: "list-ul",
})

if c.SignedInUser.HasRole(roletype.RoleEditor) {
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
Text: "Notification channels", Id: "channels", Url: s.cfg.AppSubURL + "/alerting/notifications",
Icon: "comment-alt-share",
})
}

var alertNav = navtree.NavLink{
Text: "Alerting",
SubTitle: "Learn about problems in your systems moments after they occur",
Id: "alerting-legacy",
Icon: "bell",
Children: alertChildNavs,
SortWeight: navtree.WeightAlerting,
Url: s.cfg.AppSubURL + "/alerting",
}

return &alertNav
return nil
}

func (s *ServiceImpl) buildAlertNavLinks(c *contextmodel.ReqContext) *navtree.NavLink {
hasAccess := ac.HasAccess(s.accessControl, c)
var alertChildNavs []*navtree.NavLink

if hasAccess(ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleRead), ac.EvalPermission(ac.ActionAlertingRuleExternalRead))) {
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
Text: "Alert rules", SubTitle: "Rules that determine whether an alert will fire", Id: "alert-list", Url: s.cfg.AppSubURL + "/alerting/list", Icon: "list-ul",
})
}

if hasAccess(ac.EvalAny(ac.EvalPermission(ac.ActionAlertingNotificationsRead), ac.EvalPermission(ac.ActionAlertingNotificationsExternalRead))) {
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
Text: "Contact points", SubTitle: "Choose how to notify your contact points when an alert instance fires", Id: "receivers", Url: s.cfg.AppSubURL + "/alerting/notifications",
Icon: "comment-alt-share",
})
alertChildNavs = append(alertChildNavs, &navtree.NavLink{Text: "Notification policies", SubTitle: "Determine how alerts are routed to contact points", Id: "am-routes", Url: s.cfg.AppSubURL + "/alerting/routes", Icon: "sitemap"})
}

if hasAccess(ac.EvalAny(ac.EvalPermission(ac.ActionAlertingInstanceRead), ac.EvalPermission(ac.ActionAlertingInstancesExternalRead))) {
alertChildNavs = append(alertChildNavs, &navtree.NavLink{Text: "Silences", SubTitle: "Stop notifications from one or more alerting rules", Id: "silences", Url: s.cfg.AppSubURL + "/alerting/silences", Icon: "bell-slash"})
alertChildNavs = append(alertChildNavs, &navtree.NavLink{Text: "Alert groups", SubTitle: "See grouped alerts from an Alertmanager instance", Id: "groups", Url: s.cfg.AppSubURL + "/alerting/groups", Icon: "layer-group"})
}

if c.SignedInUser.GetOrgRole() == org.RoleAdmin {
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
Text: "Admin", Id: "alerting-admin", Url: s.cfg.AppSubURL + "/alerting/admin",
Icon: "cog",
})
}

if hasAccess(ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleCreate), ac.EvalPermission(ac.ActionAlertingRuleExternalWrite))) {
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
Text: "Create alert rule", SubTitle: "Create an alert rule", Id: "alert",
Icon: "plus", Url: s.cfg.AppSubURL + "/alerting/new", HideFromTabs: true, IsCreateAction: true,
})
}

if len(alertChildNavs) > 0 {
var alertNav = navtree.NavLink{
Text: "Alerting",
SubTitle: "Learn about problems in your systems moments after they occur",
Id: navtree.NavIDAlerting,
Icon: "bell",
Children: alertChildNavs,
SortWeight: navtree.WeightAlerting,
Url: s.cfg.AppSubURL + "/alerting",
}

return &alertNav
}

return nil
}

func (s *ServiceImpl) buildDataConnectionsNavLink(c *contextmodel.ReqContext) *navtree.NavLink {
hasAccess := ac.HasAccess(s.accessControl, c)

var children []*navtree.NavLink
var navLink *navtree.NavLink

baseUrl := s.cfg.AppSubURL + "/connections"

if hasAccess(datasources.ConfigurationPageAccess) {
// Add new connection
children = append(children, &navtree.NavLink{
Id: "connections-add-new-connection",
Text: "Add new connection",
SubTitle: "Browse and create new connections",
Url: baseUrl + "/add-new-connection",
Children: []*navtree.NavLink{},
})

// Data sources
children = append(children, &navtree.NavLink{
Id: "connections-datasources",
Text: "Data sources",
SubTitle: "View and manage your connected data source connections",
Url: baseUrl + "/datasources",
Children: []*navtree.NavLink{},
})
}

if len(children) > 0 {
// Connections (main)
navLink = &navtree.NavLink{
Text: "Connections",
Icon: "adjust-circle",
Id: "connections",
Url: baseUrl,
Children: children,
SortWeight: navtree.WeightDataConnections,
}

return navLink
}
return nil
}
30 changes: 15 additions & 15 deletions public/app/core/components/AppChrome/NavToolbar/NavToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ export function NavToolbar({

return (
<div data-testid={Components.NavToolbar.container} className={styles.pageToolbar}>
<div className={styles.menuButton}>
<IconButton
id={TOGGLE_BUTTON_ID}
name="bars"
tooltip={
state.megaMenu === 'closed' || (state.megaMenu === 'docked' && isTooSmallForDockedMenu)
? t('navigation.toolbar.open-menu', 'Open menu')
: t('navigation.toolbar.close-menu', 'Close menu')
}
tooltipPlacement="bottom"
size="xl"
onClick={onToggleMegaMenu}
data-testid={Components.NavBar.Toggle.button}
/>
</div>
{/*<div className={styles.menuButton}>*/}
{/* <IconButton*/}
{/* id={TOGGLE_BUTTON_ID}*/}
{/* name="bars"*/}
{/* tooltip={*/}
{/* state.megaMenu === 'closed' || (state.megaMenu === 'docked' && isTooSmallForDockedMenu)*/}
{/* ? t('navigation.toolbar.open-menu', 'Open menu')*/}
{/* : t('navigation.toolbar.close-menu', 'Close menu')*/}
{/* }*/}
{/* tooltipPlacement="bottom"*/}
{/* size="xl"*/}
{/* onClick={onToggleMegaMenu}*/}
{/* data-testid={Components.NavBar.Toggle.button}*/}
{/* />*/}
{/*</div>*/}
<Breadcrumbs breadcrumbs={breadcrumbs} className={styles.breadcrumbsWrapper} />
<div className={styles.actions}>
{actions}
Expand Down
16 changes: 1 addition & 15 deletions public/app/core/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,7 @@ export interface Props {
}

export const Footer = React.memo(({ customLinks, hideEdition }: Props) => {
const links = (customLinks || getFooterLinks()).concat(getVersionLinks(hideEdition));

return (
<footer className="footer">
<div className="text-center">
<ul>
{links.map((link) => (
<li key={link.text}>
<FooterItem item={link} />
</li>
))}
</ul>
</div>
</footer>
);
return <footer className="footer"></footer>;
});

Footer.displayName = 'Footer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ export default (navBarTree: NavModelItem[]): CommandPaletteAction[] => {

const navBarActions = navTreeToActions(navBarTree);

return [...globalActions, ...navBarActions];
return [...navBarActions];
};
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ export default function TracePageActions(props: TracePageActionsProps) {

return (
<div className={styles.TracePageActions}>
<a
href="https://forms.gle/RZDEx8ScyZNguDoC8"
className={styles.feedback}
title="Share your thoughts about tracing in Grafana."
target="_blank"
rel="noreferrer noopener"
>
<Icon name="comment-alt-message" /> Give feedback
</a>

<ActionButton
onClick={copyTraceId}
Expand Down
2 changes: 1 addition & 1 deletion public/app/features/templating/template_srv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class TemplateSrv implements BaseTemplateSrv {
for (const variable of this.getAdHocVariables()) {
const variableUid = variable.datasource?.uid;

if (variableUid === ds.uid) {
if (variableUid === ds.uid || variableUid === ds.name) {
filters = filters.concat(variable.filters);
} else if (variableUid?.indexOf('$') === 0) {
if (this.replace(variableUid) === ds.uid) {
Expand Down
15 changes: 0 additions & 15 deletions public/app/plugins/datasource/grafana/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,11 @@ export class UnthemedQueryEditor extends PureComponent<Props, State> {
state: State = { channels: [], channelFields: {} };

queryTypes: Array<SelectableValue<GrafanaQueryType>> = [
{
label: 'Random Walk',
value: GrafanaQueryType.RandomWalk,
description: 'Random signal within the selected time range',
},
{
label: 'Live Measurements',
value: GrafanaQueryType.LiveMeasurements,
description: 'Stream real-time measurements from Grafana',
},
{
label: 'List public files',
value: GrafanaQueryType.List,
description: 'Show directory listings for public resources',
},
];

constructor(props: Props) {
Expand Down Expand Up @@ -495,11 +485,6 @@ export class UnthemedQueryEditor extends PureComponent<Props, State> {
</InlineField>
</InlineFieldRow>
{queryType === GrafanaQueryType.LiveMeasurements && this.renderMeasurementsQuery()}
{queryType === GrafanaQueryType.List && this.renderListPublicFiles()}
{queryType === GrafanaQueryType.Snapshot && this.renderSnapshotQuery()}
{queryType === GrafanaQueryType.Search && (
<SearchEditor value={query.search ?? {}} onChange={this.onSearchChange} />
)}
</>
);
}
Expand Down

0 comments on commit dfbd68d

Please sign in to comment.