Introduce useRouteRefParams to core-api to retrieve typed route params

Signed-off-by: Oliver Sand <oliver.sand@sda-se.com>
This commit is contained in:
Oliver Sand
2021-03-18 15:48:29 +01:00
parent e3718ad406
commit 01ccef4c7f
9 changed files with 95 additions and 45 deletions
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useApi } from '@backstage/core';
import { useParams } from 'react-router-dom';
import { useApi, useRouteRefParams } from '@backstage/core';
import { useAsync } from 'react-use';
import { githubActionsApiRef } from '../../api';
import { buildRouteRef } from '../../plugin';
export const useWorkflowRunsDetails = ({
hostname,
@@ -28,7 +28,7 @@ export const useWorkflowRunsDetails = ({
repo: string;
}) => {
const api = useApi(githubActionsApiRef);
const { id } = useParams();
const { id } = useRouteRefParams(buildRouteRef);
const details = useAsync(async () => {
return repo && owner
? api.getWorkflowRun({
+1
View File
@@ -33,6 +33,7 @@ export const rootRouteRef = createRouteRef({
export const buildRouteRef = createRouteRef({
path: ':id',
params: ['id'],
title: 'GitHub Actions Workflow Run',
});