sonarqube: port to new composability API
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
Progress,
|
||||
useApi,
|
||||
} from '@backstage/core';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { Chip, Grid } from '@material-ui/core';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import BugReport from '@material-ui/icons/BugReport';
|
||||
@@ -69,10 +70,10 @@ const useStyles = makeStyles(theme => ({
|
||||
},
|
||||
}));
|
||||
|
||||
interface DuplicationRating {
|
||||
type DuplicationRating = {
|
||||
greaterThan: number;
|
||||
rating: '1.0' | '2.0' | '3.0' | '4.0' | '5.0';
|
||||
}
|
||||
};
|
||||
|
||||
const defaultDuplicationRatings: DuplicationRating[] = [
|
||||
{ greaterThan: 0, rating: '1.0' },
|
||||
@@ -83,14 +84,14 @@ const defaultDuplicationRatings: DuplicationRating[] = [
|
||||
];
|
||||
|
||||
export const SonarQubeCard = ({
|
||||
entity,
|
||||
variant = 'gridItem',
|
||||
duplicationRatings = defaultDuplicationRatings,
|
||||
}: {
|
||||
entity: Entity;
|
||||
entity?: Entity;
|
||||
variant?: string;
|
||||
duplicationRatings?: DuplicationRating[];
|
||||
}) => {
|
||||
const { entity } = useEntity();
|
||||
const sonarQubeApi = useApi(sonarQubeApiRef);
|
||||
|
||||
const projectTitle = useProjectKey(entity);
|
||||
|
||||
@@ -15,4 +15,8 @@
|
||||
*/
|
||||
|
||||
export * from './components';
|
||||
export { plugin } from './plugin';
|
||||
export {
|
||||
sonarQubePlugin,
|
||||
sonarQubePlugin as plugin,
|
||||
EntitySonarQubeCard,
|
||||
} from './plugin';
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { plugin } from './plugin';
|
||||
import { sonarQubePlugin } from './plugin';
|
||||
|
||||
describe('sonarqube', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(plugin).toBeDefined();
|
||||
expect(sonarQubePlugin).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
import {
|
||||
configApiRef,
|
||||
createApiFactory,
|
||||
createComponentExtension,
|
||||
createPlugin,
|
||||
discoveryApiRef,
|
||||
} from '@backstage/core';
|
||||
import { sonarQubeApiRef, SonarQubeClient } from './api';
|
||||
|
||||
export const plugin = createPlugin({
|
||||
export const sonarQubePlugin = createPlugin({
|
||||
id: 'sonarqube',
|
||||
apis: [
|
||||
createApiFactory({
|
||||
@@ -36,3 +37,12 @@ export const plugin = createPlugin({
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
export const EntitySonarQubeCard = sonarQubePlugin.provide(
|
||||
createComponentExtension({
|
||||
component: {
|
||||
lazy: () =>
|
||||
import('./components/SonarQubeCard').then(m => m.SonarQubeCard),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user