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

Improve tags #771

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 15 additions & 8 deletions gsa/src/web/pages/tags/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ const Divider = glamorous.div({
margin: '0 5px',
});

const ScrollableContent = glamorous.div({
maxHeight: '200px',
overflow: 'auto',
});

class TagDialog extends React.Component {

constructor(...args) {
Expand Down Expand Up @@ -282,14 +287,16 @@ class TagDialog extends React.Component {
</FormGroup>

<FormGroup title={_('Resources')}>
<MultiSelect
name="resource_ids"
items={render_select_items(this.state.resourceOptions)}
value={this.state.resourceIdsSelected}
disabled={!typeIsChosen || fixed ||
resourceTypesOptions.length === 0}
onChange={ids => this.handleIdChange(ids, onValueChange)}
/>
<ScrollableContent>
<MultiSelect
name="resource_ids"
items={render_select_items(this.state.resourceOptions)}
value={this.state.resourceIdsSelected}
disabled={!typeIsChosen || fixed ||
resourceTypesOptions.length === 0}
onChange={ids => this.handleIdChange(ids, onValueChange)}
/>
</ScrollableContent>
<Divider>
{_('or add by ID:')}
</Divider>
Expand Down
10 changes: 9 additions & 1 deletion gsa/src/web/pages/tags/listpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ import IconDivider from '../../components/layout/icondivider.js';
import {createFilterDialog} from '../../components/powerfilter/dialog.js';

import TagComponent from './component.js';
import TagsTable, {SORT_FIELDS} from './table.js';
import TagsTable from './table.js';

export const SORT_FIELDS = [
['name', _('Name'), '30%'],
['value', _('Value'), '30%'],
['active', _('Active'), '8%'],
['resource_type', _('Resource Type'), '8%'],
['modified', _('Modified'), '8%'],
];

const ToolBarIcons = withCapabilties(({
capabilities,
Expand Down
95 changes: 85 additions & 10 deletions gsa/src/web/pages/tags/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,103 @@
* 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 _ from 'gmp/locale.js';

import PropTypes from '../../utils/proptypes.js';

import {createEntitiesFooter} from '../../entities/footer.js';
import {createEntitiesHeader} from '../../entities/header.js';
import {withEntitiesHeader} from '../../entities/header.js';
import {createEntitiesTable} from '../../entities/table.js';
import withRowDetails from '../../entities/withRowDetails.js';

import TableHead from '../../components/table/head.js';
import TableHeader from '../../components/table/header.js';
import TableRow from '../../components/table/row.js';

import TagDetails from './details.js';
import Row from './row.js';

export const SORT_FIELDS = [
['name', _('Name'), '30%'],
['value', _('Value'), '30%'],
['active', _('Active'), '8%'],
['resource_type', _('Resource Type'), '8%'],
['resource_count', _('Number of Resources'), '8%'],
['modified', _('Modified'), '8%'],
];
const Header = ({
actionsColumn = true,
links = true,
sort = true,
currentSortBy,
currentSortDir,
onSortChange,
}) => {
return (
<TableHeader>
<TableRow>
<TableHead
width="30%"
currentSortDir={currentSortDir}
currentSortBy={currentSortBy}
sortBy={sort ? 'name' : false}
onSortChange={onSortChange}>
{_('Name')}
</TableHead>
<TableHead
width="30%"
currentSortDir={currentSortDir}
currentSortBy={currentSortBy}
sortBy={sort ? 'value' : false}
onSortChange={onSortChange}>
{_('Value')}
</TableHead>
<TableHead
width="8%"
currentSortDir={currentSortDir}
currentSortBy={currentSortBy}
sortBy={sort ? 'active' : false}
onSortChange={onSortChange}>
{_('Active')}
</TableHead>
<TableHead
width="8%"
currentSortDir={currentSortDir}
currentSortBy={currentSortBy}
sortBy={sort ? 'resource_type' : false}
onSortChange={onSortChange}>
{_('Resource Type')}
</TableHead>
<TableHead
width="8%"
currentSortDir={currentSortDir}
currentSortBy={currentSortBy}
sortBy={false}
onSortChange={onSortChange}>
{_('Number of Resources')}
</TableHead>
<TableHead
width="8%"
currentSortDir={currentSortDir}
currentSortBy={currentSortBy}
sortBy={sort ? 'modified' : false}
onSortChange={onSortChange}>
{_('Modified')}
</TableHead>
{actionsColumn}
</TableRow>
</TableHeader>
);
};

Header.propTypes = {
actionsColumn: PropTypes.element,
currentSortBy: PropTypes.string,
currentSortDir: PropTypes.string,
links: PropTypes.bool,
sort: PropTypes.bool,
onSortChange: PropTypes.func,
};

const TagsHeader = withEntitiesHeader()(Header);

const TagsTable = createEntitiesTable({
emptyTitle: _('No tags available'),
header: createEntitiesHeader(SORT_FIELDS),
header: TagsHeader,
row: Row,
rowDetails: withRowDetails('tag')(TagDetails),
footer: createEntitiesFooter({
Expand Down