+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { getJSON, post } from '../helpers/request';
-
-export function getLicenses(): Promise<any> {
- return getJSON('/api/licenses/list').then(r => r.licenses);
-}
-
-export function setLicense(key: string, value: string): Promise<void> {
- const url = '/api/settings/set';
- const data = { key, value };
- return post(url, data);
-}
-
-export function resetLicense(key: string): Promise<void> {
- const url = '/api/settings/reset';
- const data = { keys: key };
- return post(url, data);
-}
export function encryptValue(value: string): Promise<any> {
return postJSON('/api/settings/encrypt', { value });
}
-
-export function getServerId(): Promise<any> {
- return getJSON('/api/server_id/show');
-}
-
-export function generateServerId(organization: string, ip: string): Promise<any> {
- return postJSON('/api/server_id/generate', { organization, ip });
-}
{translate('settings.page')}
</IndexLink>
</li>
- <li>
- <IndexLink to="/admin/settings/licenses" activeClassName="active">
- {translate('property.category.licenses')}
- </IndexLink>
- </li>
<li>
<IndexLink to="/admin/settings/encryption" activeClassName="active">
{translate('property.category.security.encryption')}
</IndexLink>
</li>
- <li>
- <IndexLink to="/admin/settings/server_id" activeClassName="active">
- {translate('property.category.server_id')}
- </IndexLink>
- </li>
<li>
<IndexLink to="/admin/custom_metrics" activeClassName="active">
{translate('custom_metrics.page')}
settings.page
</IndexLink>
</li>
- <li>
- <IndexLink
- activeClassName="active"
- to="/admin/settings/licenses"
- >
- property.category.licenses
- </IndexLink>
- </li>
<li>
<IndexLink
activeClassName="active"
property.category.security.encryption
</IndexLink>
</li>
- <li>
- <IndexLink
- activeClassName="active"
- to="/admin/settings/server_id"
- >
- property.category.server_id
- </IndexLink>
- </li>
<li>
<IndexLink
activeClassName="active"
<Redirect from="/settings" to="/admin/settings" />
<Redirect from="/settings/encryption" to="/admin/settings/encryption" />
<Redirect from="/settings/index" to="/admin/settings" />
- <Redirect from="/settings/licenses" to="/admin/settings/licenses" />
- <Redirect from="/settings/server_id" to="/admin/settings/server_id" />
<Redirect from="/sessions/login" to="/sessions/new" />
<Redirect from="/system" to="/admin/system" />
<Redirect from="/system/index" to="/admin/system" />
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-import Modal from 'react-modal';
-import { translate, translateWithParameters } from '../../../helpers/l10n';
-
-export default class LicenseChangeForm extends React.PureComponent {
- static propTypes = {
- license: PropTypes.object.isRequired,
- onChange: PropTypes.func.isRequired
- };
-
- state = {
- loading: false,
- modalOpen: false
- };
-
- onClick(e) {
- e.preventDefault();
- e.target.blur();
- this.setState({ modalOpen: true });
- }
-
- closeModal = () => this.setState({ modalOpen: false });
-
- handleSubmit = event => {
- event.preventDefault();
- if (this.textarea) {
- const { value } = this.textarea;
- this.setState({ loading: true });
- this.props
- .onChange(value)
- .then(
- () => this.setState({ loading: false, modalOpen: false }),
- () => this.setState({ loading: false })
- );
- }
- };
-
- handleCancelClick = event => {
- event.preventDefault();
- this.closeModal();
- };
-
- render() {
- const { license } = this.props;
- const productName = license.name || license.key;
-
- return (
- <button className="js-change" onClick={e => this.onClick(e)}>
- {translate('update_verb')}
-
- {this.state.modalOpen && (
- <Modal
- isOpen={true}
- contentLabel="license update"
- className="modal"
- overlayClassName="modal-overlay"
- onRequestClose={this.closeModal}>
- <form onSubmit={this.handleSubmit}>
- <div className="modal-head">
- <h2>{translateWithParameters('licenses.update_license_for_x', productName)}</h2>
- </div>
- <div className="modal-body">
- <label htmlFor="license-input">{translate('licenses.license_input_label')}</label>
- <textarea
- autoFocus={true}
- className="width-100 spacer-top"
- ref={node => (this.textarea = node)}
- rows="7"
- id="license-input"
- defaultValue={license.value}
- />
- <div className="spacer-top note">{translate('licenses.license_input_note')}</div>
- </div>
- <div className="modal-foot">
- {this.state.loading && <i className="js-modal-spinner spinner spacer-right" />}
- <button className="js-modal-submit" disabled={this.state.loading}>
- {translate('save')}
- </button>
- <a href="#" className="js-modal-close" onClick={this.handleCancelClick}>
- {translate('cancel')}
- </a>
- </div>
- </form>
- </Modal>
- )}
- </button>
- );
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-import DateFormatter from '../../../components/intl/DateFormatter';
-import LicenseStatus from './LicenseStatus';
-import LicenseChangeForm from './LicenseChangeForm';
-
-export default class LicenseRow extends React.PureComponent {
- static propTypes = {
- license: PropTypes.object.isRequired,
- setLicense: PropTypes.func.isRequired
- };
-
- handleSet = value => this.props.setLicense(this.props.license.key, value);
-
- render() {
- const { license } = this.props;
-
- return (
- <tr className="js-license" data-license-key={license.key}>
- <td className="text-middle">
- <LicenseStatus license={license} />
- </td>
- <td className="js-product text-middle">
- <div className={license.invalidProduct ? 'text-danger' : null}>
- {license.name || license.key}
- </div>
- </td>
- <td className="js-organization text-middle">{license.organization}</td>
- <td className="js-expiration text-middle">
- {license.expiration != null && (
- <div className={license.invalidExpiration ? 'text-danger' : null}>
- <DateFormatter date={license.expiration} long={true} />
- </div>
- )}
- </td>
- <td className="js-type text-middle">{license.type}</td>
- <td className="js-server-id text-middle">
- <div className={license.invalidServerId ? 'text-danger' : null}>{license.serverId}</div>
- </td>
- <td className="text-right">
- <LicenseChangeForm license={license} onChange={this.handleSet} />
- </td>
- </tr>
- );
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { connect } from 'react-redux';
-import LicenseRow from './LicenseRow';
-import { setLicense } from '../store/licenses/actions';
-import { getSettingsAppLicenseByKey } from '../../../store/rootReducer';
-
-const mapStateToProps = (state, ownProps) => ({
- license: getSettingsAppLicenseByKey(state, ownProps.licenseKey)
-});
-
-export default connect(mapStateToProps, { setLicense })(LicenseRow);
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-import { isLicenseInvalid } from './licenseUtils';
-
-export default class LicenseStatus extends React.PureComponent {
- static propTypes = {
- license: PropTypes.object.isRequired
- };
-
- render() {
- const { license } = this.props;
-
- if (license.value == null) {
- return null;
- }
-
- const isInvalid = isLicenseInvalid(license);
- if (isInvalid) {
- return <i className="icon-alert-error" />;
- }
-
- return <i className="icon-check" />;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import Helmet from 'react-helmet';
-import LicensesAppHeader from './LicensesAppHeader';
-import LicensesListContainer from './LicensesListContainer';
-import { translate } from '../../../helpers/l10n';
-
-export default function LicensesApp() {
- return (
- <div id="licenses-page" className="page page-limited">
- <Helmet title={translate('property.category.licenses')} />
- <LicensesAppHeader />
- <LicensesListContainer />
- </div>
- );
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { translate } from '../../../helpers/l10n';
-
-export default function LicensesAppHeader() {
- return (
- <header className="page-header">
- <h1 className="page-title">{translate('property.category.licenses')}</h1>
- <div
- className="page-description"
- dangerouslySetInnerHTML={{ __html: translate('property.category.licenses.description') }}
- />
- </header>
- );
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-import LicenseRowContainer from './LicenseRowContainer';
-import { translate } from '../../../helpers/l10n';
-
-export default class LicensesList extends React.PureComponent {
- static propTypes = {
- licenses: PropTypes.array.isRequired,
- fetchLicenses: PropTypes.func.isRequired
- };
-
- componentDidMount() {
- this.props.fetchLicenses().catch(() => {
- /* do nothing */
- });
- }
-
- render() {
- return (
- <table className="data zebra zebra-hover" style={{ tableLayout: 'fixed' }}>
- <thead>
- <tr>
- <th width={40}> </th>
- <th>{translate('licenses.list.product')}</th>
- <th width={150}>{translate('licenses.list.organization')}</th>
- <th width={150}>{translate('licenses.list.expiration')}</th>
- <th width={150}>{translate('licenses.list.type')}</th>
- <th width={150}>{translate('licenses.list.server')}</th>
- <th width={80}> </th>
- </tr>
- </thead>
- <tbody>
- {this.props.licenses.map(licenseKey => (
- <LicenseRowContainer key={licenseKey} licenseKey={licenseKey} />
- ))}
- </tbody>
- </table>
- );
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { connect } from 'react-redux';
-import LicensesList from './LicensesList';
-import { fetchLicenses } from '../store/licenses/actions';
-import { getSettingsAppAllLicenseKeys } from '../../../store/rootReducer';
-
-const mapStateToProps = state => ({
- licenses: getSettingsAppAllLicenseKeys(state)
-});
-
-export default connect(mapStateToProps, { fetchLicenses })(LicensesList);
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import LicenseChangeForm from '../LicenseChangeForm';
-
-it('should render button', () => {
- const form = shallow(<LicenseChangeForm license={{}} onChange={jest.fn()} />);
- expect(form.is('button')).toBe(true);
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import LicenseRow from '../LicenseRow';
-import LicenseStatus from '../LicenseStatus';
-import LicenseChangeForm from '../LicenseChangeForm';
-
-it('should render status', () => {
- const license = {};
- const licenseStatus = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- LicenseStatus
- );
- expect(licenseStatus.length).toBe(1);
- expect(licenseStatus.prop('license')).toBe(license);
-});
-
-it('should render product', () => {
- const license = { name: 'foo' };
- const licenseProduct = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-product'
- );
- expect(licenseProduct.length).toBe(1);
- expect(licenseProduct.text()).toContain('foo');
-});
-
-it('should render invalid product', () => {
- const license = { product: 'foo', invalidProduct: true };
- const licenseProduct = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-product'
- );
- expect(licenseProduct.find('.text-danger').length).toBe(1);
-});
-
-it('should render key when no name', () => {
- const license = { key: 'foo.secured' };
- const licenseProduct = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-product'
- );
- expect(licenseProduct.length).toBe(1);
- expect(licenseProduct.text()).toContain('foo.secured');
-});
-
-it('should render organization', () => {
- const license = { organization: 'org' };
- const licenseOrg = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-organization'
- );
- expect(licenseOrg.length).toBe(1);
- expect(licenseOrg.text()).toContain('org');
-});
-
-it('should render expiration', () => {
- const license = { expiration: '2015-01-01' };
- const licenseExpiration = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-expiration'
- );
- expect(licenseExpiration.length).toBe(1);
- expect(licenseExpiration.find('DateFormatter')).toHaveLength(1);
-});
-
-it('should render invalid expiration', () => {
- const license = { expiration: '2015-01-01', invalidExpiration: true };
- const licenseExpiration = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-expiration'
- );
- expect(licenseExpiration.find('.text-danger').length).toBe(1);
-});
-
-it('should render type', () => {
- const license = { type: 'PRODUCTION' };
- const licenseType = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-type'
- );
- expect(licenseType.length).toBe(1);
- expect(licenseType.text()).toContain('PRODUCTION');
-});
-
-it('should render server id', () => {
- const license = { serverId: 'bar' };
- const licenseServerId = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-server-id'
- );
- expect(licenseServerId.length).toBe(1);
- expect(licenseServerId.text()).toContain('bar');
-});
-
-it('should render invalid server id', () => {
- const license = { serverId: 'bar', invalidServerId: true };
- const licenseServerId = shallow(<LicenseRow license={license} setLicense={jest.fn()} />).find(
- '.js-server-id'
- );
- expect(licenseServerId.find('.text-danger').length).toBe(1);
-});
-
-it('should render change form', () => {
- const license = { key: 'foo' };
- const setLicense = jest.fn(() => Promise.resolve());
- const licenseChangeForm = shallow(<LicenseRow license={license} setLicense={setLicense} />).find(
- LicenseChangeForm
- );
- expect(licenseChangeForm.length).toBe(1);
- expect(licenseChangeForm.prop('license')).toBe(license);
- expect(typeof licenseChangeForm.prop('onChange')).toBe('function');
-
- licenseChangeForm.prop('onChange')('license-hash');
- expect(setLicense).toBeCalledWith('foo', 'license-hash');
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import LicenseStatus from '../LicenseStatus';
-
-it('should render nothing when no value', () => {
- const status = shallow(<LicenseStatus license={{}} />);
- expect(status.node).toBeNull();
-});
-
-it('should render ok', () => {
- const status = shallow(<LicenseStatus license={{ value: 'foo' }} />);
- expect(status.is('.icon-check')).toBe(true);
-});
-
-it('should render error when invalid product', () => {
- const status = shallow(<LicenseStatus license={{ value: 'foo', invalidProduct: true }} />);
- expect(status.is('.icon-check')).toBe(false);
- expect(status.is('.icon-alert-error')).toBe(true);
-});
-
-it('should render error when invalid expiration', () => {
- const status = shallow(<LicenseStatus license={{ value: 'foo', invalidExpiration: true }} />);
- expect(status.is('.icon-check')).toBe(false);
- expect(status.is('.icon-alert-error')).toBe(true);
-});
-
-it('should render error when invalid server id', () => {
- const status = shallow(<LicenseStatus license={{ value: 'foo', invalidServerId: true }} />);
- expect(status.is('.icon-check')).toBe(false);
- expect(status.is('.icon-alert-error')).toBe(true);
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import LicensesApp from '../LicensesApp';
-import LicensesAppHeader from '../LicensesAppHeader';
-import LicensesListContainer from '../LicensesListContainer';
-
-it('should render', () => {
- const app = shallow(<LicensesApp />);
- expect(app.find(LicensesAppHeader).length).toBe(1);
- expect(app.find(LicensesListContainer).length).toBe(1);
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow } from 'enzyme';
-import LicensesAppHeader from '../LicensesAppHeader';
-
-it('should render', () => {
- const header = shallow(<LicensesAppHeader />);
- expect(header.find('.page-title').length).toBe(1);
- expect(header.find('.page-description').length).toBe(1);
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import { shallow, mount } from 'enzyme';
-import LicensesList from '../LicensesList';
-import LicenseRowContainer from '../LicenseRowContainer';
-
-it('should render', () => {
- const list = shallow(<LicensesList licenses={[]} fetchLicenses={jest.fn()} />);
- expect(list.is('table')).toBe(true);
-});
-
-it('should fetch licenses', () => {
- const fetchLicenses = jest.fn(() => Promise.resolve());
- mount(<LicensesList licenses={[]} fetchLicenses={fetchLicenses} />);
- expect(fetchLicenses).toBeCalled();
-});
-
-it('should render rows', () => {
- const list = shallow(<LicensesList licenses={['foo', 'bar']} fetchLicenses={jest.fn()} />);
- expect(list.find(LicenseRowContainer).length).toBe(2);
- expect(
- list
- .find(LicenseRowContainer)
- .at(0)
- .prop('licenseKey')
- ).toBe('foo');
- expect(
- list
- .find(LicenseRowContainer)
- .at(1)
- .prop('licenseKey')
- ).toBe('bar');
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-export const isLicenseInvalid = license =>
- !!license.invalidProduct || !!license.invalidExpiration || !!license.invalidServerId;
-
-export const isLicenseFromListInvalid = (licenses, key) => {
- const license = licenses.find(license => license.key === key);
- return license ? isLicenseInvalid(license) : false;
-};
import('./components/AppContainer').then(i => callback(null, { component: i.default }));
}
},
- {
- path: 'licenses',
- getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) {
- import('./licenses/LicensesApp').then(i => callback(null, i.default));
- }
- },
{
path: 'encryption',
getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) {
import('./encryption/EncryptionAppContainer').then(i => callback(null, i.default));
}
- },
- {
- path: 'server_id',
- getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) {
- import('./serverId/ServerIdAppContainer').then(i => callback(null, i.default));
- }
}
];
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import React from 'react';
-import PropTypes from 'prop-types';
-import Helmet from 'react-helmet';
-import { translate } from '../../../helpers/l10n';
-import { getServerId, generateServerId } from '../../../api/settings';
-import { parseError } from '../../code/utils';
-
-export default class ServerIdApp extends React.PureComponent {
- static propTypes = {
- addGlobalErrorMessage: PropTypes.func.isRequired,
- closeAllGlobalMessages: PropTypes.func.isRequired
- };
-
- state = {
- loading: true,
- organization: '',
- ip: '',
- validIpAddresses: []
- };
-
- componentDidMount() {
- this.mounted = true;
- this.fetchServerId();
- }
-
- componentWillUnmount() {
- this.mounted = false;
- }
-
- handleError(error) {
- this.setState({ loading: false });
- parseError(error).then(message => this.props.addGlobalErrorMessage(message));
- }
-
- fetchServerId() {
- this.setState({ loading: true });
- getServerId()
- .then(data => {
- if (this.mounted) {
- this.setState({ ...data, loading: false });
- }
- })
- .catch(error => this.handleError(error));
- }
-
- handleSubmit(e) {
- e.preventDefault();
- this.setState({ loading: true });
- this.props.closeAllGlobalMessages();
- generateServerId(this.state.organization, this.state.ip)
- .then(data => {
- if (this.mounted) {
- this.setState({ serverId: data.serverId, invalidServerId: false, loading: false });
- }
- })
- .catch(error => this.handleError(error));
- }
-
- render() {
- return (
- <div id="server-id-page" className="page page-limited">
- <Helmet title={translate('property.category.server_id')} />
- <header className="page-header">
- <h1 className="page-title">{translate('property.category.server_id')}</h1>
- {this.state.loading && <i className="spinner" />}
- <div className="page-description">{translate('server_id_configuration.information')}</div>
- </header>
-
- {this.state.serverId != null && (
- <div className={this.state.invalidServerId ? 'panel panel-danger' : 'panel'}>
- {translate('property.category.server_id')}:
- <input
- id="server-id-result"
- className="spacer-left input-large input-clear input-code"
- type="text"
- readOnly={true}
- value={this.state.serverId}
- />
- {!!this.state.invalidServerId && (
- <span className="spacer-left">{translate('server_id_configuration.bad_key')}</span>
- )}
- </div>
- )}
-
- <div className="panel">
- <form id="server-id-form" onSubmit={e => this.handleSubmit(e)}>
- <div className="modal-field">
- <label htmlFor="server-id-organization">
- {translate('server_id_configuration.organisation.title')}
- <em className="mandatory">*</em>
- </label>
- <input
- id="server-id-organization"
- type="text"
- required={true}
- value={this.state.organization}
- disabled={this.state.loading}
- onChange={e => this.setState({ organization: e.target.value })}
- />
- <div className="modal-field-description">
- {translate('server_id_configuration.organisation.desc')}
- {'. '}
- {translate('server_id_configuration.organisation.pattern')}
- </div>
- </div>
-
- <div className="modal-field">
- <label htmlFor="server-id-ip">
- {translate('server_id_configuration.ip.title')}
- <em className="mandatory">*</em>
- </label>
- <input
- id="server-id-ip"
- type="text"
- required={true}
- value={this.state.ip}
- disabled={this.state.loading}
- onChange={e => this.setState({ ip: e.target.value })}
- />
- <div className="modal-field-description">
- {translate('server_id_configuration.ip.desc')}
- <ul className="list-styled">
- {this.state.validIpAddresses.map(ip => (
- <li key={ip} className="little-spacer-top">
- {ip}
- </li>
- ))}
- </ul>
- </div>
- </div>
-
- <div className="modal-field">
- <button disabled={this.state.loading}>
- {translate('server_id_configuration.generate_button')}
- </button>
- </div>
- </form>
- </div>
- </div>
- );
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { connect } from 'react-redux';
-import ServerIdApp from './ServerIdApp';
-import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../store/globalMessages/duck';
-
-export default connect(() => ({}), { addGlobalErrorMessage, closeAllGlobalMessages })(ServerIdApp);
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import * as licenses from '../../../../api/licenses';
-import { parseError } from '../../../code/utils';
-import {
- addGlobalSuccessMessage,
- addGlobalErrorMessage
-} from '../../../../store/globalMessages/duck';
-import { translate } from '../../../../helpers/l10n';
-import { isLicenseFromListInvalid, isLicenseInvalid } from '../../licenses/licenseUtils';
-
-export const RECEIVE_LICENSES = 'RECEIVE_LICENSES';
-
-const receiveLicenses = licenses => ({
- type: RECEIVE_LICENSES,
- licenses
-});
-
-const handleError = dispatch => error => {
- parseError(error).then(message => dispatch(addGlobalErrorMessage(message)));
- return Promise.reject();
-};
-
-export const fetchLicenses = () => dispatch => {
- return licenses
- .getLicenses()
- .then(licenses => {
- dispatch(receiveLicenses(licenses));
- /* eslint import/namespace: 0 */
- const invalidLicenses = licenses.some(isLicenseInvalid);
- if (invalidLicenses) {
- dispatch(addGlobalErrorMessage(translate('licenses.there_are_invalid')));
- }
- })
- .catch(handleError(dispatch));
-};
-
-export const setLicense = (key, value) => dispatch => {
- const request = value ? licenses.setLicense(key, value) : licenses.resetLicense(key);
-
- return request
- .then(() =>
- licenses.getLicenses().then(licenses => {
- dispatch(receiveLicenses(licenses));
- if (isLicenseFromListInvalid(licenses, key)) {
- dispatch(addGlobalErrorMessage(translate('licenses.error_message')));
- } else {
- dispatch(addGlobalSuccessMessage(translate('licenses.success_message')));
- }
- })
- )
- .catch(handleError(dispatch));
-};
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { keyBy } from 'lodash';
-import { RECEIVE_LICENSES } from './actions';
-
-const reducer = (state = {}, action = {}) => {
- if (action.type === RECEIVE_LICENSES) {
- const licensesByKey = keyBy(action.licenses, 'key');
- return { ...state, ...licensesByKey };
- }
-
- return state;
-};
-
-export default reducer;
-
-export const getLicenseByKey = (state, key) => state[key];
-
-export const getAllLicenseKeys = state => Object.keys(state);
import definitions, * as fromDefinitions from './definitions/reducer';
import values, * as fromValues from './values/reducer';
import settingsPage, * as fromSettingsPage from './settingsPage/reducer';
-import licenses, * as fromLicenses from './licenses/reducer';
import globalMessages, * as fromGlobalMessages from '../../../store/globalMessages/duck';
import encryptionPage from './encryptionPage/reducer';
/*:: import type { State as GlobalMessagesState } from '../../../store/globalMessages/duck'; */
definitions: {},
encryptionPage: {},
globalMessages: GlobalMessagesState,
- licenses: {},
settingsPage: {},
values: ValuesState
};
definitions,
values,
settingsPage,
- licenses,
encryptionPage,
globalMessages
});
export const isLoading = (state /*: State */, key /*: string */) =>
fromSettingsPage.isLoading(state.settingsPage, key);
-export const getLicenseByKey = (state /*: State */, key /*: string */) =>
- fromLicenses.getLicenseByKey(state.licenses, key);
-
-export const getAllLicenseKeys = (state /*: State */) =>
- fromLicenses.getAllLicenseKeys(state.licenses);
-
export const getValidationMessage = (state /*: State */, key /*: string */) =>
fromSettingsPage.getValidationMessage(state.settingsPage, key);
export const isSettingsAppLoading = (state, key) =>
fromSettingsApp.isLoading(state.settingsApp, key);
-export const getSettingsAppLicenseByKey = (state, key) =>
- fromSettingsApp.getLicenseByKey(state.settingsApp, key);
-
-export const getSettingsAppAllLicenseKeys = state =>
- fromSettingsApp.getAllLicenseKeys(state.settingsApp);
-
export const getSettingsAppValidationMessage = (state, key) =>
fromSettingsApp.getValidationMessage(state.settingsApp, key);
property.category.codeCoverage=Code Coverage
property.category.duplications=Duplications
property.category.localization=Localization
-property.category.server_id=Server ID
property.category.exclusions=Analysis Scope
property.category.webhooks=Webhooks
property.sonar.inclusions.name=Source File Inclusions
email_configuration.test.email_was_sent_to_x=Email was sent to {0}
-#------------------------------------------------------------------------------
-#
-# LICENSES & SERVER KEY CONFIGURATION
-#
-#------------------------------------------------------------------------------
-property.category.licenses=Licenses
-property.category.licenses.description=In case of any issue or question about licenses, please send an email to <a href="mailto:contact@sonarsource.com?subject=Question about license">contact@sonarsource.com</a>.
-property.category.licenses.server_id=Server ID
-
-server_id_configuration.generate_button=Generate ID
-server_id_configuration.bad_key=The ID is not valid anymore. Please check the organization and the IP address.
-server_id_configuration.information=The Server ID is a unique identifier of this SonarQube instance. It is used for example to obtain a license key for the SonarSource's commercial plugins. Two fields have to be provided to generate the ID : organization name and one of the IP addresses of the machine that hosts this server. There is no need to restart the server after generating a new server ID.
-server_id_configuration.organisation.title=Organization
-server_id_configuration.organisation.desc=Name of the organization
-server_id_configuration.organisation.pattern=Only letters, digits and whitespaces are allowed.
-server_id_configuration.ip.title=Fixed IP Address
-server_id_configuration.ip.desc=A server ID is linked to the IP address of the hosting machine that runs SonarQube. If the server IP address was to change, the server ID will have to be regenerated. The valid addresses are :
-
-licenses.list.product=Product
-licenses.list.organization=Organization
-licenses.list.expiration=Expiration
-licenses.list.type=Type
-licenses.list.server=Server
-licenses.update_license_for_x=Update License for {0}
-licenses.license_input_label=Insert the license text below:
-licenses.license_input_note=Keep empty if you want to unset this license.
-licenses.success_message=The license has been updated.
-licenses.error_message=The license you have just set is invalid.
-licenses.there_are_invalid=Some of the licenses are not valid. Please check the details below.
-
-
#------------------------------------------------------------------------------
#
# NOTIFICATIONS