import { sortBy, uniqBy } from 'lodash';
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
+import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
import { translate } from 'sonar-ui-common/helpers/l10n';
import {
getAvailablePlugins,
updateCenterActive={this.props.updateCenterActive}
updateQuery={this.updateQuery}
/>
- {loadingPlugins && <i className="spinner" />}
- {!loadingPlugins && (
- <PluginsList
- pending={pendingPlugins}
- plugins={filteredPlugins}
- readOnly={!standaloneMode}
- refreshPending={this.props.fetchPendingPlugins}
- />
- )}
- {!loadingPlugins && <Footer total={filteredPlugins.length} />}
+ <DeferredSpinner loading={loadingPlugins}>
+ {filteredPlugins.length === 0 &&
+ translate('marketplace.plugin_list.no_plugins', query.filter)}
+ {filteredPlugins.length > 0 && (
+ <>
+ <PluginsList
+ pending={pendingPlugins}
+ plugins={filteredPlugins}
+ readOnly={!standaloneMode}
+ refreshPending={this.props.fetchPendingPlugins}
+ />
+ <Footer total={filteredPlugins.length} />
+ </>
+ )}
+ </DeferredSpinner>
</div>
);
}
import { mockLocation, mockRouter } from '../../../helpers/testMocks';
import { App } from '../App';
-jest.mock('../../../api/plugins', () => ({
- getAvailablePlugins: jest.fn().mockResolvedValue({ plugins: [] }),
- getInstalledPlugins: jest.fn().mockResolvedValue([]),
- getInstalledPluginsWithUpdates: jest.fn().mockResolvedValue([]),
- getPluginUpdates: jest.fn().mockResolvedValue([])
-}));
+jest.mock('../../../api/plugins', () => {
+ const plugin = jest.requireActual('../../../helpers/mocks/plugins').mockPlugin();
+
+ return {
+ getAvailablePlugins: jest.fn().mockResolvedValue({ plugins: [plugin] }),
+ getInstalledPlugins: jest.fn().mockResolvedValue([]),
+ getInstalledPluginsWithUpdates: jest.fn().mockResolvedValue([]),
+ getPluginUpdates: jest.fn().mockResolvedValue([])
+ };
+});
beforeEach(jest.clearAllMocks);
-it('should render correctly', () => {
+it('should render correctly', async () => {
const wrapper = shallowRender();
expect(wrapper).toMatchSnapshot('loading');
- expect(wrapper.setState({ loadingPlugins: false })).toMatchSnapshot('loaded');
+
+ await waitAndUpdate(wrapper);
+ expect(wrapper).toMatchSnapshot('loaded');
});
it('should fetch plugin info', async () => {
updateCenterActive={false}
updateQuery={[Function]}
/>
- <PluginsList
- pending={
- Object {
- "installing": Array [],
- "removing": Array [],
- "updating": Array [],
+ <DeferredSpinner
+ loading={false}
+ >
+ <PluginsList
+ pending={
+ Object {
+ "installing": Array [],
+ "removing": Array [],
+ "updating": Array [],
+ }
}
- }
- plugins={Array []}
- readOnly={true}
- refreshPending={[MockFunction]}
- />
- <Footer
- total={0}
- />
+ plugins={
+ Array [
+ Object {
+ "key": "sonar-foo",
+ "name": "Sonar Foo",
+ },
+ ]
+ }
+ readOnly={true}
+ refreshPending={[MockFunction]}
+ />
+ <Footer
+ total={1}
+ />
+ </DeferredSpinner>
</div>
`;
updateCenterActive={false}
updateQuery={[Function]}
/>
- <i
- className="spinner"
- />
+ <DeferredSpinner
+ loading={true}
+ >
+ marketplace.plugin_list.no_plugins.all
+ </DeferredSpinner>
</div>
`;
marketplace.page.you_are_running.datacenter=You are currently running a Data Center Edition.
marketplace.page.plugins=Plugins
marketplace.page.plugins.description=Plugins available in the MarketPlace are not provided or supported by SonarSource. Please reach out directly to their maintainers for support.
+marketplace.plugin_list.no_plugins.all=No installed plugins or updates available
+marketplace.plugin_list.no_plugins.installed=No installed plugins
+marketplace.plugin_list.no_plugins.updates=No plugin updates available
marketplace.instance_needs_to_be_restarted_to={instance} needs to be restarted in order to
marketplace.install_x_plugins=install {nb} plugins
marketplace.update_x_plugins=update {nb} plugins