Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable and enable strategies - frontend (#3582)
Signed-off-by: andreas-unleash <andreas@getunleash.ai> Co-authored-by: andreas-unleash <andreas@getunleash.ai>
- Loading branch information
1 parent
1e3f652
commit 3bb09c5
Showing
28 changed files
with
722 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...tend/src/component/changeRequest/ChangeRequest/Changes/Change/hooks/useCurrentStrategy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
IChangeRequestAddStrategy, | ||
IChangeRequestDeleteStrategy, | ||
IChangeRequestUpdateStrategy, | ||
} from 'component/changeRequest/changeRequest.types'; | ||
import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; | ||
|
||
export const useCurrentStrategy = ( | ||
change: | ||
| IChangeRequestAddStrategy | ||
| IChangeRequestUpdateStrategy | ||
| IChangeRequestDeleteStrategy, | ||
project: string, | ||
feature: string, | ||
environmentName: string | ||
) => { | ||
const currentFeature = useFeature(project, feature); | ||
const currentStrategy = currentFeature.feature?.environments | ||
.find(environment => environment.name === environmentName) | ||
?.strategies.find( | ||
strategy => | ||
'id' in change.payload && strategy.id === change.payload.id | ||
); | ||
return currentStrategy; | ||
}; |
Oops, something went wrong.