]> source.dussan.org Git - sonarqube.git/commitdiff
Merge remote-tracking branch 'origin/branch-6.7'
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 6 Nov 2017 15:31:09 +0000 (16:31 +0100)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 6 Nov 2017 15:31:09 +0000 (16:31 +0100)
1  2 
pom.xml
server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionForm.tsx
server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionSet.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionForm-test.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionSet-test.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/LicenseEditionForm-test.tsx.snap
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/LicenseEditionSet-test.tsx.snap

diff --cc pom.xml
Simple merge
index 414a768e48561e581adf1de2874644f6303c0181,778c63fb4575e550090528d345c7ceed546fd959..f94c85cd727da82cb00afb4919b45b8bcc3b4914
@@@ -102,10 -107,15 +102,13 @@@ export default class LicenseEditionFor
          <footer className="modal-foot">
            {submitting && <i className="spinner spacer-right" />}
            {status && (
-             <button className="js-confirm" onClick={this.handleConfirmClick} disabled={submitting}>
+             <button
+               className="js-confirm"
+               onClick={this.handleConfirmClick}
+               disabled={!license || submitting}>
 -              {status === 'AUTOMATIC_INSTALL' ? (
 -                translate('marketplace.install')
 -              ) : (
 -                translate('save')
 -              )}
 +              {status === 'AUTOMATIC_INSTALL'
 +                ? translate('marketplace.install')
 +                : translate('save')}
              </button>
            )}
            <a className="js-modal-close" href="#" onClick={this.handleCancelClick}>
index f33cb6a39118a584076ba772a433c86675a1467c,2053ea87e5099b1663d2b10b77106269680c7f47..919a6aac0c1c183ccad13631ca805f39ed8b53c8
@@@ -20,8 -20,9 +20,9 @@@
  import { stringify } from 'querystring';
  import * as React from 'react';
  import * as classNames from 'classnames';
 -import Checkbox from '../../../components/controls/Checkbox';
  import { FormattedMessage } from 'react-intl';
  import { debounce } from 'lodash';
++import Checkbox from '../../../components/controls/Checkbox';
  import DeferredSpinner from '../../../components/common/DeferredSpinner';
  import { omitNil } from '../../../helpers/request';
  import { Edition, getFormData, getLicensePreview } from '../../../api/marketplace';
@@@ -125,48 -135,76 +135,76 @@@ export default class LicenseEditionSet 
      const { licenseEdition, previewStatus } = this.state;
      if (!previewStatus) {
        const { edition } = this.props;
-       if (edition && licenseEdition && edition.key !== licenseEdition.key) {
-         return (
-           <p className="alert alert-danger spacer-top">
-             {translateWithParameters('marketplace.wrong_license_type_x', edition.name)}
-           </p>
-         );
+       if (!edition) {
+         return undefined;
        }
  
-       return undefined;
+       return (
+         <div className="spacer-top">
+           {licenseEdition !== undefined &&
 -          edition.key !== licenseEdition.key && (
 -            <p className="alert alert-danger">
 -              {translateWithParameters('marketplace.wrong_license_type_x', edition.name)}
 -            </p>
 -          )}
++            edition.key !== licenseEdition.key && (
++              <p className="alert alert-danger">
++                {translateWithParameters('marketplace.wrong_license_type_x', edition.name)}
++              </p>
++            )}
+           <a href={this.getLicenseFormUrl(edition)} target="_blank">
+             {translate('marketplace.i_need_a_license')}
+           </a>
+         </div>
+       );
      }
  
      return (
-       <p
-         className={classNames('alert spacer-top', {
-           'alert-warning': previewStatus === 'AUTOMATIC_INSTALL',
-           'alert-success': previewStatus === 'NO_INSTALL',
-           'alert-danger': previewStatus === 'MANUAL_INSTALL'
-         })}>
-         {translateWithParameters(
-           'marketplace.license_preview_status.' + previewStatus,
-           licenseEdition ? licenseEdition.name : translate('marketplace.commercial_edition')
-         )}
-         {licenseEdition &&
-           licenseEdition.key === 'datacenter' &&
-           previewStatus !== 'NO_INSTALL' && (
-             <span className="little-spacer-left">
-               <FormattedMessage
-                 defaultMessage={translate('marketplace.how_to_setup_cluster_url')}
-                 id="marketplace.how_to_setup_cluster_url"
-                 values={{
-                   url: (
-                     <a
-                       href="https://redirect.sonarsource.com/doc/data-center-edition.html"
-                       target="_blank">
-                       {licenseEdition.name}
-                     </a>
-                   )
-                 }}
-               />
-             </span>
+       <div className="spacer-top">
+         <p
+           className={classNames('alert', {
+             'alert-warning': previewStatus === 'AUTOMATIC_INSTALL',
+             'alert-success': previewStatus === 'NO_INSTALL',
+             'alert-danger': previewStatus === 'MANUAL_INSTALL'
+           })}>
+           {translateWithParameters(
+             'marketplace.license_preview_status.' + previewStatus,
+             licenseEdition ? licenseEdition.name : translate('marketplace.commercial_edition')
            )}
-       </p>
+           {licenseEdition &&
 -          licenseEdition.key === 'datacenter' &&
 -          previewStatus !== 'NO_INSTALL' && (
 -            <span className="little-spacer-left">
 -              <FormattedMessage
 -                defaultMessage={translate('marketplace.how_to_setup_cluster_url')}
 -                id="marketplace.how_to_setup_cluster_url"
 -                values={{
 -                  url: (
 -                    <a
 -                      href="https://redirect.sonarsource.com/doc/data-center-edition.html"
 -                      target="_blank">
 -                      {licenseEdition.name}
 -                    </a>
 -                  )
 -                }}
 -              />
 -            </span>
 -          )}
++            licenseEdition.key === 'datacenter' &&
++            previewStatus !== 'NO_INSTALL' && (
++              <span className="little-spacer-left">
++                <FormattedMessage
++                  defaultMessage={translate('marketplace.how_to_setup_cluster_url')}
++                  id="marketplace.how_to_setup_cluster_url"
++                  values={{
++                    url: (
++                      <a
++                        href="https://redirect.sonarsource.com/doc/data-center-edition.html"
++                        target="_blank">
++                        {licenseEdition.name}
++                      </a>
++                    )
++                  }}
++                />
++              </span>
++            )}
+         </p>
+         {previewStatus !== 'NO_INSTALL' && (
+           <span className="js-edition-tos">
+             <Checkbox
+               checked={this.state.acceptTerms}
+               id="edition-terms"
+               onCheck={this.handleTermsCheck}>
+               <label className="little-spacer-left" htmlFor="edition-terms">
+                 {translate('marketplace.i_accept_the')}
+               </label>
+             </Checkbox>
+             <a
+               className="nowrap little-spacer-left"
+               href="http://dist.sonarsource.com/SonarSource_Terms_And_Conditions.pdf"
+               target="_blank">
+               {translate('marketplace.terms_and_conditions')}
+             </a>
+           </span>
+         )}
+       </div>
      );
    }
  
index 5efe571d8610077b3a55e92ee93484cc9fcd49e9,b0be56873fd02c33ccd14793e7047dfcbeff6ecb..846f65e191d7ad0cc7b53fa7282e39eb14fa7efc
@@@ -57,17 -55,33 +57,40 @@@ it('should display correctly', () => 
    expect(getWrapper()).toMatchSnapshot();
  });
  
 +it('should display the get license link with parameters', async () => {
 +  const wrapper = getWrapper();
 +  await new Promise(setImmediate);
 +  wrapper.update();
 +  expect(wrapper.find('a')).toMatchSnapshot();
 +});
 +
  it('should correctly display status message after checking license', async () => {
-   await testLicenseStatus('NO_INSTALL');
-   await testLicenseStatus('AUTOMATIC_INSTALL');
-   await testLicenseStatus('MANUAL_INSTALL');
+   let wrapper = await testLicenseStatus('NO_INSTALL', jest.fn());
+   expect(wrapper.find('p.alert')).toMatchSnapshot();
+   wrapper = await testLicenseStatus('AUTOMATIC_INSTALL', jest.fn());
+   expect(wrapper.find('p.alert')).toMatchSnapshot();
+   wrapper = await testLicenseStatus('MANUAL_INSTALL', jest.fn());
+   expect(wrapper.find('p.alert')).toMatchSnapshot();
+ });
+ it('should display terms of license checkbox', async () => {
+   let updateLicense = jest.fn();
+   let wrapper = await testLicenseStatus('NO_INSTALL', updateLicense);
+   expect(wrapper.find('.js-edition-tos').exists()).toBeFalsy();
+   expect(updateLicense).toHaveBeenCalledWith('mylicense', 'NO_INSTALL');
+   updateLicense = jest.fn();
+   wrapper = await testLicenseStatus('AUTOMATIC_INSTALL', updateLicense);
 -  let tosCheckbox = wrapper.find('.js-edition-tos');
++  const tosCheckbox = wrapper.find('.js-edition-tos');
+   expect(tosCheckbox.find('a').exists()).toBeTruthy();
+   expect(updateLicense).toHaveBeenLastCalledWith(undefined, 'AUTOMATIC_INSTALL');
+   (tosCheckbox.find('Checkbox').prop('onCheck') as Function)(true);
+   expect(updateLicense).toHaveBeenLastCalledWith('mylicense', 'AUTOMATIC_INSTALL');
+   updateLicense = jest.fn();
+   wrapper = await testLicenseStatus('MANUAL_INSTALL', updateLicense);
+   expect(wrapper.find('.js-edition-tos').exists()).toBeTruthy();
+   expect(updateLicense).toHaveBeenLastCalledWith(undefined, 'MANUAL_INSTALL');
  });
  
  function getWrapper(props = {}) {
@@@ -85,12 -99,11 +108,11 @@@ async function testLicenseStatus(status
    getLicensePreview.mockImplementation(() =>
      Promise.resolve({ nextEditionKey: 'foo', previewStatus: status })
    );
-   const updateLicense = jest.fn();
    const wrapper = getWrapper({ updateLicense });
 -  (wrapper.instance() as LicenseEditionSet).mounted = true;
    change(wrapper.find('textarea'), 'mylicense');
    expect(getLicensePreview).toHaveBeenCalled();
    await new Promise(setImmediate);
    expect(updateLicense).toHaveBeenCalled();
-   expect(wrapper.find('p.alert')).toMatchSnapshot();
 +  wrapper.update();
+   return wrapper;
  }
index 6e1defbecd03d402d01ff90756c6154ffd71682e,49d105b88f590330b46576d2e03779b9829c9928..c70a6a6abb0272dfea44cb2bc9de5cb921285625
@@@ -1,39 -1,18 +1,9 @@@
  // Jest Snapshot v1, https://goo.gl/fbAQLP
  
- exports[`should correctly change the button based on the status 1`] = `
- <button
-   className="js-confirm"
-   disabled={false}
-   onClick={[Function]}
- >
-   save
- </button>
- `;
- exports[`should correctly change the button based on the status 2`] = `
- <button
-   className="js-confirm"
-   disabled={false}
-   onClick={[Function]}
- >
-   marketplace.install
- </button>
- `;
- exports[`should correctly change the button based on the status 3`] = `
- <button
-   className="js-confirm"
-   disabled={false}
-   onClick={[Function]}
- >
-   save
- </button>
- `;
  exports[`should display correctly 1`] = `
  <Modal
 -  ariaHideApp={true}
 -  bodyOpenClassName="ReactModal__Body--open"
 -  className="modal"
 -  closeTimeoutMS={0}
    contentLabel="marketplace.upgrade_to_x.Foo"
 -  isOpen={true}
    onRequestClose={[Function]}
 -  overlayClassName="modal-overlay"
 -  parentSelector={[Function]}
 -  portalClassName="ReactModalPortal"
 -  shouldCloseOnOverlayClick={true}
  >
    <header
      className="modal-head"
index 6026ff03d9709dfffc4725e1ce523106a7006f11,19750aefb8bbcc60f13af6f55bd10a647ac95463..8631ff5d7d4370fbaa65f67ce17a624b198ae2f7
@@@ -65,23 -64,17 +64,26 @@@ exports[`should display correctly 1`] 
      }
      loading={false}
      timeout={100}
-   />
-   <a
-     className="display-inline-block spacer-top"
-     href="license_url"
-     target="_blank"
    >
-     marketplace.i_need_a_license
-   </a>
+     <div
+       className="spacer-top"
+     >
+       <a
+         href="license_url"
+         target="_blank"
+       >
+         marketplace.i_need_a_license
+       </a>
+     </div>
+   </DeferredSpinner>
  </div>
  `;
-   className="display-inline-block spacer-top"
 +
 +exports[`should display the get license link with parameters 1`] = `
 +<a
 +  href="license_url?serverId=foo&ncloc=1000"
 +  target="_blank"
 +>
 +  marketplace.i_need_a_license
 +</a>
 +`;