@@ -13,9 +13,9 @@ import { CONTINGENCY_ENDPOINTS } from './constants-endpoints';
13
13
import {
14
14
ElementType ,
15
15
getRequestParamFromList ,
16
- fetchEnv ,
17
16
backendFetchJson ,
18
17
backendFetch ,
18
+ backendFetchText ,
19
19
} from '@gridsuite/commons-ui' ;
20
20
21
21
const PREFIX_USER_ADMIN_SERVER_QUERIES =
@@ -63,68 +63,6 @@ export function connectNotificationsWsUpdateConfig() {
63
63
return reconnectingWebSocket ;
64
64
}
65
65
66
- function parseError ( text ) {
67
- try {
68
- return JSON . parse ( text ) ;
69
- } catch ( err ) {
70
- return null ;
71
- }
72
- }
73
-
74
- function handleError ( response ) {
75
- return response . text ( ) . then ( ( text ) => {
76
- const errorName = 'HttpResponseError : ' ;
77
- let error ;
78
- const errorJson = parseError ( text ) ;
79
- if (
80
- errorJson &&
81
- errorJson . status &&
82
- errorJson . error &&
83
- errorJson . message
84
- ) {
85
- error = new Error (
86
- errorName +
87
- errorJson . status +
88
- ' ' +
89
- errorJson . error +
90
- ', message : ' +
91
- errorJson . message
92
- ) ;
93
- error . status = errorJson . status ;
94
- } else {
95
- error = new Error (
96
- errorName + response . status + ' ' + response . statusText
97
- ) ;
98
- error . status = response . status ;
99
- }
100
- throw error ;
101
- } ) ;
102
- }
103
-
104
- function prepareRequest ( init , token ) {
105
- if ( ! ( typeof init == 'undefined' || typeof init == 'object' ) ) {
106
- throw new TypeError (
107
- 'Argument 2 of backendFetch is not an object' + typeof init
108
- ) ;
109
- }
110
- const initCopy = Object . assign ( { } , init ) ;
111
- initCopy . headers = new Headers ( initCopy . headers || { } ) ;
112
- const tokenCopy = token ? token : getToken ( ) ;
113
- initCopy . headers . append ( 'Authorization' , 'Bearer ' + tokenCopy ) ;
114
- return initCopy ;
115
- }
116
-
117
- function safeFetch ( url , initCopy ) {
118
- return fetch ( url , initCopy ) . then ( ( response ) =>
119
- response . ok ? response : handleError ( response )
120
- ) ;
121
- }
122
-
123
- export function backendFetchText ( url , init , token ) {
124
- const initCopy = prepareRequest ( init , token ) ;
125
- return safeFetch ( url , initCopy ) . then ( ( safeResponse ) => safeResponse . text ( ) ) ;
126
- }
127
-
128
66
const getContingencyUriParamType = ( contingencyListType ) => {
129
67
switch ( contingencyListType ) {
130
68
case ContingencyListType . SCRIPT . id :
@@ -173,43 +111,6 @@ export function fetchValidateUser(user) {
173
111
} ) ;
174
112
}
175
113
176
- export function fetchAuthorizationCodeFlowFeatureFlag ( ) {
177
- console . info ( `Fetching authorization code flow feature flag...` ) ;
178
- return fetchEnv ( )
179
- . then ( ( res ) =>
180
- fetch ( res . appsMetadataServerUrl + '/authentication.json' )
181
- )
182
- . then ( ( res ) => res . json ( ) )
183
- . then ( ( res ) => {
184
- console . log (
185
- `Authorization code flow is ${
186
- res . authorizationCodeFlowFeatureFlag
187
- ? 'enabled'
188
- : 'disabled'
189
- } `
190
- ) ;
191
- return res . authorizationCodeFlowFeatureFlag ;
192
- } )
193
- . catch ( ( error ) => {
194
- console . error ( error ) ;
195
- console . warn (
196
- `Something wrong happened when retrieving authentication.json: authorization code flow will be disabled`
197
- ) ;
198
- return false ;
199
- } ) ;
200
- }
201
-
202
- export function fetchVersion ( ) {
203
- console . info ( `Fetching global metadata...` ) ;
204
- return fetchEnv ( )
205
- . then ( ( env ) => fetch ( env . appsMetadataServerUrl + '/version.json' ) )
206
- . then ( ( response ) => response . json ( ) )
207
- . catch ( ( reason ) => {
208
- console . error ( 'Error while fetching the version : ' + reason ) ;
209
- return reason ;
210
- } ) ;
211
- }
212
-
213
114
export function fetchConfigParameters ( appName ) {
214
115
console . info ( 'Fetching UI configuration params for app : ' + appName ) ;
215
116
const fetchParams =
0 commit comments