diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-20 15:33:44 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-23 08:01:13 -0700 |
commit | ee4d391a17cddca6478e95db65601b398af3f78f (patch) | |
tree | d5ead0181c903bf95d166e5cba893006dc5c5c92 | |
parent | 4064ea3d8241568ccc7a1cf556bd8eeb0e92c5e9 (diff) | |
download | sonarqube-ee4d391a17cddca6478e95db65601b398af3f78f.tar.gz sonarqube-ee4d391a17cddca6478e95db65601b398af3f78f.zip |
Prevent from any action on the marketplace when in cluster mode
13 files changed, 66 insertions, 22 deletions
diff --git a/server/sonar-web/src/main/js/apps/marketplace/App.tsx b/server/sonar-web/src/main/js/apps/marketplace/App.tsx index fd737dc037f..c5012002c95 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/App.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/App.tsx @@ -45,6 +45,7 @@ export interface Props { editionsUrl: string; location: { pathname: string; query: RawQuery }; sonarqubeVersion: string; + standaloneMode: boolean; updateCenterActive: boolean; } @@ -204,6 +205,7 @@ export default class App extends React.PureComponent<Props, State> { }; render() { + const { standaloneMode } = this.props; const { editions, editionStatus, loadingPlugins, plugins, pending } = this.state; const query = parseQuery(this.props.location.query); const filteredPlugins = query.search ? filterPlugins(plugins, query.search) : plugins; @@ -216,10 +218,13 @@ export default class App extends React.PureComponent<Props, State> { <EditionsStatusNotif editions={editions} editionStatus={editionStatus} + readOnly={!standaloneMode} updateEditionStatus={this.updateEditionStatus} /> )} - <PendingActions refreshPending={this.fetchPendingPlugins} pending={pending} /> + {!standaloneMode && ( + <PendingActions refreshPending={this.fetchPendingPlugins} pending={pending} /> + )} </div> <Header /> <EditionBoxes @@ -227,6 +232,7 @@ export default class App extends React.PureComponent<Props, State> { loading={this.state.loadingEditions} editionStatus={editionStatus} editionsUrl={this.props.editionsUrl} + readOnly={!standaloneMode} sonarqubeVersion={this.props.sonarqubeVersion} updateCenterActive={this.props.updateCenterActive} updateEditionStatus={this.updateEditionStatus} @@ -241,6 +247,7 @@ export default class App extends React.PureComponent<Props, State> { <PluginsList plugins={filteredPlugins} pending={pending} + readOnly={!standaloneMode} refreshPending={this.fetchPendingPlugins} updateQuery={this.updateQuery} /> diff --git a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx index abf67e2c3d8..90fac954650 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx @@ -25,6 +25,7 @@ import './style.css'; const mapStateToProps = (state: any) => ({ editionsUrl: (getGlobalSettingValue(state, 'sonar.editions.jsonUrl') || {}).value, sonarqubeVersion: getAppState(state).version, + standaloneMode: getAppState(state).standalone, updateCenterActive: (getGlobalSettingValue(state, 'sonar.updatecenter.activate') || {}).value === 'true' }); diff --git a/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx b/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx index 95a3c96d109..e9b7fa6f246 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx @@ -30,6 +30,7 @@ export interface Props { editionStatus?: EditionStatus; editionsUrl: string; loading: boolean; + readOnly: boolean; sonarqubeVersion: string; updateCenterActive: boolean; updateEditionStatus: (editionStatus: EditionStatus) => void; @@ -50,7 +51,7 @@ export default class EditionBoxes extends React.PureComponent<Props, State> { handleCloseUninstallForm = () => this.setState({ openUninstallForm: false }); render() { - const { editions, editionStatus, loading } = this.props; + const { editions, editionStatus, loading, readOnly } = this.props; const { installEdition, openUninstallForm } = this.state; if (loading) { return <i className="big-spacer-bottom spinner" />; @@ -85,10 +86,12 @@ export default class EditionBoxes extends React.PureComponent<Props, State> { key={edition.key} onInstall={this.handleOpenLicenseForm} onUninstall={this.handleOpenUninstallForm} + readOnly={readOnly} /> ))} - {installEdition && ( + {!readOnly && + installEdition && ( <LicenseEditionForm edition={installEdition} editions={editions} @@ -97,7 +100,8 @@ export default class EditionBoxes extends React.PureComponent<Props, State> { /> )} - {openUninstallForm && + {!readOnly && + openUninstallForm && editionStatus && editionStatus.currentEditionKey && ( <UninstallEditionForm diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx index df07149f700..4bc679d4d2a 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx @@ -30,6 +30,7 @@ interface Props { updating: PluginPending[]; removing: PluginPending[]; }; + readOnly: boolean; refreshPending: () => void; updateQuery: (newQuery: Partial<Query>) => void; } @@ -56,6 +57,7 @@ export default class PluginsList extends React.PureComponent<Props> { <PluginInstalled plugin={plugin} status={status} + readOnly={this.props.readOnly} refreshPending={this.props.refreshPending} updateQuery={this.props.updateQuery} /> @@ -66,6 +68,7 @@ export default class PluginsList extends React.PureComponent<Props> { <PluginAvailable plugin={plugin} status={status} + readOnly={this.props.readOnly} refreshPending={this.props.refreshPending} updateQuery={this.props.updateQuery} /> diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx index ca11079be15..eeff50797ce 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx @@ -71,6 +71,7 @@ function getWrapper(props = {}) { loading={false} editionStatus={DEFAULT_STATUS} editionsUrl="" + readOnly={false} sonarqubeVersion="6.7.5" updateCenterActive={true} updateEditionStatus={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap index f02b9834603..ffaa0ae4298 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap @@ -55,6 +55,7 @@ exports[`should display the edition boxes 2`] = ` } onInstall={[Function]} onUninstall={[Function]} + readOnly={false} /> <EditionBox edition={ @@ -76,6 +77,7 @@ exports[`should display the edition boxes 2`] = ` } onInstall={[Function]} onUninstall={[Function]} + readOnly={false} /> </div> `; diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx index 70920158b75..d637c7116ae 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx @@ -27,6 +27,7 @@ interface Props { editionStatus?: EditionStatus; onInstall: (edition: Edition) => void; onUninstall: () => void; + readOnly: boolean; } export default class EditionBox extends React.PureComponent<Props> { @@ -56,7 +57,7 @@ export default class EditionBox extends React.PureComponent<Props> { } render() { - const { edition, editionStatus } = this.props; + const { edition, editionStatus, readOnly } = this.props; const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key; const installInProgress = editionStatus && @@ -72,12 +73,14 @@ export default class EditionBox extends React.PureComponent<Props> { <a href={edition.homeUrl} target="_blank"> {translate('marketplace.learn_more')} </a> - {!isInstalled && ( + {!readOnly && + !isInstalled && ( <button disabled={installInProgress} onClick={this.handleInstall}> {translate('marketplace.install')} </button> )} - {isInstalled && ( + {!readOnly && + isInstalled && ( <button className="button-red" disabled={installInProgress} diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx index 7679e29a591..2430200ac27 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx @@ -26,6 +26,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { editions?: Edition[]; editionStatus: EditionStatus; + readOnly: boolean; updateEditionStatus: (editionStatus: EditionStatus) => void; } @@ -49,7 +50,8 @@ export default class EditionsStatusNotif extends React.PureComponent<Props, Stat }; renderStatusAlert() { - const { installationStatus, nextEditionKey } = this.props.editionStatus; + const { editionStatus, readOnly } = this.props; + const { installationStatus, nextEditionKey } = editionStatus; const nextEdition = this.props.editions && this.props.editions.find(edition => edition.key === nextEditionKey); @@ -75,10 +77,13 @@ export default class EditionsStatusNotif extends React.PureComponent<Props, Stat translate('marketplace.status', installationStatus) )} </span> - <button className="js-restart spacer-left" onClick={this.handleOpenRestart}> - {translate('marketplace.restart')} - </button> - {this.state.openRestart && <RestartForm onClose={this.hanleCloseRestart} />} + {!readOnly && ( + <button className="js-restart spacer-left" onClick={this.handleOpenRestart}> + {translate('marketplace.restart')} + </button> + )} + {!readOnly && + this.state.openRestart && <RestartForm onClose={this.hanleCloseRestart} />} </div> ); case 'MANUAL_IN_PROGRESS': diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/PluginAvailable.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginAvailable.tsx index a6badc50eab..86935c1406d 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/PluginAvailable.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginAvailable.tsx @@ -30,12 +30,19 @@ import { Query } from '../utils'; interface Props { plugin: PluginAvailable; + readOnly: boolean; refreshPending: () => void; status?: string; updateQuery: (newQuery: Partial<Query>) => void; } -export default function PluginAvailable({ plugin, refreshPending, status, updateQuery }: Props) { +export default function PluginAvailable({ + plugin, + readOnly, + refreshPending, + status, + updateQuery +}: Props) { return ( <tr> <PluginDescription plugin={plugin} updateQuery={updateQuery} /> @@ -71,7 +78,9 @@ export default function PluginAvailable({ plugin, refreshPending, status, update </ul> </td> - <PluginStatus plugin={plugin} status={status} refreshPending={refreshPending} /> + {!readOnly && ( + <PluginStatus plugin={plugin} status={status} refreshPending={refreshPending} /> + )} </tr> ); } diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/PluginInstalled.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginInstalled.tsx index 6dc69081d72..df35603ab15 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/PluginInstalled.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginInstalled.tsx @@ -30,12 +30,19 @@ import { Query } from '../utils'; interface Props { plugin: PluginInstalled; + readOnly: boolean; refreshPending: () => void; status?: string; updateQuery: (newQuery: Partial<Query>) => void; } -export default function PluginInstalled({ plugin, refreshPending, status, updateQuery }: Props) { +export default function PluginInstalled({ + plugin, + readOnly, + refreshPending, + status, + updateQuery +}: Props) { return ( <tr> <PluginDescription plugin={plugin} updateQuery={updateQuery} /> @@ -59,7 +66,9 @@ export default function PluginInstalled({ plugin, refreshPending, status, update </ul> </td> - <PluginStatus plugin={plugin} status={status} refreshPending={refreshPending} /> + {!readOnly && ( + <PluginStatus plugin={plugin} status={status} refreshPending={refreshPending} /> + )} </tr> ); } diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/PluginStatus.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginStatus.tsx index d797cbbd736..50716b726e9 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/PluginStatus.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginStatus.tsx @@ -43,12 +43,7 @@ export default function PluginStatus({ plugin, refreshPending, status }: Props) <p className="text-danger">{translate('marketplace.uninstall_pending')}</p> )} - {status == null && ( - <div> - <i className="js-spinner spinner hidden" /> - <PluginActions plugin={plugin} refreshPending={refreshPending} /> - </div> - )} + {status == null && <PluginActions plugin={plugin} refreshPending={refreshPending} />} </td> ); } diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx index ceaf61a7aa5..fbc88c1deb4 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx @@ -117,6 +117,7 @@ function getWrapper(props = {}) { editionStatus={DEFAULT_STATUS} onInstall={jest.fn()} onUninstall={jest.fn()} + readOnly={false} {...props} /> ); diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionsStatusNotif-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionsStatusNotif-test.tsx index d86c8ac266c..4275351147c 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionsStatusNotif-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionsStatusNotif-test.tsx @@ -36,6 +36,7 @@ it('should display an in progress notif', () => { const wrapper = shallow( <EditionsStatusNotif editionStatus={{ installationStatus: 'AUTOMATIC_IN_PROGRESS' }} + readOnly={false} updateEditionStatus={jest.fn()} /> ); @@ -46,6 +47,7 @@ it('should display a ready notification', () => { const wrapper = shallow( <EditionsStatusNotif editionStatus={{ installationStatus: 'AUTOMATIC_READY' }} + readOnly={false} updateEditionStatus={jest.fn()} /> ); @@ -56,6 +58,7 @@ it('should display install errors', () => { const wrapper = shallow( <EditionsStatusNotif editionStatus={{ installationStatus: 'AUTOMATIC_IN_PROGRESS', installError: 'Foo error' }} + readOnly={false} updateEditionStatus={jest.fn()} /> ); @@ -67,6 +70,7 @@ it('should allow to dismiss install errors', async () => { const wrapper = shallow( <EditionsStatusNotif editionStatus={{ installationStatus: 'NONE', installError: 'Foo error' }} + readOnly={false} updateEditionStatus={updateEditionStatus} /> ); |