const query = parseQuery(this.props.location.query);
const filteredPlugins = filterPlugins(plugins, query.search);
+ /*
+ * standalone mode is true when cluster mode is not active. We preserve this
+ * condition if it ever becomes possible to have a community edition NOT in standalone mode.
+ */
+ const allowActions =
+ currentEdition === EditionKey.community &&
+ Boolean(standaloneMode) &&
+ riskConsent === RiskConsent.Accepted;
+
return (
<div className="page page-limited" id="marketplace-page">
<Suggestions suggestions="marketplace" />
<PluginsList
pending={pendingPlugins}
plugins={filteredPlugins}
- readOnly={!standaloneMode || riskConsent !== RiskConsent.Accepted}
+ readOnly={!allowActions}
refreshPending={this.props.fetchPendingPlugins}
/>
<Footer total={filteredPlugins.length} />
} from '../../../api/plugins';
import { getValues, setSimpleSettingValue } from '../../../api/settings';
import { mockLocation, mockRouter } from '../../../helpers/testMocks';
+import { EditionKey } from '../../../types/editions';
import { RiskConsent } from '../../../types/plugins';
import { SettingsKey } from '../../../types/settings';
import { App } from '../App';
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot('loaded');
+
+ wrapper.setProps({ currentEdition: EditionKey.community, standaloneMode: true });
+ wrapper.setState({ riskConsent: RiskConsent.Accepted });
+
+ expect(wrapper).toMatchSnapshot('not readonly');
});
it('should handle accepting the risk', async () => {
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly: loaded 1`] = `
+<div
+ className="page page-limited"
+ id="marketplace-page"
+>
+ <Suggestions
+ suggestions="marketplace"
+ />
+ <Helmet
+ defer={true}
+ encodeSpecialCharacters={true}
+ title="marketplace.page"
+ />
+ <Header
+ currentEdition="developer"
+ />
+ <EditionBoxes
+ currentEdition="developer"
+ />
+ <header
+ className="page-header"
+ >
+ <h1
+ className="page-title"
+ >
+ marketplace.page.plugins
+ </h1>
+ <div
+ className="page-description"
+ >
+ <p>
+ marketplace.page.plugins.description
+ </p>
+ <p
+ className="spacer-top"
+ >
+ <FormattedMessage
+ defaultMessage="marketplace.page.plugins.description2"
+ id="marketplace.page.plugins.description2"
+ values={
+ Object {
+ "link": <Link
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ target="_blank"
+ to="/documentation/instance-administration/marketplace/"
+ >
+ marketplace.page.plugins.description2.link
+ </Link>,
+ }
+ }
+ />
+ </p>
+ </div>
+ </header>
+ <PluginRiskConsentBox
+ acknowledgeRisk={[Function]}
+ currentEdition="developer"
+ />
+ <Search
+ query={
+ Object {
+ "filter": "all",
+ "search": "",
+ }
+ }
+ updateCenterActive={false}
+ updateQuery={[Function]}
+ />
+ <DeferredSpinner
+ loading={false}
+ >
+ <PluginsList
+ pending={
+ Object {
+ "installing": Array [],
+ "removing": Array [],
+ "updating": Array [],
+ }
+ }
+ plugins={
+ Array [
+ Object {
+ "key": "sonar-foo",
+ "name": "Sonar Foo",
+ },
+ ]
+ }
+ readOnly={true}
+ refreshPending={[MockFunction]}
+ />
+ <Footer
+ total={1}
+ />
+ </DeferredSpinner>
+</div>
+`;
+
+exports[`should render correctly: loading 1`] = `
+<div
+ className="page page-limited"
+ id="marketplace-page"
+>
+ <Suggestions
+ suggestions="marketplace"
+ />
+ <Helmet
+ defer={true}
+ encodeSpecialCharacters={true}
+ title="marketplace.page"
+ />
+ <Header
+ currentEdition="developer"
+ />
+ <EditionBoxes
+ currentEdition="developer"
+ />
+ <header
+ className="page-header"
+ >
+ <h1
+ className="page-title"
+ >
+ marketplace.page.plugins
+ </h1>
+ <div
+ className="page-description"
+ >
+ <p>
+ marketplace.page.plugins.description
+ </p>
+ <p
+ className="spacer-top"
+ >
+ <FormattedMessage
+ defaultMessage="marketplace.page.plugins.description2"
+ id="marketplace.page.plugins.description2"
+ values={
+ Object {
+ "link": <Link
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ target="_blank"
+ to="/documentation/instance-administration/marketplace/"
+ >
+ marketplace.page.plugins.description2.link
+ </Link>,
+ }
+ }
+ />
+ </p>
+ </div>
+ </header>
+ <PluginRiskConsentBox
+ acknowledgeRisk={[Function]}
+ currentEdition="developer"
+ />
+ <Search
+ query={
+ Object {
+ "filter": "all",
+ "search": "",
+ }
+ }
+ updateCenterActive={false}
+ updateQuery={[Function]}
+ />
+ <DeferredSpinner
+ loading={true}
+ >
+ marketplace.plugin_list.no_plugins.all
+ </DeferredSpinner>
+</div>
+`;
+
+exports[`should render correctly: not readonly 1`] = `
+<div
+ className="page page-limited"
+ id="marketplace-page"
+>
+ <Suggestions
+ suggestions="marketplace"
+ />
+ <Helmet
+ defer={true}
+ encodeSpecialCharacters={true}
+ title="marketplace.page"
+ />
+ <Header
+ currentEdition="community"
+ />
+ <EditionBoxes
+ currentEdition="community"
+ />
+ <header
+ className="page-header"
+ >
+ <h1
+ className="page-title"
+ >
+ marketplace.page.plugins
+ </h1>
+ <div
+ className="page-description"
+ >
+ <p>
+ marketplace.page.plugins.description
+ </p>
+ </div>
+ </header>
+ <PluginRiskConsentBox
+ acknowledgeRisk={[Function]}
+ currentEdition="community"
+ riskConsent="ACCEPTED"
+ />
+ <Search
+ query={
+ Object {
+ "filter": "all",
+ "search": "",
+ }
+ }
+ updateCenterActive={false}
+ updateQuery={[Function]}
+ />
+ <DeferredSpinner
+ loading={false}
+ >
+ <PluginsList
+ pending={
+ Object {
+ "installing": Array [],
+ "removing": Array [],
+ "updating": Array [],
+ }
+ }
+ plugins={
+ Array [
+ Object {
+ "key": "sonar-foo",
+ "name": "Sonar Foo",
+ },
+ ]
+ }
+ readOnly={false}
+ refreshPending={[MockFunction]}
+ />
+ <Footer
+ total={1}
+ />
+ </DeferredSpinner>
+</div>
+`;