Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
merge dev-20.10.x (#11193)
Browse files Browse the repository at this point in the history
* merge dev-20.10.x

* Attempt to fix the build
  • Loading branch information
Thebarda authored Jun 9, 2022
1 parent d176d19 commit 5dc283b
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 59 deletions.
1 change: 0 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,4 @@ try {
"*COMMIT*: <https://github.com/centreon/centreon/commit/${source.COMMIT}|here> by ${source.COMMITTER}\n" +
"*INFO*: ${e}"
}

}
2 changes: 1 addition & 1 deletion www/api/class/centreon_ceip.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private function getLicenseInformation(): array
}
}
} catch (\Exception $exception) {
$this->logger->error($exception->getMessage, ['context' => $exception]);
$this->logger->error($exception->getMessage(), ['context' => $exception]);
}

return [
Expand Down
7 changes: 2 additions & 5 deletions www/front_src/src/Footer/Links.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';

import { dec, equals, length, not, pipe } from 'ramda';
import { equals, not, dec } from 'ramda';

import { Link, makeStyles, Typography } from '@material-ui/core';

Expand Down Expand Up @@ -43,10 +43,7 @@ const links: Array<FooterLink> = [
},
];

const numbersOfLinks = pipe<Array<FooterLink>, number, number>(
length,
dec,
)(links);
const numbersOfLinks = dec(links.length);

const Links = (): JSX.Element => {
const classes = useStyles();
Expand Down
2 changes: 1 addition & 1 deletion www/front_src/src/Resources/Filter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const Filter = (): JSX.Element => {
/>
<Button
color="primary"
data-testid={labelClear}
data-testid={labelClearAll}
onClick={clearAllFilters}
>
{t(labelClearAll)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import DowntimeDetailsTable from './DetailsTable/Downtime';

interface StateChipProps {
Chip: () => JSX.Element;
DetailsTable: React.SFC<{ endpoint: string }>;
DetailsTable: React.FC<{ endpoint: string }>;
endpoint: string;
label: string;
}
Expand Down
2 changes: 1 addition & 1 deletion www/front_src/src/Resources/Listing/columns/Url/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const UrlColumn = ({
<IconButton
ariaLabel={title}
data-testid={title || endpoint}
title={title || endpoint}
title={(title || endpoint) as string}
onClick={(): null => {
return null;
}}
Expand Down
9 changes: 0 additions & 9 deletions www/front_src/src/Resources/Listing/useListing.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as React from 'react';

import { ifElse, pathEq, always, pathOr } from 'ramda';

import { useRequest } from '@centreon/ui';

import { ResourceListing } from '../models';
import { labelSomethingWentWrong } from '../translatedLabels';

import { defaultSortOrder, defaultSortField } from './columns';
import ApiNotFoundMessage from './ApiNotFoundMessage';
import { listResources } from './api';

type SortOrder = 'asc' | 'desc';
Expand Down Expand Up @@ -41,11 +37,6 @@ const useListing = (): ListingState => {
const [enabledAutorefresh, setEnabledAutorefresh] = React.useState(true);

const { sendRequest, sending } = useRequest<ResourceListing>({
getErrorMessage: ifElse(
pathEq(['response', 'status'], 404),
always(ApiNotFoundMessage),
pathOr(labelSomethingWentWrong, ['response', 'data', 'message']),
),
request: listResources,
});

Expand Down
13 changes: 4 additions & 9 deletions www/front_src/src/components/Hook/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import React, { Suspense } from 'react';

import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { useHistory } from 'react-router';
import isEqual from 'lodash/isEqual';

import { dynamicImport } from '../../helpers/dynamicImport';
import centreonAxios from '../../axios';

interface Props {
history;
hooks;
path;
}

const LoadableHooks = ({
history,
hooks,
path,
...rest
}: Props): JSX.Element => {
const LoadableHooks = ({ hooks, path, ...rest }: Props): JSX.Element => {
const history = useHistory();
const basename = history.createHref({
hash: '',
pathname: '/',
Expand Down Expand Up @@ -58,4 +53,4 @@ const mapStateToProps = ({ externalComponents }): Record<string, unknown> => ({
hooks: externalComponents.hooks,
});

export default connect(mapStateToProps)(withRouter(Hook));
export default connect(mapStateToProps)(Hook);
11 changes: 6 additions & 5 deletions www/front_src/src/components/ReactRouter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Suspense } from 'react';

import { connect } from 'react-redux';
import { Switch, Route, withRouter } from 'react-router-dom';
import { Switch, Route, useHistory } from 'react-router';
import isEqual from 'lodash/isEqual';

import { styled } from '@material-ui/core';
Expand Down Expand Up @@ -59,12 +59,13 @@ const getExternalPageRoutes = ({
interface Props {
allowedPages: Array<string>;
externalPagesFetched: boolean;
history;
pages: Record<string, unknown>;
}

const ReactRouter = React.memo<Props>(
({ allowedPages, history, pages, externalPagesFetched }: Props) => {
({ allowedPages, pages, externalPagesFetched }: Props) => {
const history = useHistory();

if (!externalPagesFetched) {
// eslint-disable-next-line react/jsx-no-undef
return <PageContainer />;
Expand Down Expand Up @@ -104,10 +105,10 @@ const ReactRouter = React.memo<Props>(
isEqual(previousProps.externalPagesFetched, nextProps.externalPagesFetched),
);

const mapStateToProps = (state): Record<string, unknown> => ({
const mapStateToProps = (state): Props => ({
allowedPages: allowedPagesSelector(state),
externalPagesFetched: state.externalComponents.fetched,
pages: state.externalComponents.pages,
});

export default connect(mapStateToProps)(withRouter(ReactRouter));
export default connect(mapStateToProps)(ReactRouter);
53 changes: 27 additions & 26 deletions www/include/configuration/configObject/contact/formContact.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
Expand Down Expand Up @@ -84,7 +85,7 @@
$dbResult->closeCursor();

$cct = array();
if (($o == "c" || $o == "w") && $contactId) {
if (($o == MODIFY_CONTACT || $o == WATCH_CONTACT) && $contactId) {
/**
* Init Tables informations
*/
Expand Down Expand Up @@ -146,7 +147,7 @@
*/
$langs = array();
$langs = getLangs();
if ($o == "mc") {
if ($o == MASSIVE_CHANGE) {
array_unshift($langs, null);
}

Expand Down Expand Up @@ -236,7 +237,7 @@
* @var $moduleFormManager \Centreon\Domain\Service\ModuleFormManager
*/

if ($o == "a") {
if ($o == ADD_CONTACT) {
$form->addElement('header', 'title', _("Add a User"));

$eventDispatcher->notify(
Expand All @@ -248,7 +249,7 @@
'contact_id' => $contactId
]
);
} elseif ($o == "c") {
} elseif ($o == MODIFY_CONTACT) {
$form->addElement('header', 'title', _("Modify a User"));

$eventDispatcher->notify(
Expand All @@ -260,7 +261,7 @@
'contact_id' => $contactId
]
);
} elseif ($o == "w") {
} elseif ($o == WATCH_CONTACT) {
$form->addElement('header', 'title', _("View a User"));

$eventDispatcher->notify(
Expand All @@ -272,7 +273,7 @@
'contact_id' => $contactId
]
);
} elseif ($o == "mc") {
} elseif ($o == MASSIVE_CHANGE) {
$form->addElement('header', 'title', _("Massive Change"));

$eventDispatcher->notify(
Expand Down Expand Up @@ -301,7 +302,7 @@
* Don't change contact name and alias in massif change
* Don't change contact name, alias or autologin key in massive change
*/
if ($o != "mc") {
if ($o != MASSIVE_CHANGE) {
$form->addElement('text', 'contact_name', _("Full Name"), $attrsTextDescr);
$form->addElement('text', 'contact_alias', _("Alias / Login"), $attrsText);
$form->addElement('text', 'contact_autologin_key', _("Autologin Key"), array("size" => "90", "id" => "aKey"));
Expand All @@ -328,7 +329,7 @@
* Contact Groups Field
*/
$form->addElement('header', 'groupLinks', _("Group Relations"));
if ($o == "mc") {
if ($o == MASSIVE_CHANGE) {
$mc_mod_cg = array();
$mc_mod_cg[] = $form->createElement('radio', 'mc_mod_cg', null, _("Incremental"), '0');
$mc_mod_cg[] = $form->createElement('radio', 'mc_mod_cg', null, _("Replacement"), '1');
Expand Down Expand Up @@ -396,7 +397,7 @@
/**
* ACL configurations
*/
if ($o == "mc") {
if ($o == MASSIVE_CHANGE) {
$mc_mod_cg = array();
$mc_mod_cg[] = $form->createElement('radio', 'mc_mod_acl', null, _("Incremental"), '0');
$mc_mod_cg[] = $form->createElement('radio', 'mc_mod_acl', null, _("Replacement"), '1');
Expand Down Expand Up @@ -432,7 +433,7 @@
);
$form->addElement('select2', 'contact_location', _("Timezone / Location"), array(), $attrTimezones);

if ($o != "mc") {
if ($o != MASSIVE_CHANGE) {
$auth_type = array();
} else {
$auth_type = array(null => null);
Expand All @@ -446,7 +447,7 @@
$dnElement->freeze();
}
}
if ($o != "mc") {
if ($o != MASSIVE_CHANGE) {
$form->setDefaults(array(
'contact_oreon' => '1',
'contact_admin' => '0',
Expand All @@ -466,7 +467,7 @@
$tab[] = $form->createElement('radio', 'contact_enable_notifications', null, _("No"), '0');
$tab[] = $form->createElement('radio', 'contact_enable_notifications', null, _("Default"), '2');
$form->addGroup($tab, 'contact_enable_notifications', _("Enable Notifications"), '&nbsp;');
if ($o != "mc") {
if ($o != MASSIVE_CHANGE) {
$form->setDefaults(array('contact_enable_notifications' => '2'));
}

Expand Down Expand Up @@ -529,7 +530,7 @@

unset($hostNotifOpt);

if ($o == "mc") {
if ($o == MASSIVE_CHANGE) {
$mc_mod_hcmds = array();
$mc_mod_hcmds[] = $form->createElement('radio', 'mc_mod_hcmds', null, _("Incremental"), '0');
$mc_mod_hcmds[] = $form->createElement('radio', 'mc_mod_hcmds', null, _("Replacement"), '1');
Expand Down Expand Up @@ -615,7 +616,7 @@
);
$form->addElement('select2', 'timeperiod_tp_id2', _("Service Notification Period"), array(), $attrTimeperiod2);

if ($o == "mc") {
if ($o == MASSIVE_CHANGE) {
$mc_mod_svcmds = array();
$mc_mod_svcmds[] = $form->createElement('radio', 'mc_mod_svcmds', null, _("Incremental"), '0');
$mc_mod_svcmds[] = $form->createElement('radio', 'mc_mod_svcmds', null, _("Replacement"), '1');
Expand Down Expand Up @@ -645,7 +646,7 @@
$cctActivation[] = $form->createElement('radio', 'contact_activate', null, _("Disabled"), '0');
$form->addGroup($cctActivation, 'contact_activate', _("Status"), '&nbsp;');
$form->setDefaults(array('contact_activate' => '1'));
if ($o == "c" && $centreon->user->get_id() == $cct["contact_id"]) {
if ($o == MODIFY_CONTACT && $centreon->user->get_id() == $cct["contact_id"]) {
$form->freeze('contact_activate');
}

Expand Down Expand Up @@ -683,7 +684,7 @@ function myReplace()
$form->applyFilter('__ALL__', 'myTrim');
$form->applyFilter('contact_name', 'myReplace');
$from_list_menu = false;
if ($o != "mc") {
if ($o != MASSIVE_CHANGE) {
$ret = $form->getSubmitValues();
$form->addRule('contact_name', _("Compulsory Name"), 'required');
$form->addRule('contact_alias', _("Compulsory Alias"), 'required');
Expand Down Expand Up @@ -730,7 +731,7 @@ function myReplace()
_("You have to keep at least one contact to access to Centreon"),
'keepOneContactAtLeast'
);
} elseif ($o == "mc") {
} elseif ($o == MASSIVE_CHANGE) {
if ($form->getSubmitValue("submitMC")) {
$from_list_menu = false;
} else {
Expand All @@ -753,7 +754,7 @@ function myReplace()
$helptext .= '<span style="display:none" id="help:' . $key . '">' . $text . '</span>' . "\n";
}
$tpl->assign("helptext", $helptext);
if ($o == "w") {
if ($o == WATCH_CONTACT) {
# Just watch a contact information
if ($centreon->user->access->page($p) != 2) {
$form->addElement(
Expand All @@ -765,16 +766,16 @@ function myReplace()
}
$form->setDefaults($cct);
$form->freeze();
} elseif ($o == "c") {
} elseif ($o == MODIFY_CONTACT) {
# Modify a contact information
$subC = $form->addElement('submit', 'submitC', _("Save"), array("class" => "btc bt_success"));
$res = $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default"));
$form->setDefaults($cct);
} elseif ($o == "a") {
} elseif ($o == ADD_CONTACT) {
# Add a contact information
$subA = $form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success"));
$res = $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default"));
} elseif ($o == "mc") {
} elseif ($o == MASSIVE_CHANGE) {
# Massive Change
$subMC = $form->addElement('submit', 'submitMC', _("Save"), array("class" => "btc bt_success"));
$res = $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default"));
Expand All @@ -791,7 +792,7 @@ function myReplace()

if ($form->validate() && $from_list_menu == false) {
$cctObj = $form->getElement('contact_id');
if (!$centreon->user->admin && $contact_id) {
if (!$centreon->user->admin && $contactId) {
$form->removeElement('contact_admin');
$form->removeElement('reach_api');
$form->removeElement('reach_api_rt');
Expand Down Expand Up @@ -821,16 +822,16 @@ function myReplace()
);
} elseif ($form->getSubmitValue("submitMC")) {
$select = explode(",", $select);
foreach ($select as $key => $contactId) {
if ($contactId) {
updateContactInDB($contactId, true);
foreach ($select as $key => $selectedContactId) {
if ($selectedContactId) {
updateContactInDB($selectedContactId, true);

$eventDispatcher->notify(
'contact.form',
EventDispatcher::EVENT_UPDATE,
[
'form' => $form,
'contact_id' => $contactId
'contact_id' => $selectedContactId
]
);
}
Expand Down

0 comments on commit 5dc283b

Please sign in to comment.