From dfbe698743d83672e4d0092d46e77a451a676cfa Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Mon, 13 Feb 2023 09:38:48 -0500 Subject: [PATCH] chore(review): address comments Signed-off-by: Phil Kuang --- .github/CODEOWNERS | 2 ++ plugins/entity-feedback-backend/package.json | 2 +- .../src/service/DatabaseHandler.ts | 9 +++++--- plugins/entity-feedback-common/api-report.md | 23 +++++++++---------- plugins/entity-feedback-common/package.json | 2 +- plugins/entity-feedback-common/src/index.ts | 2 +- plugins/entity-feedback/api-report.md | 14 +++++++---- plugins/entity-feedback/package.json | 2 +- .../src/api/EntityFeedbackApi.ts | 8 ++++--- .../src/api/EntityFeedbackClient.ts | 6 ++--- .../FeedbackResponseTable.tsx | 4 ++-- 11 files changed, 42 insertions(+), 32 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bb6f8da19b..d4d5f91a0d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -37,6 +37,8 @@ yarn.lock @backstage/maintainers @back /plugins/code-coverage-backend @backstage/maintainers @alde @nissayeva /plugins/cost-insights @backstage/maintainers @backstage/silver-lining /plugins/cost-insights-* @backstage/maintainers @backstage/silver-lining +/plugins/entity-feedback @backstage/maintainers @kuangp +/plugins/entity-feedback-* @backstage/maintainers @kuangp /plugins/events-backend @backstage/maintainers @pjungermann /plugins/events-backend-module-aws-sqs @backstage/maintainers @pjungermann /plugins/events-backend-module-azure @backstage/maintainers @pjungermann diff --git a/plugins/entity-feedback-backend/package.json b/plugins/entity-feedback-backend/package.json index 487d5f5d5e..7fbc7b9f7e 100644 --- a/plugins/entity-feedback-backend/package.json +++ b/plugins/entity-feedback-backend/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-entity-feedback-backend", - "version": "0.1.0", + "version": "0.0.0", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/plugins/entity-feedback-backend/src/service/DatabaseHandler.ts b/plugins/entity-feedback-backend/src/service/DatabaseHandler.ts index aeeaffd694..9b81cd94bb 100644 --- a/plugins/entity-feedback-backend/src/service/DatabaseHandler.ts +++ b/plugins/entity-feedback-backend/src/service/DatabaseHandler.ts @@ -15,7 +15,10 @@ */ import { resolvePackagePath } from '@backstage/backend-common'; -import { Rating, Response } from '@backstage/plugin-entity-feedback-common'; +import { + FeedbackResponse, + Rating, +} from '@backstage/plugin-entity-feedback-common'; import { Knex } from 'knex'; const migrationsDir = resolvePackagePath( @@ -119,7 +122,7 @@ export class DatabaseHandler { ).map(rating => ({ userRef: rating.user_ref, rating: rating.rating })); } - async recordResponse(response: Response) { + async recordResponse(response: FeedbackResponse) { await this.database('responses').insert({ entity_ref: response.entityRef, response: response.response, @@ -131,7 +134,7 @@ export class DatabaseHandler { async getResponses( entityRef: string, - ): Promise[]> { + ): Promise[]> { return ( await this.database('responses') .where('entity_ref', entityRef) diff --git a/plugins/entity-feedback-common/api-report.md b/plugins/entity-feedback-common/api-report.md index 35da32c1da..118e6c78f2 100644 --- a/plugins/entity-feedback-common/api-report.md +++ b/plugins/entity-feedback-common/api-report.md @@ -16,17 +16,7 @@ export interface EntityRatingsData { } // @public (undocumented) -export interface Rating { - // (undocumented) - entityRef: string; - // (undocumented) - rating: string; - // (undocumented) - userRef: string; -} - -// @public (undocumented) -interface Response_2 { +export interface FeedbackResponse { // (undocumented) comments?: string; // (undocumented) @@ -38,5 +28,14 @@ interface Response_2 { // (undocumented) userRef: string; } -export { Response_2 as Response }; + +// @public (undocumented) +export interface Rating { + // (undocumented) + entityRef: string; + // (undocumented) + rating: string; + // (undocumented) + userRef: string; +} ``` diff --git a/plugins/entity-feedback-common/package.json b/plugins/entity-feedback-common/package.json index 45a5a2b131..6316b72943 100644 --- a/plugins/entity-feedback-common/package.json +++ b/plugins/entity-feedback-common/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/plugin-entity-feedback-common", "description": "Common functionalities for the entity-feedback plugin", - "version": "0.1.0", + "version": "0.0.0", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/plugins/entity-feedback-common/src/index.ts b/plugins/entity-feedback-common/src/index.ts index f19fcdd648..eea289a899 100644 --- a/plugins/entity-feedback-common/src/index.ts +++ b/plugins/entity-feedback-common/src/index.ts @@ -32,7 +32,7 @@ export interface Rating { /** * @public */ -export interface Response { +export interface FeedbackResponse { entityRef: string; response?: string; comments?: string; diff --git a/plugins/entity-feedback/api-report.md b/plugins/entity-feedback/api-report.md index 399e84e674..06b0166b0d 100644 --- a/plugins/entity-feedback/api-report.md +++ b/plugins/entity-feedback/api-report.md @@ -10,10 +10,10 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { EntityRatingsData } from '@backstage/plugin-entity-feedback-common'; +import { FeedbackResponse } from '@backstage/plugin-entity-feedback-common'; import { FetchApi } from '@backstage/core-plugin-api'; import { Rating } from '@backstage/plugin-entity-feedback-common'; import { ReactNode } from 'react'; -import { Response as Response_2 } from '@backstage/plugin-entity-feedback-common'; import { RouteRef } from '@backstage/core-plugin-api'; // @public (undocumented) @@ -25,13 +25,15 @@ export interface EntityFeedbackApi { // (undocumented) getRatings(entityRef: string): Promise[]>; // (undocumented) - getResponses(entityRef: string): Promise[]>; + getResponses( + entityRef: string, + ): Promise[]>; // (undocumented) recordRating(entityRef: string, rating: string): Promise; // (undocumented) recordResponse( entityRef: string, - response: Omit, + response: Omit, ): Promise; } @@ -48,13 +50,15 @@ export class EntityFeedbackClient implements EntityFeedbackApi { // (undocumented) getRatings(entityRef: string): Promise[]>; // (undocumented) - getResponses(entityRef: string): Promise[]>; + getResponses( + entityRef: string, + ): Promise[]>; // (undocumented) recordRating(entityRef: string, rating: string): Promise; // (undocumented) recordResponse( entityRef: string, - response: Omit, + response: Omit, ): Promise; } diff --git a/plugins/entity-feedback/package.json b/plugins/entity-feedback/package.json index 6d71b04cc2..f8560a9237 100644 --- a/plugins/entity-feedback/package.json +++ b/plugins/entity-feedback/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-entity-feedback", - "version": "0.1.0", + "version": "0.0.0", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/plugins/entity-feedback/src/api/EntityFeedbackApi.ts b/plugins/entity-feedback/src/api/EntityFeedbackApi.ts index f8f6b4fccc..d2f1a46f55 100644 --- a/plugins/entity-feedback/src/api/EntityFeedbackApi.ts +++ b/plugins/entity-feedback/src/api/EntityFeedbackApi.ts @@ -17,8 +17,8 @@ import { createApiRef } from '@backstage/core-plugin-api'; import { EntityRatingsData, + FeedbackResponse, Rating, - Response, } from '@backstage/plugin-entity-feedback-common'; /** @@ -42,8 +42,10 @@ export interface EntityFeedbackApi { recordResponse( entityRef: string, - response: Omit, + response: Omit, ): Promise; - getResponses(entityRef: string): Promise[]>; + getResponses( + entityRef: string, + ): Promise[]>; } diff --git a/plugins/entity-feedback/src/api/EntityFeedbackClient.ts b/plugins/entity-feedback/src/api/EntityFeedbackClient.ts index 43d3cbe95a..34856473c8 100644 --- a/plugins/entity-feedback/src/api/EntityFeedbackClient.ts +++ b/plugins/entity-feedback/src/api/EntityFeedbackClient.ts @@ -18,8 +18,8 @@ import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api'; import { ResponseError } from '@backstage/errors'; import { EntityRatingsData, + FeedbackResponse, Rating, - Response, } from '@backstage/plugin-entity-feedback-common'; import { EntityFeedbackApi } from './EntityFeedbackApi'; @@ -99,7 +99,7 @@ export class EntityFeedbackClient implements EntityFeedbackApi { async recordResponse( entityRef: string, - response: Omit, + response: Omit, ) { const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback'); const resp = await this.fetchApi.fetch( @@ -118,7 +118,7 @@ export class EntityFeedbackClient implements EntityFeedbackApi { async getResponses( entityRef: string, - ): Promise[]> { + ): Promise[]> { const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback'); const resp = await this.fetchApi.fetch( `${baseUrl}/responses/${encodeURIComponent(entityRef)}`, diff --git a/plugins/entity-feedback/src/components/FeedbackResponseTable/FeedbackResponseTable.tsx b/plugins/entity-feedback/src/components/FeedbackResponseTable/FeedbackResponseTable.tsx index 2bc03b8537..ba954c7747 100644 --- a/plugins/entity-feedback/src/components/FeedbackResponseTable/FeedbackResponseTable.tsx +++ b/plugins/entity-feedback/src/components/FeedbackResponseTable/FeedbackResponseTable.tsx @@ -18,7 +18,7 @@ import { parseEntityRef } from '@backstage/catalog-model'; import { ErrorPanel, Table } from '@backstage/core-components'; import { useApi } from '@backstage/core-plugin-api'; import { humanizeEntityRef } from '@backstage/plugin-catalog-react'; -import { Response } from '@backstage/plugin-entity-feedback-common'; +import { FeedbackResponse } from '@backstage/plugin-entity-feedback-common'; import { BackstageTheme } from '@backstage/theme'; import { Chip, makeStyles } from '@material-ui/core'; import CheckIcon from '@material-ui/icons/Check'; @@ -27,7 +27,7 @@ import useAsync from 'react-use/lib/useAsync'; import { entityFeedbackApiRef } from '../../api'; -type ResponseRow = Omit; +type ResponseRow = Omit; const useStyles = makeStyles(theme => ({ consentCheck: {