Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom page title to all pages #1623

Merged
merged 44 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
db13aa9
Added PageTitle component
saberlynx Sep 6, 2019
d277882
Added document title to dashboards, task: listpage and detailspage
saberlynx Sep 9, 2019
6f47d61
Amended pagetitle to return cleanup function
saberlynx Sep 9, 2019
3fe0e1a
Added document title to reports: listpage and detailspage
saberlynx Sep 9, 2019
ed30949
Added document title to results: listpage and detailspage
saberlynx Sep 9, 2019
69cba08
Added document title to vulnerabilities listpage
saberlynx Sep 9, 2019
d14622a
Added document title to notes: listpage and detailspage
saberlynx Sep 9, 2019
cd27b71
Added document title to override: detailspage and listpage
saberlynx Sep 9, 2019
fe632e5
Added document title to host: details and listpage
saberlynx Sep 9, 2019
3279259
Added document title to tickets: listpage and detailspage
saberlynx Sep 9, 2019
43795e4
Added document title to nvt: listpage and detailspage
saberlynx Sep 9, 2019
36c5464
Added document title to cve: listpage and detailspage
saberlynx Sep 9, 2019
96ed524
Added document title to cpe: listpage and detailspage
saberlynx Sep 9, 2019
384804e
Added document title to ovaldefs: listpage and detailspage
saberlynx Sep 9, 2019
88bbd3f
Added document title to dfncerts: listpage and detailspage
saberlynx Sep 9, 2019
4eff504
Added document title to targets: listpage and detailspage
saberlynx Sep 9, 2019
7d10d5f
Added document title to portlists: listpage and detailspage
saberlynx Sep 9, 2019
6f14f2a
Added document title to credentials: listpage and detailspage
saberlynx Sep 9, 2019
0a5cc37
Added document title to scanconfigs: listpage and detailspage
saberlynx Sep 9, 2019
bdd6f3d
Added document title to alerts: listpage and detailspage
saberlynx Sep 9, 2019
b516360
Added document title to schedules: listpage and detailspage
saberlynx Sep 10, 2019
47bd4c9
Added document title to report formats: listpage and detailspage
saberlynx Sep 10, 2019
1adb864
Added document title to agents listpage and detailspage
saberlynx Sep 10, 2019
2347bc6
Added document title to scanners listpage and detailspage
saberlynx Sep 10, 2019
14254e2
Added document title to filters listpage and detailspage
saberlynx Sep 10, 2019
aa6c735
Added document title to tags listpage and detailspage
saberlynx Sep 10, 2019
132c90b
Added document title to users listpage and detailspage
saberlynx Sep 10, 2019
3c3bc12
Added document title to groups listpage and detailspage
saberlynx Sep 10, 2019
655f89c
Added document title to roles listpage and detailspage
saberlynx Sep 10, 2019
79d172d
Added document title to permissions listpage and detailspage
saberlynx Sep 10, 2019
f3aa7f4
Added document title to performance, trashcan, feedstatus, ldap, radi…
saberlynx Sep 10, 2019
8df3644
Added document title to audits listpage and detailspage
saberlynx Sep 10, 2019
e63e043
Added document title to policies listpage and detailspage
saberlynx Sep 10, 2019
6b725df
Added tests to PageTitle component
saberlynx Sep 11, 2019
f871055
Update CHANGELOG.md
saberlynx Sep 11, 2019
26f280e
Added a rerender test to pagetitle
saberlynx Sep 11, 2019
0007fbb
Update gsa/src/web/pages/agents/detailspage.js
saberlynx Sep 11, 2019
fdd546d
Made titles for alerts and audits detailspage translatable. Also adde…
saberlynx Sep 11, 2019
88382d7
Made the title translatable for the following: CPE, credential, CVE, …
saberlynx Sep 11, 2019
e95d6da
Added document title to operating systems listpage and detailspage
saberlynx Sep 11, 2019
cc4b997
Added document title to TLS Certificates listpage and detailspage
saberlynx Sep 11, 2019
051927a
Made the title translatable for the following: OVAL Defs, permissions…
saberlynx Sep 11, 2019
3fed3e6
Added title to usersettings
saberlynx Sep 11, 2019
2f6c220
Merge branch 'master' into page-title
bjoernricks Sep 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Added
- Added custom page title to all pages [#1623](https://github.com/greenbone/gsa/pull/1623/files)
- Allow to disable reload timers [#1619](https://github.com/greenbone/gsa/pull/1619)
- Added missing withRouter to withEntitiesContainer [#1614](https://github.com/greenbone/gsa/pull/1614)
- Added parseTrend() function to ScanConfig model [#1583](https://github.com/greenbone/gsa/pull/1583)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PageTitle tests should render 1`] = `null`;
59 changes: 59 additions & 0 deletions gsa/src/web/components/layout/__tests__/pagetitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Copyright (C) 2017-2019 Greenbone Networks GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import React from 'react';

import PageTitle from 'web/components/layout/pagetitle';

import {render} from 'web/utils/testing';

describe('PageTitle tests', () => {
test('should render', () => {
const {element} = render(<PageTitle />);
expect(element).toMatchSnapshot();
});

test('Should render default title', () => {
const defaultTitle = 'Greenbone Security Assistant';
render(<PageTitle />);

expect(global.window.document.title).toBe(defaultTitle);
});

test('Should render custom title', () => {
const title = 'foo';
const defaultTitle = 'Greenbone Security Assistant';
render(<PageTitle title={title} />);

expect(global.window.document.title).toBe(defaultTitle + ' - ' + title);
});

test('should update value', () => {
const title1 = 'foo';
const title2 = 'bar';
const defaultTitle = 'Greenbone Security Assistant';
const {rerender} = render(<PageTitle title={title1} />);

expect(global.window.document.title).toBe(defaultTitle + ' - ' + title1);

rerender(<PageTitle title={title2} />);

expect(global.window.document.title).toBe(defaultTitle + ' - ' + title2);
});
});
44 changes: 44 additions & 0 deletions gsa/src/web/components/layout/pagetitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Copyright (C) 2017-2019 Greenbone Networks GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import {useEffect} from 'react';
import {isDefined} from 'gmp/utils/identity';
import PropTypes from 'web/utils/proptypes';

const defaultTitle = 'Greenbone Security Assistant';

const PageTitle = ({title}) => {
useEffect(() => {
if (isDefined(title)) {
document.title = defaultTitle + ' - ' + title;
} else {
document.title = defaultTitle;
}

return () => {
document.title = defaultTitle;
};
}, [title]);
return null;
};

PageTitle.propTypes = {
title: PropTypes.string,
};

export default PageTitle;
88 changes: 46 additions & 42 deletions gsa/src/web/pages/agents/detailspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import VerifyIcon from 'web/components/icon/verifyicon';
import Divider from 'web/components/layout/divider';
import IconDivider from 'web/components/layout/icondivider';
import Layout from 'web/components/layout/layout';
import PageTitle from 'web/components/layout/pagetitle';

import Tab from 'web/components/tab/tab';
import TabLayout from 'web/components/tab/tablayout';
Expand Down Expand Up @@ -173,49 +174,52 @@ const Page = ({
onInteraction={onInteraction}
>
{({activeTab = 0, onActivateTab}) => (
<Layout grow="1" flex="column">
<TabLayout grow="1" align={['start', 'end']}>
<TabList
active={activeTab}
align={['start', 'stretch']}
onActivateTab={onActivateTab}
>
<Tab>{_('Information')}</Tab>
<EntitiesTab entities={entity.userTags}>
{_('User Tags')}
</EntitiesTab>
<EntitiesTab entities={permissions}>
{_('Permissions')}
</EntitiesTab>
</TabList>
</TabLayout>
<React.Fragment>
<PageTitle title={_('Agent: {{name}}', {name: entity.name})} />
<Layout grow="1" flex="column">
<TabLayout grow="1" align={['start', 'end']}>
<TabList
active={activeTab}
align={['start', 'stretch']}
onActivateTab={onActivateTab}
>
<Tab>{_('Information')}</Tab>
<EntitiesTab entities={entity.userTags}>
{_('User Tags')}
</EntitiesTab>
<EntitiesTab entities={permissions}>
{_('Permissions')}
</EntitiesTab>
</TabList>
</TabLayout>

<Tabs active={activeTab}>
<TabPanels>
<TabPanel>
<AgentDetails entity={entity} />
</TabPanel>
<TabPanel>
<EntityTags
entity={entity}
onChanged={onChanged}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
<TabPanel>
<EntityPermissions
entity={entity}
permissions={permissions}
onChanged={onChanged}
onDownloaded={onDownloaded}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
</TabPanels>
</Tabs>
</Layout>
<Tabs active={activeTab}>
<TabPanels>
<TabPanel>
<AgentDetails entity={entity} />
</TabPanel>
<TabPanel>
<EntityTags
entity={entity}
onChanged={onChanged}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
<TabPanel>
<EntityPermissions
entity={entity}
permissions={permissions}
onChanged={onChanged}
onDownloaded={onDownloaded}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
</TabPanels>
</Tabs>
</Layout>
</React.Fragment>
)}
</EntityPage>
)}
Expand Down
47 changes: 26 additions & 21 deletions gsa/src/web/pages/agents/listpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import ManualIcon from 'web/components/icon/manualicon';
import NewIcon from 'web/components/icon/newicon';

import IconDivider from 'web/components/layout/icondivider';
import PageTitle from 'web/components/layout/pagetitle';

import AgentIcon from 'web/components/icon/agenticon';

Expand Down Expand Up @@ -94,27 +95,31 @@ const AgentsPage = ({
save,
verify,
}) => (
<EntitiesPage
{...props}
filterEditDialog={AgentsFilterDialog}
filtersFilter={AGENTS_FILTER_FILTER}
sectionIcon={<AgentIcon size="large" />}
table={AgentsTable}
title={_('Agents')}
toolBarIcons={ToolBarIcons}
onChanged={onChanged}
onDownloaded={onDownloaded}
onError={onError}
onAgentCloneClick={clone}
onAgentCreateClick={create}
onAgentDeleteClick={delete_func}
onAgentDownloadClick={download}
onAgentEditClick={edit}
onAgentInstallerDownloadClick={downloadinstaller}
onAgentSaveClick={save}
onAgentVerifyClick={verify}
onInteraction={onInteraction}
/>
<React.Fragment>
<PageTitle title={_('Agents')} />

<EntitiesPage
{...props}
filterEditDialog={AgentsFilterDialog}
filtersFilter={AGENTS_FILTER_FILTER}
sectionIcon={<AgentIcon size="large" />}
table={AgentsTable}
title={_('Agents')}
toolBarIcons={ToolBarIcons}
onChanged={onChanged}
onDownloaded={onDownloaded}
onError={onError}
onAgentCloneClick={clone}
onAgentCreateClick={create}
onAgentDeleteClick={delete_func}
onAgentDownloadClick={download}
onAgentEditClick={edit}
onAgentInstallerDownloadClick={downloadinstaller}
onAgentSaveClick={save}
onAgentVerifyClick={verify}
onInteraction={onInteraction}
/>
</React.Fragment>
)}
</AgentComponent>
);
Expand Down
94 changes: 49 additions & 45 deletions gsa/src/web/pages/alerts/detailspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ListIcon from 'web/components/icon/listicon';
import Divider from 'web/components/layout/divider';
import IconDivider from 'web/components/layout/icondivider';
import Layout from 'web/components/layout/layout';
import PageTitle from 'web/components/layout/pagetitle';

import Tab from 'web/components/tab/tab';
import TabLayout from 'web/components/tab/tablayout';
Expand Down Expand Up @@ -145,51 +146,54 @@ const Page = ({
>
{({activeTab = 0, onActivateTab}) => {
return (
<Layout grow="1" flex="column">
<TabLayout grow="1" align={['start', 'end']}>
<TabList
active={activeTab}
align={['start', 'stretch']}
onActivateTab={onActivateTab}
>
<Tab>{_('Information')}</Tab>
<EntitiesTab entities={entity.userTags}>
{_('User Tags')}
</EntitiesTab>
<EntitiesTab entities={permissions}>
{_('Permissions')}
</EntitiesTab>
</TabList>
</TabLayout>
<Tabs active={activeTab}>
<TabPanels>
<TabPanel>
<AlertDetails
entity={entity}
reportFormats={reportFormats}
/>
</TabPanel>
<TabPanel>
<EntityTags
entity={entity}
onChanged={onChanged}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
<TabPanel>
<EntityPermissions
entity={entity}
permissions={permissions}
onChanged={onChanged}
onDownloaded={onDownloaded}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
</TabPanels>
</Tabs>
</Layout>
<React.Fragment>
<PageTitle title={_('Alert: {{name}}', {name: entity.name})} />
<Layout grow="1" flex="column">
<TabLayout grow="1" align={['start', 'end']}>
<TabList
active={activeTab}
align={['start', 'stretch']}
onActivateTab={onActivateTab}
>
<Tab>{_('Information')}</Tab>
<EntitiesTab entities={entity.userTags}>
{_('User Tags')}
</EntitiesTab>
<EntitiesTab entities={permissions}>
{_('Permissions')}
</EntitiesTab>
</TabList>
</TabLayout>
<Tabs active={activeTab}>
<TabPanels>
<TabPanel>
<AlertDetails
entity={entity}
reportFormats={reportFormats}
/>
</TabPanel>
<TabPanel>
<EntityTags
entity={entity}
onChanged={onChanged}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
<TabPanel>
<EntityPermissions
entity={entity}
permissions={permissions}
onChanged={onChanged}
onDownloaded={onDownloaded}
onError={onError}
onInteraction={onInteraction}
/>
</TabPanel>
</TabPanels>
</Tabs>
</Layout>
</React.Fragment>
);
}}
</EntityPage>
Expand Down
Loading