-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UXE-5889] feat: migrate network lists/domains filters in WAF Tunning…
… for API v4 (#2088) * feat: migrate network lists dropdown in waf rules tuning * feat: added multiselect lazy loader component * test: load domain v4 test case * refactor: clean up code formatting in multiselect lazy loader and field dropdown components * refactor: added throw error in load domain v4 service * refactor: added throw error in load network list v4 service * fix: correct domain name extraction in list domain service * refactor: reposition domain field in WAF Rules Tuning list view * refactor: optimize multiselect lazy loader data fetching and pagination * fix: remove duplicated attr from dropdown lazy loader
- Loading branch information
1 parent
c5618ff
commit 5c25f57
Showing
14 changed files
with
565 additions
and
61 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { AxiosHttpClientAdapter, parseHttpResponse } from '@/services/axios/AxiosHttpClientAdapter' | ||
import { makeDomainsBaseUrl } from './make-domains-service' | ||
import { extractApiError } from '@/helpers/extract-api-error' | ||
|
||
export const loadDomainService = async ({ id }) => { | ||
let httpResponse = await AxiosHttpClientAdapter.request({ | ||
url: `${makeDomainsBaseUrl()}/${id}`, | ||
method: 'GET' | ||
}) | ||
|
||
httpResponse = adapt(httpResponse) | ||
|
||
return parseHttpResponse(httpResponse) | ||
} | ||
|
||
const adapt = ({ body, statusCode }) => { | ||
if (statusCode !== 200) { | ||
throw new Error(extractApiError({ body })).message | ||
} | ||
|
||
const domain = body?.results | ||
|
||
const parsedVariable = { | ||
id: domain.id, | ||
name: domain.name, | ||
alternateDomains: domain.alternate_domains, | ||
networkMap: domain.network_map, | ||
lastEditor: domain.last_editor, | ||
lastModified: domain.last_modified, | ||
active: domain.active, | ||
tls: domain.tls, | ||
protocols: domain.protocols, | ||
mtls: domain.mtls, | ||
domains: domain.domains, | ||
productVersion: domain.product_version | ||
} | ||
|
||
return { | ||
body: parsedVariable, | ||
statusCode | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
src/services/waf-rules-services/v4/list-network-list-service.js
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,48 @@ | ||
import { AxiosHttpClientAdapter, parseHttpResponse } from '@/services/axios/AxiosHttpClientAdapter' | ||
import { makeNetworkListBaseUrl } from '../../network-lists-services/v4/make-network-list-service' | ||
import { makeListServiceQueryParams } from '@/helpers/make-list-service-query-params' | ||
|
||
export const listNetworkListService = async ({ | ||
fields = '', | ||
search = '', | ||
ordering = '', | ||
page = 1, | ||
pageSize = 10 | ||
}) => { | ||
const searchParams = makeListServiceQueryParams({ fields, ordering, page, pageSize, search }) | ||
let httpResponse = await AxiosHttpClientAdapter.request({ | ||
url: `${makeNetworkListBaseUrl()}?${searchParams.toString()}`, | ||
method: 'GET' | ||
}) | ||
|
||
httpResponse = adapt(httpResponse) | ||
return parseHttpResponse(httpResponse) | ||
} | ||
|
||
const adapt = (httpResponse) => { | ||
const isArray = Array.isArray(httpResponse.body.results) | ||
|
||
const networkList = isArray | ||
? httpResponse.body.results.map((element) => { | ||
const disabledIP = element.type === 'ip_cidr' | ||
const disabledCountries = element.type === 'countries' | ||
return { | ||
value: { | ||
id: element.id, | ||
disabledIP, | ||
disabledCountries | ||
}, | ||
id: element.id, | ||
name: element.name | ||
} | ||
}) | ||
: [] | ||
|
||
const count = httpResponse.body?.count ?? 0 | ||
|
||
return { | ||
count, | ||
body: networkList, | ||
statusCode: httpResponse.statusCode | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/services/waf-rules-services/v4/load-network-list-service.js
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,37 @@ | ||
import { AxiosHttpClientAdapter, parseHttpResponse } from '@/services/axios/AxiosHttpClientAdapter' | ||
import { makeNetworkListBaseUrl } from '../../network-lists-services/v4/make-network-list-service' | ||
import { extractApiError } from '@/helpers/extract-api-error' | ||
|
||
export const loadNetworkListService = async ({ id }) => { | ||
let httpResponse = await AxiosHttpClientAdapter.request({ | ||
url: `${makeNetworkListBaseUrl()}/${id}`, | ||
method: 'GET' | ||
}) | ||
|
||
httpResponse = adapt(httpResponse, id) | ||
return parseHttpResponse(httpResponse) | ||
} | ||
|
||
const adapt = ({ body, statusCode }) => { | ||
if (statusCode !== 200) { | ||
throw new Error(extractApiError({ body })).message | ||
} | ||
|
||
const element = body?.results | ||
|
||
const disabledIP = element.type === 'ip_cidr' | ||
const disabledCountries = element.type === 'countries' | ||
const networkList = { | ||
value: { | ||
id: element.id, | ||
disabledIP, | ||
disabledCountries | ||
}, | ||
name: element.name | ||
} | ||
|
||
return { | ||
body: networkList, | ||
statusCode | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
' | ||
<script setup> | ||
import ButtonPrime from 'primevue/button' | ||
import Divider from 'primevue/divider' | ||
|
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
Oops, something went wrong.