refactors to avoid using useParams where possible
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import { Progress } from '@backstage/core-components';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { ScorecardInfo } from '../ScorecardsInfo';
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
import { techInsightsApiRef } from '../../api/TechInsightsApi';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { getCompoundEntityRef } from '@backstage/catalog-model';
|
||||
|
||||
export const ScorecardsCard = (props: {
|
||||
title?: string;
|
||||
@@ -30,7 +31,7 @@ export const ScorecardsCard = (props: {
|
||||
}) => {
|
||||
const { title, description, checksId } = props;
|
||||
const api = useApi(techInsightsApiRef);
|
||||
const { namespace, kind, name } = useParams();
|
||||
const { namespace, kind, name } = getCompoundEntityRef(useEntity().entity);
|
||||
const { value, loading, error } = useAsync(
|
||||
async () => await api.runChecks({ namespace, kind, name }, checksId),
|
||||
);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import { Content, Page, Progress } from '@backstage/core-components';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
@@ -23,6 +22,8 @@ import { ScorecardInfo } from '../ScorecardsInfo';
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
import { techInsightsApiRef } from '../../api/TechInsightsApi';
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { getCompoundEntityRef } from '@backstage/catalog-model';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
contentScorecards: {
|
||||
@@ -39,7 +40,7 @@ export const ScorecardsContent = (props: {
|
||||
const { title, description, checksId } = props;
|
||||
const classes = useStyles();
|
||||
const api = useApi(techInsightsApiRef);
|
||||
const { namespace, kind, name } = useParams();
|
||||
const { namespace, kind, name } = getCompoundEntityRef(useEntity().entity);
|
||||
const { value, loading, error } = useAsync(
|
||||
async () => await api.runChecks({ namespace, kind, name }, checksId),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user