Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: detail page tab routing (#8) #9

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions workspaces/resource-optimization/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"fix": "backstage-cli repo fix",
"lint": "backstage-cli repo lint --since origin/main",
"lint:all": "backstage-cli repo lint",
"format": "prettier --write .",
"prettier:check": "prettier --check .",
"new": "backstage-cli new --scope @backstage-community",
"export-dynamic": "yarn workspaces foreach -A run export-dynamic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export type OptimizationsApi = Omit<
>;

// @public
export class OptimizationsClient implements OptimizationsApi {
export class OptimizationsApiClient implements OptimizationsApi {
constructor(options: { discoveryApi: DiscoveryApi; fetchApi: FetchApi });
// (undocumented)
getRecommendationById(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@
},
"typesVersions": {
"*": {
".": [
"./src/index.ts"
],
"./package.json": [
"./package.json"
"package.json": [
"package.json"
]
}
},
"license": "Apache-2.0",
"private": true,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts"
"access": "public"
},
"backstage": {
"role": "common-library"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ function patchPathRecommendationsList(spec) {

const RECOMMENDATIONS_LIST_PATH = '/recommendations/openshift';
const recommendationsListDef = spec.paths[RECOMMENDATIONS_LIST_PATH];

// We delete the tags to prevent the generator from making a module
// named apis/OrchestratorApi.client.ts that doesn't get exposed
// properly by the generator.
delete recommendationsListDef.get.tags;

const { parameters = [] } = recommendationsListDef.get;
const problematicParams = parameters.filter(p =>
PROBLEMATIC_QUERY_PARAM_NAMES.test(p.name),
Expand Down Expand Up @@ -68,12 +68,12 @@ function patchPathRecommendationsById(spec) {
const recommendationsByIdDef = structuredClone(
spec.paths[RECOMMENDATION_BY_ID_PATH],
);

// We delete the tags to prevent the generator from making a module
// named apis/OrchestratorApi.client.ts that doesn't get exposed
// properly by the generator.
delete recommendationsByIdDef.get.tags;

const { parameters = [] } = recommendationsByIdDef.get;
for (const parameter of parameters) {
parameter.name = parameter.name.replace('-', '_');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* This is a copy of GetTokenResponse, to avoid importing resource-optimization-backend.
*
*
* @public
*/
export interface GetTokenResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ paths:
summary: Get all recommendations
description: This feature is in limited preview for select customers
externalDocs:
description: Please refer to this blog post if you want to be included in the
description:
Please refer to this blog post if you want to be included in the
preview
url: https://www.redhat.com/en/blog/red-hat-insights-brings-resource-optimization-red-hat-openshift
operationId: getRecommendationList
Expand All @@ -27,7 +28,8 @@ paths:
type: string
- name: workload_type
in: query
description: Options are daemonset, deployment, deploymentconfig, replicaset,
description:
Options are daemonset, deployment, deploymentconfig, replicaset,
replicationcontroller, statefulset
required: false
schema:
Expand Down Expand Up @@ -89,7 +91,8 @@ paths:
maximum: 100
- name: order_by
in: query
description: Options are cluster, project, workload_type, workload, container,
description:
Options are cluster, project, workload_type, workload, container,
last_reported
required: false
schema:
Expand All @@ -103,13 +106,13 @@ paths:
type: string
example: DESC
responses:
"200":
'200':
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/RecommendationList"
"401":
$ref: '#/components/schemas/RecommendationList'
'401':
description: User is not authorized
content:
text/plain:
Expand All @@ -120,7 +123,8 @@ paths:
get:
description: This feature is in limited preview for select customers
externalDocs:
description: Please refer to this blog post if you want to be included in the
description:
Please refer to this blog post if you want to be included in the
preview
url: https://www.redhat.com/en/blog/red-hat-insights-brings-resource-optimization-red-hat-openshift
operationId: getRecommendationById
Expand Down Expand Up @@ -154,13 +158,13 @@ paths:
default: cores
summary: Get recommendation for container
responses:
"200":
'200':
description: OK
content:
application/json; charset=UTF-8:
schema:
$ref: "#/components/schemas/RecommendationBoxPlots"
"401":
$ref: '#/components/schemas/RecommendationBoxPlots'
'401':
description: User is not authorized
content:
text/plain:
Expand All @@ -175,7 +179,7 @@ components:
data:
type: array
items:
$ref: "#/components/schemas/Recommendations"
$ref: '#/components/schemas/Recommendations'
meta:
type: object
properties:
Expand Down Expand Up @@ -279,11 +283,11 @@ components:
type: object
properties:
long_term:
$ref: "#/components/schemas/LongTermRecommendation"
$ref: '#/components/schemas/LongTermRecommendation'
medium_term:
$ref: "#/components/schemas/MediumTermRecommendation"
$ref: '#/components/schemas/MediumTermRecommendation'
short_term:
$ref: "#/components/schemas/ShortTermRecommendation"
$ref: '#/components/schemas/ShortTermRecommendation'
source_id:
type: string
example: 0920ff0d-f1d6-4fe2-8bf3-18e6074bd27b
Expand All @@ -308,9 +312,9 @@ components:
type: object
properties:
cost:
$ref: "#/components/schemas/CostRecommendation"
$ref: '#/components/schemas/CostRecommendation'
performance:
$ref: "#/components/schemas/PerformanceRecommendation"
$ref: '#/components/schemas/PerformanceRecommendation'
MediumTermRecommendation:
type: object
properties:
Expand All @@ -326,9 +330,9 @@ components:
type: object
properties:
cost:
$ref: "#/components/schemas/CostRecommendation"
$ref: '#/components/schemas/CostRecommendation'
performance:
$ref: "#/components/schemas/PerformanceRecommendation"
$ref: '#/components/schemas/PerformanceRecommendation'
ShortTermRecommendation:
type: object
properties:
Expand All @@ -344,9 +348,9 @@ components:
type: object
properties:
cost:
$ref: "#/components/schemas/CostRecommendation"
$ref: '#/components/schemas/CostRecommendation'
performance:
$ref: "#/components/schemas/PerformanceRecommendation"
$ref: '#/components/schemas/PerformanceRecommendation'
CostRecommendation:
type: object
properties:
Expand Down Expand Up @@ -626,11 +630,11 @@ components:
type: object
properties:
long_term:
$ref: "#/components/schemas/LongTermRecommendationBoxPlots"
$ref: '#/components/schemas/LongTermRecommendationBoxPlots'
medium_term:
$ref: "#/components/schemas/MediumTermRecommendationBoxPlots"
$ref: '#/components/schemas/MediumTermRecommendationBoxPlots'
short_term:
$ref: "#/components/schemas/ShortTermRecommendationBoxPlots"
$ref: '#/components/schemas/ShortTermRecommendationBoxPlots'
source_id:
type: string
example: 0920ff0d-f1d6-4fe2-8bf3-18e6074bd27b
Expand All @@ -652,14 +656,14 @@ components:
format: date-time
example: 2023-06-02T00:45:00Z
plots:
$ref: "#/components/schemas/PlotsData"
$ref: '#/components/schemas/PlotsData'
recommendation_engines:
type: object
properties:
cost:
$ref: "#/components/schemas/CostRecommendation"
$ref: '#/components/schemas/CostRecommendation'
performance:
$ref: "#/components/schemas/PerformanceRecommendation"
$ref: '#/components/schemas/PerformanceRecommendation'
MediumTermRecommendationBoxPlots:
type: object
properties:
Expand All @@ -672,14 +676,14 @@ components:
format: date-time
example: 2023-06-02T00:45:00Z
plots:
$ref: "#/components/schemas/PlotsData"
$ref: '#/components/schemas/PlotsData'
recommendation_engines:
type: object
properties:
cost:
$ref: "#/components/schemas/CostRecommendation"
$ref: '#/components/schemas/CostRecommendation'
performance:
$ref: "#/components/schemas/PerformanceRecommendation"
$ref: '#/components/schemas/PerformanceRecommendation'
ShortTermRecommendationBoxPlots:
type: object
properties:
Expand All @@ -692,31 +696,31 @@ components:
format: date-time
example: 2023-06-02T00:45:00Z
plots:
$ref: "#/components/schemas/PlotsData"
$ref: '#/components/schemas/PlotsData'
recommendation_engines:
type: object
properties:
cost:
$ref: "#/components/schemas/CostRecommendation"
$ref: '#/components/schemas/CostRecommendation'
performance:
$ref: "#/components/schemas/PerformanceRecommendation"
$ref: '#/components/schemas/PerformanceRecommendation'
PlotsData:
type: object
properties:
datapoints:
type: integer
example: 4
plots_data:
$ref: "#/components/schemas/PlotDetails"
$ref: '#/components/schemas/PlotDetails'
PlotDetails:
type: object
additionalProperties:
type: object
properties:
cpuUsage:
$ref: "#/components/schemas/cpuUsage"
$ref: '#/components/schemas/cpuUsage'
memoryUsage:
$ref: "#/components/schemas/memoryUsage"
$ref: '#/components/schemas/memoryUsage'
cpuUsage:
type: object
properties:
Expand All @@ -725,31 +729,31 @@ components:
example: null
nullable: true
max:
$ref: "#/components/schemas/cpuUsageFloatComponent"
$ref: '#/components/schemas/cpuUsageFloatComponent'
median:
$ref: "#/components/schemas/cpuUsageFloatComponent"
$ref: '#/components/schemas/cpuUsageFloatComponent'
min:
$ref: "#/components/schemas/cpuUsageFloatComponent"
$ref: '#/components/schemas/cpuUsageFloatComponent'
q1:
$ref: "#/components/schemas/cpuUsageFloatComponent"
$ref: '#/components/schemas/cpuUsageFloatComponent'
q3:
$ref: "#/components/schemas/cpuUsageFloatComponent"
$ref: '#/components/schemas/cpuUsageFloatComponent'
memoryUsage:
type: object
properties:
format:
type: string
example: Mi
max:
$ref: "#/components/schemas/memoryUsageFloatComponent"
$ref: '#/components/schemas/memoryUsageFloatComponent'
median:
$ref: "#/components/schemas/memoryUsageFloatComponent"
$ref: '#/components/schemas/memoryUsageFloatComponent'
min:
$ref: "#/components/schemas/memoryUsageFloatComponent"
$ref: '#/components/schemas/memoryUsageFloatComponent'
q1:
$ref: "#/components/schemas/memoryUsageFloatComponent"
$ref: '#/components/schemas/memoryUsageFloatComponent'
q3:
$ref: "#/components/schemas/memoryUsageFloatComponent"
$ref: '#/components/schemas/memoryUsageFloatComponent'
cpuUsageFloatComponent:
type: number
example: 0.05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const ResourceOptimizationPage: Router;
export const resourceOptimizationPlugin: BackstagePlugin<
{
root: RouteRef<undefined>;
breakdown: SubRouteRef<PathParams<'/:id'>>;
breakdown: SubRouteRef<PathParams<'/:id/*'>>;
},
{},
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const rootRouteRef = createRouteRef({
export const optimizationsBreakdownRouteRef = createSubRouteRef({
id: 'ros.page.breakdown',
parent: rootRouteRef,
path: '/:id',
path: '/:id/*',
});
Loading