chore: refactor the query string building a little
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
||||
ScaffolderTask,
|
||||
TasksOwnerFilterKind,
|
||||
} from './types';
|
||||
import queryString from 'qs';
|
||||
|
||||
/**
|
||||
* Utility API reference for the {@link ScaffolderApi}.
|
||||
@@ -77,12 +78,11 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
|
||||
async listTasks(createdBy: TasksOwnerFilterKind): Promise<ScaffolderTask[]> {
|
||||
const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');
|
||||
const { userEntityRef } = await this.identityApi.getBackstageIdentity();
|
||||
|
||||
let query = '';
|
||||
if (createdBy === 'owned') {
|
||||
const { userEntityRef } = await this.identityApi.getBackstageIdentity();
|
||||
query = `createdBy=${encodeURIComponent(userEntityRef)}`;
|
||||
}
|
||||
const query = queryString.stringify(
|
||||
createdBy === 'owned' ? { createdBy: userEntityRef } : {},
|
||||
);
|
||||
|
||||
const url = `${baseUrl}/v2/tasks?${query}`;
|
||||
|
||||
|
||||
@@ -24,10 +24,7 @@ import {
|
||||
Progress,
|
||||
} from '@backstage/core-components';
|
||||
import { useApi, useRouteRef } from '@backstage/core-plugin-api';
|
||||
import {
|
||||
CatalogFilterLayout,
|
||||
EntityRefLink,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { CatalogFilterLayout } from '@backstage/plugin-catalog-react';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import MaterialTable from '@material-table/core';
|
||||
import React, { useState } from 'react';
|
||||
@@ -41,7 +38,6 @@ import {
|
||||
TaskStatusColumn,
|
||||
TemplateTitleColumn,
|
||||
} from './columns';
|
||||
import { parseEntityRef } from '@backstage/catalog-model';
|
||||
|
||||
export interface MyTaskPageProps {
|
||||
initiallySelectedFilter?: TasksOwnerFilterKind;
|
||||
|
||||
Reference in New Issue
Block a user