@@ -7,17 +7,13 @@ import {
7
7
DeleteRepositoryErrorResponse ,
8
8
FindRepositoryErrorResponse ,
9
9
FindSecuritySettingsErrorResponse ,
10
- RepoRuleDeleteErrorResponse ,
11
- RepoRuleListErrorResponse ,
12
10
UpdateDefaultBranchErrorResponse ,
13
11
UpdatePublicAccessErrorResponse ,
14
12
UpdateRepositoryErrorResponse ,
15
13
UpdateSecuritySettingsErrorResponse ,
16
14
useDeleteRepositoryMutation ,
17
15
useFindRepositoryQuery ,
18
16
useFindSecuritySettingsQuery ,
19
- useRepoRuleDeleteMutation ,
20
- useRepoRuleListQuery ,
21
17
useUpdateDefaultBranchMutation ,
22
18
useUpdatePublicAccessMutation ,
23
19
useUpdateRepositoryMutation ,
@@ -29,34 +25,23 @@ import { AccessLevel, ErrorTypes, RepoSettingsGeneralPage, RepoUpdateData, Secur
29
25
30
26
import { BranchSelectorContainer } from '../../components-v2/branch-selector-container'
31
27
import { useRoutes } from '../../framework/context/NavigationContext'
32
- import { useGetRepoId } from '../../framework/hooks/useGetRepoId'
33
28
import { useGetRepoRef } from '../../framework/hooks/useGetRepoPath'
34
29
import { PathParams } from '../../RouteDefinitions'
35
30
import { useRepoRulesStore } from './stores/repo-settings-store'
36
31
37
32
export const RepoSettingsGeneralPageContainer = ( ) => {
38
33
const routes = useRoutes ( )
39
34
const repoRef = useGetRepoRef ( )
40
- const repoName = useGetRepoId ( )
41
35
const navigate = useNavigate ( )
42
36
const { spaceId } = useParams < PathParams > ( )
43
37
const queryClient = useQueryClient ( )
44
- const { setRepoData, setRules, setSecurityScanning } = useRepoRulesStore ( )
45
- const [ rulesSearchQuery , setRulesSearchQuery ] = useState ( '' )
38
+ const { setRepoData, setSecurityScanning } = useRepoRulesStore ( )
46
39
const [ apiError , setApiError ] = useState < { type : ErrorTypes ; message : string } | null > ( null )
47
- const [ isRuleAlertDeleteDialogOpen , setRuleIsAlertDeleteDialogOpen ] = useState ( false )
48
40
const [ isRepoAlertDeleteDialogOpen , setRepoIsAlertDeleteDialogOpen ] = useState ( false )
49
- const [ alertDeleteParams , setAlertDeleteParams ] = useState ( '' )
50
41
51
42
const closeAlertDeleteDialog = ( ) => {
52
- isRuleAlertDeleteDialogOpen && setRuleIsAlertDeleteDialogOpen ( false )
53
43
isRepoAlertDeleteDialogOpen && setRepoIsAlertDeleteDialogOpen ( false )
54
44
}
55
- const openRulesAlertDeleteDialog = ( identifier : string ) => {
56
- setAlertDeleteParams ( identifier )
57
- setRuleIsAlertDeleteDialogOpen ( true )
58
- }
59
-
60
45
const openRepoAlertDeleteDialog = ( ) => setRepoIsAlertDeleteDialogOpen ( true )
61
46
62
47
const { data : { body : repoData } = { } , isLoading : isLoadingRepoData } = useFindRepositoryQuery (
@@ -69,20 +54,6 @@ export const RepoSettingsGeneralPageContainer = () => {
69
54
}
70
55
)
71
56
72
- const {
73
- data : { body : rulesData } = { } ,
74
- refetch : refetchRulesList ,
75
- isLoading : isRulesLoading
76
- } = useRepoRuleListQuery (
77
- { repo_ref : repoRef , queryParams : { query : rulesSearchQuery } } ,
78
- {
79
- onError : ( error : RepoRuleListErrorResponse ) => {
80
- const message = error . message || 'Error fetching rules'
81
- setApiError ( { type : ErrorTypes . FETCH_RULES , message } )
82
- }
83
- }
84
- )
85
-
86
57
const {
87
58
mutateAsync : updateDescription ,
88
59
isLoading : updatingDescription ,
@@ -103,24 +74,6 @@ export const RepoSettingsGeneralPageContainer = () => {
103
74
}
104
75
)
105
76
106
- const { mutate : deleteRule , isLoading : isDeletingRule } = useRepoRuleDeleteMutation (
107
- { repo_ref : repoRef } ,
108
- {
109
- onSuccess : ( ) => {
110
- refetchRulesList ( )
111
- setRepoIsAlertDeleteDialogOpen ( false )
112
- setApiError ( null )
113
- } ,
114
- onError : ( error : RepoRuleDeleteErrorResponse ) => {
115
- // Invalidate queries to refetch data from server
116
- queryClient . invalidateQueries ( [ 'ruleList' , repoRef ] )
117
-
118
- const message = error . message || 'Error deleting rule'
119
- setApiError ( { type : ErrorTypes . DELETE_RULE , message } )
120
- }
121
- }
122
- )
123
-
124
77
const {
125
78
mutateAsync : updateBranch ,
126
79
isLoading : updatingBranch ,
@@ -226,32 +179,15 @@ export const RepoSettingsGeneralPageContainer = () => {
226
179
setApiError ( null )
227
180
} , [ repoData ?. default_branch , repoData , setRepoData ] )
228
181
229
- useEffect ( ( ) => {
230
- if ( rulesData ) {
231
- setRules ( rulesData )
232
- setApiError ( null )
233
- }
234
- } , [ rulesData , setRules ] )
235
-
236
182
const handleUpdateSecuritySettings = ( data : SecurityScanning ) => {
237
183
updateSecuritySettings ( { body : { secret_scanning_enabled : data . secretScanning } } )
238
184
}
239
185
240
- const handleRuleClick = ( identifier : string ) => {
241
- navigate ( routes . toRepoBranchRule ( { spaceId, repoId : repoName , identifier } ) )
242
- }
243
-
244
- const handleDeleteRule = ( identifier : string ) => {
245
- deleteRule ( { rule_identifier : identifier } )
246
- navigate ( routes . toRepoBranchRules ( { spaceId, repoId : repoName , identifier } ) )
247
- }
248
-
249
186
const loadingStates = {
250
187
isLoadingRepoData : isLoadingRepoData || isLoadingSecuritySettings ,
251
188
isUpdatingRepoData : updatingPublicAccess || updatingDescription || updatingBranch ,
252
189
isLoadingSecuritySettings,
253
- isUpdatingSecuritySettings,
254
- isRulesLoading
190
+ isUpdatingSecuritySettings
255
191
}
256
192
257
193
return (
@@ -263,27 +199,13 @@ export const RepoSettingsGeneralPageContainer = () => {
263
199
loadingStates = { loadingStates }
264
200
isRepoUpdateSuccess = { updatePublicAccessSuccess || updateDescriptionSuccess || updateBranchSuccess }
265
201
useRepoRulesStore = { useRepoRulesStore }
266
- handleRuleClick = { handleRuleClick }
267
- openRulesAlertDeleteDialog = { openRulesAlertDeleteDialog }
268
202
openRepoAlertDeleteDialog = { openRepoAlertDeleteDialog }
269
- rulesSearchQuery = { rulesSearchQuery }
270
- setRulesSearchQuery = { setRulesSearchQuery }
271
203
branchSelectorRenderer = { BranchSelectorContainer }
272
204
/>
273
205
274
206
< DeleteAlertDialog
275
- open = { isRuleAlertDeleteDialogOpen || isRepoAlertDeleteDialogOpen }
207
+ open = { isRepoAlertDeleteDialogOpen }
276
208
onClose = { closeAlertDeleteDialog }
277
- { ...wrapConditionalObjectElement (
278
- {
279
- identifier : alertDeleteParams ,
280
- deleteFn : handleDeleteRule ,
281
- isLoading : isDeletingRule ,
282
- error : apiError ?. type === ErrorTypes . DELETE_RULE ? apiError : null ,
283
- type : 'rule'
284
- } ,
285
- isRuleAlertDeleteDialogOpen
286
- ) }
287
209
{ ...wrapConditionalObjectElement (
288
210
{
289
211
identifier : repoRef ,
0 commit comments