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

Fix/new ticket dialog error and policy clone issue #4303

Merged
merged 4 commits into from
Jan 28, 2025
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
2 changes: 0 additions & 2 deletions allowedSnakeCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ const allowedSnakeCase = [
'get_settings',
'get_settings_response',
'get_value',
'goto_details',
'goto_host',
'goto_list',
'grant_full',
'group_column',
'group_id',
Expand Down
3 changes: 2 additions & 1 deletion src/web/components/form/useFormValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ const useFormValidation = (
};

// Some common validation rules
export const shouldBeNonEmpty = (string = '') => string.trim().length > 0;
export const shouldBeNonEmpty = (string = '') =>
String(string).trim().length > 0;
export const shouldBeValidPassword = (password = '') => password.length > 5;
export const shouldBeValidName = (string = '') =>
string.match(/^[.#\-_ ,/a-z0-9äüöÄÜÖß]+$/i) !== null; // this is analogue to the
Expand Down
4 changes: 2 additions & 2 deletions src/web/entity/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import PropTypes from 'web/utils/proptypes';
import {generateFilename} from 'web/utils/render';
import withGmp from 'web/utils/withGmp';

export const goto_details =
export const goToDetails =
(type, props) =>
({data}) => {
const {navigate} = props;
return navigate('/' + type + '/' + data.id);
};

export const goto_list = (type, props) => () => {
export const goToList = (type, props) => () => {
const {navigate} = props;
return navigate('/' + type);
};
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/alerts/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TabList from 'web/components/tab/tablist';
import TabPanel from 'web/components/tab/tabpanel';
import TabPanels from 'web/components/tab/tabpanels';
import Tabs from 'web/components/tab/tabs';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -102,10 +102,10 @@ const Page = ({
}) => (
<AlertComponent
onCloneError={onError}
onCloned={goto_details('alert', props)}
onCreated={goto_details('alert', props)}
onCloned={goToDetails('alert', props)}
onCreated={goToDetails('alert', props)}
onDeleteError={onError}
onDeleted={goto_list('alerts', props)}
onDeleted={goToList('alerts', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
6 changes: 3 additions & 3 deletions src/web/pages/audits/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import EditIcon from 'web/entity/icon/editicon';
import TrashIcon from 'web/entity/icon/trashicon';
Expand Down Expand Up @@ -271,10 +271,10 @@ const Page = ({
}) => (
<AuditComponent
onCloneError={onError}
onCloned={goto_details('audit', props)}
onCloned={goToDetails('audit', props)}
onContainerSaved={onChanged}
onDeleteError={onError}
onDeleted={goto_list('audits', props)}
onDeleted={goToList('audits', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/credentials/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import DetailsBlock from 'web/entity/block';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -166,10 +166,10 @@ const Page = ({
return (
<CredentialComponent
onCloneError={onError}
onCloned={goto_details('credential', props)}
onCreated={goto_details('credential', props)}
onCloned={goToDetails('credential', props)}
onCreated={goToDetails('credential', props)}
onDeleteError={onError}
onDeleted={goto_list('credentials', props)}
onDeleted={goToList('credentials', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInstallerDownloadError={onError}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/filters/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TabList from 'web/components/tab/tablist';
import TabPanel from 'web/components/tab/tabpanel';
import TabPanels from 'web/components/tab/tabpanels';
import Tabs from 'web/components/tab/tabs';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -93,10 +93,10 @@ const Page = ({
return (
<FilterComponent
onCloneError={onError}
onCloned={goto_details('filter', props)}
onCreated={goto_details('filter', props)}
onCloned={goToDetails('filter', props)}
onCreated={goToDetails('filter', props)}
onDeleteError={onError}
onDeleted={goto_list('filters', props)}
onDeleted={goToList('filters', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/groups/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TabList from 'web/components/tab/tablist';
import TabPanel from 'web/components/tab/tabpanel';
import TabPanels from 'web/components/tab/tabpanels';
import Tabs from 'web/components/tab/tabs';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -96,10 +96,10 @@ const Page = ({
return (
<GroupComponent
onCloneError={onError}
onCloned={goto_details('group', props)}
onCreated={goto_details('group', props)}
onCloned={goToDetails('group', props)}
onCreated={goToDetails('group', props)}
onDeleteError={onError}
onDeleted={goto_list('groups', props)}
onDeleted={goToList('groups', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/hosts/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CreateIcon from 'web/entity/icon/createicon';
import DeleteIcon from 'web/entity/icon/deleteicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -244,19 +244,19 @@ const Page = ({
onInteraction,
...props
}) => {
const goto_host = goto_details('host', props);
const goto_host = goToDetails('host', props);
return (
<HostComponent
onCreated={goto_host}
onDeleted={goto_list('hosts', props)}
onDeleted={goToList('hosts', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onIdentifierDeleteError={onError}
onIdentifierDeleted={onChanged}
onInteraction={onInteraction}
onSaved={onChanged}
onTargetCreateError={onError}
onTargetCreated={goto_details('target', props)}
onTargetCreated={goToDetails('target', props)}
>
{({create, delete: delete_func, deleteidentifier, download, edit}) => (
<EntityPage
Expand Down
4 changes: 2 additions & 2 deletions src/web/pages/hosts/listpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import IconDivider from 'web/components/layout/icondivider';
import PageTitle from 'web/components/layout/pagetitle';
import EntitiesPage from 'web/entities/page';
import withEntitiesContainer from 'web/entities/withEntitiesContainer';
import {goto_details} from 'web/entity/component';
import {goToDetails} from 'web/entity/component';
import {
loadEntities,
selector as entitiesSelector,
Expand Down Expand Up @@ -66,7 +66,7 @@ const Page = ({
onInteraction={onInteraction}
onSaved={onChanged}
onTargetCreateError={onError}
onTargetCreated={goto_details('target', props)}
onTargetCreated={goToDetails('target', props)}
>
{({
create,
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/notes/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -161,10 +161,10 @@ const Page = ({
}) => (
<NoteComponent
onCloneError={onError}
onCloned={goto_details('note', props)}
onCreated={goto_details('note', props)}
onCloned={goToDetails('note', props)}
onCreated={goToDetails('note', props)}
onDeleteError={onError}
onDeleted={goto_list('notes', props)}
onDeleted={goToList('notes', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
4 changes: 2 additions & 2 deletions src/web/pages/operatingsystems/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import {goto_list} from 'web/entity/component';
import {goToList} from 'web/entity/component';
import EntityPage, {Col} from 'web/entity/page';
import EntityPermissions from 'web/entity/permissions';
import EntitiesTab from 'web/entity/tab';
Expand Down Expand Up @@ -190,7 +190,7 @@ const Page = ({
}) => (
<OsComponent
onDeleteError={onError}
onDeleted={goto_list('operatingsystems', props)}
onDeleted={goToList('operatingsystems', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/overrides/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import TableBody from 'web/components/table/body';
import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -164,10 +164,10 @@ const Page = ({
}) => (
<OverrideComponent
onCloneError={onError}
onCloned={goto_details('override', props)}
onCreated={goto_details('override', props)}
onCloned={goToDetails('override', props)}
onCreated={goToDetails('override', props)}
onDeleteError={onError}
onDeleted={goto_list('overrides', props)}
onDeleted={goToList('overrides', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/permissions/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TabList from 'web/components/tab/tablist';
import TabPanel from 'web/components/tab/tabpanel';
import TabPanels from 'web/components/tab/tabpanels';
import Tabs from 'web/components/tab/tabs';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -85,10 +85,10 @@ const Page = ({
return (
<PermissionComponent
onCloneError={onError}
onCloned={goto_details('permission', props)}
onCreated={goto_details('permission', props)}
onCloned={goToDetails('permission', props)}
onCreated={goToDetails('permission', props)}
onDeleteError={onError}
onDeleted={goto_list('permissions', props)}
onDeleted={goToList('permissions', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
6 changes: 3 additions & 3 deletions src/web/pages/policies/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TabList from 'web/components/tab/tablist';
import TabPanel from 'web/components/tab/tabpanel';
import TabPanels from 'web/components/tab/tabpanels';
import Tabs from 'web/components/tab/tabs';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import EditIcon from 'web/entity/icon/editicon';
import TrashIcon from 'web/entity/icon/trashicon';
Expand Down Expand Up @@ -122,9 +122,9 @@ const Page = ({
return (
<PolicyComponent
onCloneError={onError}
onCloned={goto_details('policies', props)}
onCloned={goToDetails('policy', props)}
onDeleteError={onError}
onDeleted={goto_list('policies', props)}
onDeleted={goToList('policies', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/portlists/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TabList from 'web/components/tab/tablist';
import TabPanel from 'web/components/tab/tabpanel';
import TabPanels from 'web/components/tab/tabpanels';
import Tabs from 'web/components/tab/tabs';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -128,10 +128,10 @@ const Page = ({
}) => (
<PortListComponent
onCloneError={onError}
onCloned={goto_details('portlist', props)}
onCreated={goto_details('portlist', props)}
onCloned={goToDetails('portlist', props)}
onCreated={goToDetails('portlist', props)}
onDeleteError={onError}
onDeleted={goto_list('portlists', props)}
onDeleted={goToList('portlists', props)}
onDownloadError={onError}
onDownloaded={onDownloaded}
onInteraction={onInteraction}
Expand Down
8 changes: 4 additions & 4 deletions src/web/pages/reportconfigs/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import TableHead from 'web/components/table/head';
import TableHeader from 'web/components/table/header';
import TableRow from 'web/components/table/row';
import Table from 'web/components/table/stripedtable';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CloneIcon from 'web/entity/icon/cloneicon';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
Expand Down Expand Up @@ -167,11 +167,11 @@ const Page = ({
}) => (
<ReportConfigComponent
onCloneError={onError}
onCloned={goto_details('reportconfig', props)}
onCloned={goToDetails('reportconfig', props)}
onCreateError={onError}
onCreated={goto_details('reportconfig', props)}
onCreated={goToDetails('reportconfig', props)}
onDeleteError={onError}
onDeleted={goto_list('reportconfigs', props)}
onDeleted={goToList('reportconfigs', props)}
onInteraction={onInteraction}
onSaveError={onError}
onSaved={onChanged}
Expand Down
6 changes: 3 additions & 3 deletions src/web/pages/reportformats/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import TableHead from 'web/components/table/head';
import TableHeader from 'web/components/table/header';
import TableRow from 'web/components/table/row';
import Table from 'web/components/table/stripedtable';
import {goto_details, goto_list} from 'web/entity/component';
import {goToDetails, goToList} from 'web/entity/component';
import CreateIcon from 'web/entity/icon/createicon';
import EditIcon from 'web/entity/icon/editicon';
import TrashIcon from 'web/entity/icon/trashicon';
Expand Down Expand Up @@ -204,8 +204,8 @@ const Page = ({
}) => (
<ReportFormatComponent
onDeleteError={onError}
onDeleted={goto_list('reportformats', props)}
onImported={goto_details('reportformat', props)}
onDeleted={goToList('reportformats', props)}
onImported={goToDetails('reportformat', props)}
onInteraction={onInteraction}
onSaved={onChanged}
>
Expand Down
4 changes: 2 additions & 2 deletions src/web/pages/results/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import TableData from 'web/components/table/data';
import InfoTable from 'web/components/table/infotable';
import TableRow from 'web/components/table/row';
import DetailsBlock from 'web/entity/block';
import {goto_details} from 'web/entity/component';
import {goToDetails} from 'web/entity/component';
import Note from 'web/entity/note';
import Override from 'web/entity/override';
import EntityPage, {Col} from 'web/entity/page';
Expand Down Expand Up @@ -414,7 +414,7 @@ class Page extends React.Component {
>
{({create: createoverride}) => (
<TicketComponent
onCreated={goto_details('ticket', this.props)}
onCreated={goToDetails('ticket', this.props)}
onInteraction={onInteraction}
>
{({createFromResult: createticket}) => (
Expand Down
Loading
Loading