Commit feeb3ea5 by Johannes Schill

feat: Generate page titles from navModel

parent 25304629
...@@ -41,3 +41,7 @@ export function getNavModel(navIndex: NavIndex, id: string, fallback?: NavModel) ...@@ -41,3 +41,7 @@ export function getNavModel(navIndex: NavIndex, id: string, fallback?: NavModel)
return getNotFoundModel(); return getNotFoundModel();
} }
export const getTitleFromNavModel = (navModel: NavModel) => {
return `${navModel.main.text}${navModel.node.text ? ': ' + navModel.node.text : '' }`;
};
...@@ -8,7 +8,8 @@ import DataSourcesList from './DataSourcesList'; ...@@ -8,7 +8,8 @@ import DataSourcesList from './DataSourcesList';
import { DataSource, NavModel, StoreState } from 'app/types'; import { DataSource, NavModel, StoreState } from 'app/types';
import { LayoutMode } from 'app/core/components/LayoutSelector/LayoutSelector'; import { LayoutMode } from 'app/core/components/LayoutSelector/LayoutSelector';
import { loadDataSources, setDataSourcesLayoutMode, setDataSourcesSearchQuery } from './state/actions'; import { loadDataSources, setDataSourcesLayoutMode, setDataSourcesSearchQuery } from './state/actions';
import { getNavModel } from 'app/core/selectors/navModel'; import { getNavModel, getTitleFromNavModel } from 'app/core/selectors/navModel';
import { import {
getDataSources, getDataSources,
getDataSourcesCount, getDataSourcesCount,
...@@ -66,7 +67,7 @@ export class DataSourcesListPage extends PureComponent<Props> { ...@@ -66,7 +67,7 @@ export class DataSourcesListPage extends PureComponent<Props> {
}; };
return ( return (
<Page title="Configuration: Data Sources"> <Page title={getTitleFromNavModel(navModel)}>
<Page.Header model={navModel} /> <Page.Header model={navModel} />
<Page.Contents isLoading={!hasFetched}> <Page.Contents isLoading={!hasFetched}>
<> <>
......
...@@ -6,9 +6,9 @@ import OrgActionBar from 'app/core/components/OrgActionBar/OrgActionBar'; ...@@ -6,9 +6,9 @@ import OrgActionBar from 'app/core/components/OrgActionBar/OrgActionBar';
import PluginList from './PluginList'; import PluginList from './PluginList';
import { NavModel, Plugin } from 'app/types'; import { NavModel, Plugin } from 'app/types';
import { loadPlugins, setPluginsLayoutMode, setPluginsSearchQuery } from './state/actions'; import { loadPlugins, setPluginsLayoutMode, setPluginsSearchQuery } from './state/actions';
import { getNavModel } from '../../core/selectors/navModel'; import { getNavModel, getTitleFromNavModel } from 'app/core/selectors/navModel';
import { getLayoutMode, getPlugins, getPluginsSearchQuery } from './state/selectors'; import { getLayoutMode, getPlugins, getPluginsSearchQuery } from './state/selectors';
import { LayoutMode } from '../../core/components/LayoutSelector/LayoutSelector'; import { LayoutMode } from 'app/core/components/LayoutSelector/LayoutSelector';
export interface Props { export interface Props {
navModel: NavModel; navModel: NavModel;
...@@ -47,7 +47,7 @@ export class PluginListPage extends PureComponent<Props> { ...@@ -47,7 +47,7 @@ export class PluginListPage extends PureComponent<Props> {
}; };
return ( return (
<Page title="Configuration: Plugins"> <Page title={getTitleFromNavModel(navModel)}>
<Page.Header model={navModel} /> <Page.Header model={navModel} />
<Page.Contents isLoading={!hasFetched}> <Page.Contents isLoading={!hasFetched}>
<> <>
......
...@@ -4,10 +4,10 @@ import { hot } from 'react-hot-loader'; ...@@ -4,10 +4,10 @@ import { hot } from 'react-hot-loader';
import Page from 'app/core/components/Page/Page'; import Page from 'app/core/components/Page/Page';
import { DeleteButton } from '@grafana/ui'; import { DeleteButton } from '@grafana/ui';
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
import { NavModel, Team } from '../../types'; import { NavModel, Team } from 'app/types';
import { loadTeams, deleteTeam, setSearchQuery } from './state/actions'; import { loadTeams, deleteTeam, setSearchQuery } from './state/actions';
import { getSearchQuery, getTeams, getTeamsCount } from './state/selectors'; import { getSearchQuery, getTeams, getTeamsCount } from './state/selectors';
import { getNavModel } from 'app/core/selectors/navModel'; import { getNavModel, getTitleFromNavModel } from 'app/core/selectors/navModel';
export interface Props { export interface Props {
navModel: NavModel; navModel: NavModel;
...@@ -140,7 +140,7 @@ export class TeamList extends PureComponent<Props, any> { ...@@ -140,7 +140,7 @@ export class TeamList extends PureComponent<Props, any> {
const { hasFetched, navModel } = this.props; const { hasFetched, navModel } = this.props;
return ( return (
<Page title="Configuration: Teams"> <Page title={getTitleFromNavModel(navModel)}>
<Page.Header model={navModel} /> <Page.Header model={navModel} />
<Page.Contents isLoading={!hasFetched}> <Page.Contents isLoading={!hasFetched}>
{hasFetched && this.renderList()} {hasFetched && this.renderList()}
......
...@@ -9,7 +9,7 @@ import InviteesTable from './InviteesTable'; ...@@ -9,7 +9,7 @@ import InviteesTable from './InviteesTable';
import { Invitee, NavModel, OrgUser } from 'app/types'; import { Invitee, NavModel, OrgUser } from 'app/types';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import { loadUsers, loadInvitees, setUsersSearchQuery, updateUser, removeUser } from './state/actions'; import { loadUsers, loadInvitees, setUsersSearchQuery, updateUser, removeUser } from './state/actions';
import { getNavModel } from '../../core/selectors/navModel'; import { getNavModel, getTitleFromNavModel } from 'app/core/selectors/navModel';
import { getInvitees, getUsers, getUsersSearchQuery } from './state/selectors'; import { getInvitees, getUsers, getUsersSearchQuery } from './state/selectors';
export interface Props { export interface Props {
...@@ -104,7 +104,7 @@ export class UsersListPage extends PureComponent<Props, State> { ...@@ -104,7 +104,7 @@ export class UsersListPage extends PureComponent<Props, State> {
const externalUserMngInfoHtml = this.externalUserMngInfoHtml; const externalUserMngInfoHtml = this.externalUserMngInfoHtml;
return ( return (
<Page title="Configuration: Users"> <Page title={getTitleFromNavModel(navModel)}>
<Page.Header model={navModel} /> <Page.Header model={navModel} />
<Page.Contents isLoading={!hasFetched}> <Page.Contents isLoading={!hasFetched}>
<> <>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment