From 8746cb1f895cb176c5ddf701ecf76bf051fce1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Tue, 9 May 2023 14:39:28 +0100 Subject: [PATCH] fix: strategyId in edit strategy API command endpoint (#3725) Fixes a small issue where the "API Command" for edit strategy was showing the strategyId as `undefined`: `/api/admin/projects/demo-app/features/demoApp.step1/environments/dev/strategies/undefined'` ![image](https://github.com/Unleash/unleash/assets/14320932/19650a15-5cde-43c3-9d2b-a7e790bea0ac) --- .../FeatureStrategyEdit/FeatureStrategyEdit.test.tsx | 3 ++- .../FeatureStrategyEdit/FeatureStrategyEdit.tsx | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.test.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.test.tsx index b35a1fc096..b9e45b69eb 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.test.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.test.tsx @@ -31,12 +31,13 @@ test('formatUpdateStrategyApiCode', () => { 'projectId', 'featureId', 'environmentId', + 'strategyId', strategy, strategyDefinition, 'unleashUrl' ) ).toMatchInlineSnapshot(` - "curl --location --request PUT 'unleashUrl/api/admin/projects/projectId/features/featureId/environments/environmentId/strategies/a' \\\\ + "curl --location --request PUT 'unleashUrl/api/admin/projects/projectId/features/featureId/environments/environmentId/strategies/strategyId' \\\\ --header 'Authorization: INSERT_API_KEY' \\\\ --header 'Content-Type: application/json' \\\\ --data-raw '{ diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx index fa9a8350f9..056f4f6204 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx @@ -213,6 +213,7 @@ export const FeatureStrategyEdit = () => { projectId, featureId, environmentId, + strategyId, payload, strategyDefinition, unleashUrl @@ -272,6 +273,7 @@ export const formatUpdateStrategyApiCode = ( projectId: string, featureId: string, environmentId: string, + strategyId: string, strategy: Partial, strategyDefinition: IStrategy, unleashUrl?: string @@ -290,7 +292,7 @@ export const formatUpdateStrategyApiCode = ( ), }; - const url = `${unleashUrl}/api/admin/projects/${projectId}/features/${featureId}/environments/${environmentId}/strategies/${strategy.id}`; + const url = `${unleashUrl}/api/admin/projects/${projectId}/features/${featureId}/environments/${environmentId}/strategies/${strategyId}`; const payload = JSON.stringify(sortedStrategy, undefined, 2); return `curl --location --request PUT '${url}' \\