Skip to content

Commit bc1e341

Browse files
committed
Remove mention of Appirio
1 parent aa612f8 commit bc1e341

File tree

6 files changed

+19739
-27410
lines changed

6 files changed

+19739
-27410
lines changed

src/apps/admin/src/lib/components/UsersFilters/UsersFilters.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const UsersFilters: FC<Props> = props => {
147147
Tips:
148148
<br />
149149
- Wildcard(*) is available for partial matching. (e.g.
150-
ChrisB*, chris*@appirio.com)
150+
ChrisB*, chris*@wipro.com)
151151
<br />
152152
- Maximum number of searched results is 500.
153153
</p>

src/apps/admin/src/lib/services/roles.service.ts

Lines changed: 51 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import _ from 'lodash'
66
import { EnvironmentConfig } from '~/config'
77
import { xhrDeleteAsync, xhrGetAsync, xhrPostAsync } from '~/libs/core'
88

9-
import { adjustUserRoleResponse, ApiV3Response, UserRole } from '../models'
9+
import { adjustUserRoleResponse, UserRole } from '../models'
1010

1111
/**
1212
* Fetchs roles of the specified subject
@@ -17,11 +17,11 @@ import { adjustUserRoleResponse, ApiV3Response, UserRole } from '../models'
1717
export const fetchRolesBySubject = async (
1818
subjectId: string,
1919
): Promise<UserRole[]> => {
20-
const result = await xhrGetAsync<ApiV3Response<UserRole[]>>(
21-
`${EnvironmentConfig.API.V3}/roles/?filter=subjectID=${subjectId}`,
20+
const roles = await xhrGetAsync<UserRole[]>(
21+
`${EnvironmentConfig.API.V6}/roles/?filter=subjectID=${subjectId}`,
2222
)
23-
const roles = result.result.content.map(adjustUserRoleResponse)
24-
return _.orderBy(roles, ['roleName'], ['asc'])
23+
const adjusted = roles.map(adjustUserRoleResponse)
24+
return _.orderBy(adjusted, ['roleName'], ['asc'])
2525
}
2626

2727
/**
@@ -30,11 +30,11 @@ export const fetchRolesBySubject = async (
3030
* by names.
3131
*/
3232
export const fetchRoles = async (): Promise<UserRole[]> => {
33-
const result = await xhrGetAsync<ApiV3Response<UserRole[]>>(
34-
`${EnvironmentConfig.API.V3}/roles`,
33+
const roles = await xhrGetAsync<UserRole[]>(
34+
`${EnvironmentConfig.API.V6}/roles`,
3535
)
36-
const roles = result.result.content.map(adjustUserRoleResponse)
37-
return _.orderBy(roles, ['roleName'], ['asc'])
36+
const adjusted = roles.map(adjustUserRoleResponse)
37+
return _.orderBy(adjusted, ['roleName'], ['asc'])
3838
}
3939

4040
/**
@@ -43,15 +43,15 @@ export const fetchRoles = async (): Promise<UserRole[]> => {
4343
* @returns resolves to the role object, if success.
4444
*/
4545
export const createRole = async (roleName: string): Promise<UserRole> => {
46-
const result = await xhrPostAsync<any, ApiV3Response<UserRole>>(
47-
`${EnvironmentConfig.API.V3}/roles`,
46+
const response = await xhrPostAsync<any, UserRole>(
47+
`${EnvironmentConfig.API.V6}/roles`,
4848
{
4949
param: {
5050
roleName,
5151
},
5252
},
5353
)
54-
return adjustUserRoleResponse(result.result.content)
54+
return adjustUserRoleResponse(response)
5555
}
5656

5757
/**
@@ -63,13 +63,10 @@ export const createRole = async (roleName: string): Promise<UserRole> => {
6363
export const assignRole = async (
6464
roleId: string,
6565
userId: string,
66-
): Promise<string> => {
67-
const result = await xhrPostAsync<undefined, ApiV3Response<string>>(
68-
`${EnvironmentConfig.API.V3}/roles/${roleId}/assign?action=true&filter=subjectID%3D${userId}`,
69-
undefined,
70-
)
71-
return result.result.content
72-
}
66+
): Promise<string> => xhrPostAsync<undefined, string>(
67+
`${EnvironmentConfig.API.V6}/roles/${roleId}/assign?action=true&filter=subjectID%3D${userId}`,
68+
undefined,
69+
)
7370

7471
/**
7572
* Unassigns role from the user.
@@ -80,12 +77,9 @@ export const assignRole = async (
8077
export const unassignRole = async (
8178
roleId: string,
8279
userId: string,
83-
): Promise<string> => {
84-
const result = await xhrDeleteAsync<ApiV3Response<string>>(
85-
`${EnvironmentConfig.API.V3}/roles/${roleId}/deassign?action=true&filter=subjectID%3D${userId}`,
86-
)
87-
return result.result.content
88-
}
80+
): Promise<string> => xhrDeleteAsync<string>(
81+
`${EnvironmentConfig.API.V6}/roles/${roleId}/deassign?action=true&filter=subjectID%3D${userId}`,
82+
)
8983

9084
/**
9185
* Fetchs role info
@@ -97,67 +91,46 @@ export const fetchRole = async (
9791
roleId: string,
9892
fields: string[],
9993
): Promise<UserRole> => {
100-
// there is a bug in backend, when we ask to get role subjects
101-
// but there are no subjects, backend returns 404 even if role exists
102-
// as a workaround we get role without subjects first to check if it exists
103-
// and only after we try to get it subject
104-
// TODO: remove code in this if, after this bug is fixed at the backend
105-
// keep only the part after else
94+
const baseUrl = `${EnvironmentConfig.API.V6}/roles/${roleId}`
95+
10696
if (fields && _.includes(fields, 'subjects')) {
107-
const fieldsWithouSubjects = _.without(fields, 'subjects')
108-
// if there are no fields after removing 'subjects', add 'id' to retrieve minimum data
109-
if (!fieldsWithouSubjects.length) {
110-
fieldsWithouSubjects.push('id')
97+
// Work around backend returning 404 when requesting subjects for empty roles.
98+
const fieldsWithoutSubjects = _.without(fields, 'subjects')
99+
if (!fieldsWithoutSubjects.length) {
100+
fieldsWithoutSubjects.push('id')
111101
}
112102

113-
const fieldsQuery = fields
114-
? `?fields=${fieldsWithouSubjects.join(',')}`
115-
: ''
116-
117-
return xhrGetAsync<ApiV3Response<UserRole>>(
118-
`${EnvironmentConfig.API.V3}/roles/${roleId}${fieldsQuery}`,
103+
const fieldsQuery = `?fields=${fieldsWithoutSubjects.join(',')}`
104+
const roleWithoutSubjects = await xhrGetAsync<UserRole>(
105+
`${baseUrl}${fieldsQuery}`,
119106
)
120-
.then(async (res: ApiV3Response<UserRole>) => {
121-
const roleWithoutSubjects = res.result.content
122107

123-
// now let's try to get subjects
124-
return xhrGetAsync<ApiV3Response<UserRole>>(
125-
`${EnvironmentConfig.API.V3}/roles/${roleId}?fields=subjects`,
126-
)
127-
// populate role with subjects and return it
128-
.then((resChild: ApiV3Response<UserRole>) => _.assign(
129-
roleWithoutSubjects,
130-
{
131-
subjects: resChild.result.content.subjects,
132-
},
133-
))
134-
.catch((error: any) => {
135-
// if get error 404 in this case we know role exits
136-
// so just return roleWithoutSubjects with subjects as en empty array
137-
if (
138-
error.data
139-
&& error.data.result
140-
&& error.data.result.status === 404
141-
) {
142-
return adjustUserRoleResponse(
143-
_.assign(roleWithoutSubjects, {
144-
subjects: [],
145-
}),
146-
)
147-
148-
}
149-
150-
// for other errors return rejected promise with error
151-
return Promise.reject(error)
152-
})
108+
try {
109+
const subjectsResponse = await xhrGetAsync<UserRole>(
110+
`${baseUrl}?fields=subjects`,
111+
)
112+
const mergedRole = _.assign({}, roleWithoutSubjects, {
113+
subjects: subjectsResponse.subjects,
153114
})
115+
return adjustUserRoleResponse(mergedRole)
116+
} catch (error: any) {
117+
const statusCode = error?.data?.result?.status
118+
?? error?.response?.status
119+
?? error?.status
154120

121+
if (statusCode === 404) {
122+
return adjustUserRoleResponse(
123+
_.assign({}, roleWithoutSubjects, { subjects: [] }),
124+
)
125+
}
126+
127+
throw error
128+
}
155129
}
156130

157-
// if don't ask for subjects, then just normal request
158-
const fieldsQuery = fields ? `?fields=${fields.join(',')}` : ''
159-
const result = await xhrGetAsync<ApiV3Response<UserRole>>(
160-
`${EnvironmentConfig.API.V3}/roles/${roleId}${fieldsQuery}`,
131+
const fieldsQuery = fields?.length ? `?fields=${fields.join(',')}` : ''
132+
const response = await xhrGetAsync<UserRole>(
133+
`${baseUrl}${fieldsQuery}`,
161134
)
162-
return adjustUserRoleResponse(result.result.content)
135+
return adjustUserRoleResponse(response)
163136
}

src/apps/admin/src/lib/services/user.service.ts

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ export const searchUsers = async (options?: {
8686
}
8787
},
8888
)
89-
const result = await xhrGetAsync<ApiV3Response<UserInfo[]>>(
90-
`${EnvironmentConfig.API.V3}/users?${query}`,
89+
const users = await xhrGetAsync<UserInfo[]>(
90+
`${EnvironmentConfig.API.V6}/users?${query}`,
9191
)
92-
return result.result.content.map(adjustUserInfoResponse)
92+
return users.map(adjustUserInfoResponse)
9393
}
9494

9595
/**
@@ -123,11 +123,10 @@ export const updateUserEmail = async (
123123
email,
124124
},
125125
})
126-
const result = await xhrPatchAsync<string, ApiV3Response<UserInfo>>(
127-
`${EnvironmentConfig.API.V3}/users/${userId}/email`,
126+
return xhrPatchAsync<string, UserInfo>(
127+
`${EnvironmentConfig.API.V6}/users/${userId}/email`,
128128
payload,
129129
)
130-
return result.result.content
131130
}
132131

133132
/**
@@ -148,11 +147,11 @@ export const updateUserStatus = async (
148147
},
149148
})
150149
const param = comment ? `?comment=${encodeURIComponent(comment)}` : ''
151-
const result = await xhrPatchAsync<string, ApiV3Response<UserInfo>>(
152-
`${EnvironmentConfig.API.V3}/users/${userId}/status${param}`,
150+
const result = await xhrPatchAsync<string, UserInfo>(
151+
`${EnvironmentConfig.API.V6}/users/${userId}/status${param}`,
153152
payload,
154153
)
155-
return adjustUserInfoResponse(result.result.content)
154+
return adjustUserInfoResponse(result)
156155
}
157156

158157
/**
@@ -163,10 +162,10 @@ export const updateUserStatus = async (
163162
export const fetchAchievements = async (
164163
userId: string,
165164
): Promise<UserStatusHistory[]> => {
166-
const result = await xhrGetAsync<ApiV3Response<UserStatusHistory[]>>(
167-
`${EnvironmentConfig.API.V3}/users/${userId}/achievements`,
165+
const history = await xhrGetAsync<UserStatusHistory[]>(
166+
`${EnvironmentConfig.API.V6}/users/${userId}/achievements`,
168167
)
169-
return result.result.content.map(adjustUserStatusHistoryResponse)
168+
return history.map(adjustUserStatusHistoryResponse)
170169
}
171170

172171
/**
@@ -177,10 +176,10 @@ export const fetchAchievements = async (
177176
export const findUserById = async (
178177
userId: string | number,
179178
): Promise<UserInfo> => {
180-
const result = await xhrGetAsync<ApiV3Response<UserInfo>>(
181-
`${EnvironmentConfig.API.V3}/users/${userId}`,
179+
const user = await xhrGetAsync<UserInfo>(
180+
`${EnvironmentConfig.API.V6}/users/${userId}`,
182181
)
183-
return adjustUserInfoResponse(result.result.content)
182+
return adjustUserInfoResponse(user)
184183
}
185184

186185
/**
@@ -190,12 +189,9 @@ export const findUserById = async (
190189
*/
191190
export const fetchSSOUserLogins = async (
192191
userId: string | number,
193-
): Promise<SSOUserLogin[]> => {
194-
const result = await xhrGetAsync<ApiV3Response<SSOUserLogin[]>>(
195-
`${EnvironmentConfig.API.V3}/users/${userId}/SSOUserLogins`,
196-
)
197-
return result.result.content
198-
}
192+
): Promise<SSOUserLogin[]> => xhrGetAsync<SSOUserLogin[]>(
193+
`${EnvironmentConfig.API.V6}/users/${userId}/SSOUserLogins`,
194+
)
199195

200196
/**
201197
* Fetch list of sso login provider.
@@ -218,15 +214,15 @@ export const createSSOUserLogin = async (
218214
userId: string | number,
219215
userLogin: FormAddSSOLoginData,
220216
): Promise<SSOUserLogin> => {
221-
const result = await xhrPostAsync<
217+
const response = await xhrPostAsync<
222218
{
223219
param: FormAddSSOLoginData
224220
},
225-
ApiV3Response<SSOUserLogin>
226-
>(`${EnvironmentConfig.API.V3}/users/${userId}/SSOUserLogin`, {
221+
SSOUserLogin
222+
>(`${EnvironmentConfig.API.V6}/users/${userId}/SSOUserLogin`, {
227223
param: userLogin,
228224
})
229-
return result.result.content
225+
return response
230226
}
231227

232228
/**
@@ -239,15 +235,15 @@ export const updateSSOUserLogin = async (
239235
userId: string | number,
240236
userLogin: FormAddSSOLoginData,
241237
): Promise<SSOUserLogin> => {
242-
const result = await xhrPutAsync<
238+
const response = await xhrPutAsync<
243239
{
244240
param: FormAddSSOLoginData
245241
},
246-
ApiV3Response<SSOUserLogin>
247-
>(`${EnvironmentConfig.API.V3}/users/${userId}/SSOUserLogin`, {
242+
SSOUserLogin
243+
>(`${EnvironmentConfig.API.V6}/users/${userId}/SSOUserLogin`, {
248244
param: userLogin,
249245
})
250-
return result.result.content
246+
return response
251247
}
252248

253249
/**
@@ -260,8 +256,8 @@ export const deleteSSOUserLogin = async (
260256
userId: string | number,
261257
provider: string,
262258
): Promise<SSOUserLogin> => {
263-
const result = await xhrDeleteAsync<ApiV3Response<SSOUserLogin>>(
264-
`${EnvironmentConfig.API.V3}/users/${userId}/SSOUserLogin?provider=${provider}`,
259+
const response = await xhrDeleteAsync<SSOUserLogin>(
260+
`${EnvironmentConfig.API.V6}/users/${userId}/SSOUserLogin?provider=${provider}`,
265261
)
266-
return result.result.content
262+
return response
267263
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EnvironmentConfig } from '~/config'
22

33
export function user(userId: number): string {
4-
return `${EnvironmentConfig.API.V3}/users/${userId}`
4+
return `${EnvironmentConfig.API.V6}/users/${userId}`
55
}

src/libs/core/lib/profile/profile-functions/profile-store/profile-endpoint.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function memberStatsDistroURL(): string {
3030
}
3131

3232
export function memberModifyURL(): string {
33-
return `${EnvironmentConfig.API.V3}/users`
33+
return `${EnvironmentConfig.API.V6}/users`
3434
}
3535

3636
export function memberEmailPreferencesURL(): string {

0 commit comments

Comments
 (0)