Skip to content

Commit

Permalink
Merge pull request #633 from aziontech/dev
Browse files Browse the repository at this point in the history
DEPLOY 2024.01.24
  • Loading branch information
csfeijo authored Jan 26, 2024
2 parents 0522f81 + d98151a commit f948379
Show file tree
Hide file tree
Showing 28 changed files with 248 additions and 78 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azion-platform-kit",
"version": "1.8.1",
"version": "1.8.2",
"private": true,
"type": "module",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/router/routes/users-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const usersListsRoutes = {
listTimezonesService: UsersService.listTimezonesService,
listTeamsService: UsersService.listTeamsService,
editAnotherUserService: UsersService.editAnotherUserService,
loadUserService: UsersService.loadUserService,
loadAnotherUserService: UsersService.loadAnotherUserService,
updatedRedirect: 'list-users'
},
meta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const adapt = (httpResponse) => {
id: httpResponse.body.results.id,
edgeFunctionID: httpResponse.body.results.edge_function_id,
name: httpResponse.body.results.name,
args: JSON.stringify(httpResponse.body.results.args)
args: JSON.stringify(httpResponse.body.results.args, null, '\t')
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const adapt = (httpResponse) => {
id: httpResponse.body.results.id,
edgeFunctionID: httpResponse.body.results.edge_function,
name: httpResponse.body.results.name,
args: JSON.stringify(httpResponse.body.results.json_args)
args: JSON.stringify(httpResponse.body.results.json_args, null, '\t')
}

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const makeResourcesBaseUrl = () => {
return `edge_services`
const version = 'v3'
return `${version}/edge_services`
}
2 changes: 1 addition & 1 deletion src/services/users-services/create-users-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const adapt = (payload) => {
email: payload.email,
language: payload.language,
timezone: payload.timezone,
country_call_code: payload.countryCallCode.value,
country_call_code: payload.countryCallCode,
mobile: payload.mobile?.toString(),
is_account_owner: payload.isAccountOwner,
teams_ids: payload.teamsIds,
Expand Down
2 changes: 1 addition & 1 deletion src/services/users-services/edit-another-user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const adapt = (payload) => {
email: payload.email,
language: payload.language,
timezone: payload.timezone,
country_call_code: payload.countryCallCode.value,
country_call_code: payload.countryCallCode,
mobile: payload.mobile?.toString(),
is_account_owner: payload.isAccountOwner,
teams_ids: payload.teamsIds,
Expand Down
4 changes: 3 additions & 1 deletion src/services/users-services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { listTeamsService } from './list-teams-service'
import { editAnotherUserService } from './edit-another-user-service'
import { loadUserService } from './load-user-service'
import { editUsersService } from './edit-users-service'
import { loadAnotherUserService } from './load-another-user-service'

export {
listUsersService,
Expand All @@ -21,5 +22,6 @@ export {
listTeamsService,
loadUserService,
editAnotherUserService,
editUsersService
editUsersService,
loadAnotherUserService
}
41 changes: 41 additions & 0 deletions src/services/users-services/load-another-user-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { AxiosHttpClientAdapter, parseHttpResponse } from '../axios/AxiosHttpClientAdapter'
import { makeUsersBaseUrl } from './make-users-base-url'

export const loadAnotherUserService = async ({ id }) => {
let httpResponse = await AxiosHttpClientAdapter.request({
url: `${makeUsersBaseUrl()}/${id}`,
method: 'GET'
})
httpResponse = adapt(httpResponse)

return parseHttpResponse(httpResponse)
}

const adapt = (httpResponse) => {
const responseData = httpResponse.body.data
const parsedUser = {
id: responseData.id,
firstName: responseData.first_name,
lastName: responseData.last_name,
email: responseData.email,
language: responseData.language,
timezone: responseData.timezone,
countryCallCode: responseData.country_call_code,
mobile: responseData.mobile,
isAccountOwner: responseData.is_account_owner,
teamsIds: responseData.teams.map((value) => value.id),
twoFactorEnabled: responseData.two_factor_enabled,
dateJoined: responseData.date_joined,
isActive: responseData.is_active,
isStaff: responseData.is_staff,
isTrial: responseData.is_trial,
lastLogin: responseData.last_login,
phone: responseData.phone,
teams: responseData.teams
}

return {
body: parsedUser,
statusCode: httpResponse.statusCode
}
}
7 changes: 5 additions & 2 deletions src/templates/create-form-block/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
return blockViewRedirection.value && isDirty.value
})
const { meta, errors, handleSubmit, isSubmitting, values } = useForm({
const { meta, errors, handleSubmit, isSubmitting, values, resetForm } = useForm({
validationSchema: props.schema,
initialValues: props.initialValues
})
Expand Down Expand Up @@ -90,7 +90,10 @@
<template>
<div class="flex flex-col min-h-[calc(100vh-300px)]">
<form class="w-full grow flex flex-col gap-8 max-md:gap-6">
<slot name="form" />
<slot
name="form"
:resetForm="resetForm"
/>
<slot name="raw-form" />
</form>
<DialogUnsavedBlock :blockRedirectUnsaved="formHasChanges" />
Expand Down
16 changes: 15 additions & 1 deletion src/templates/list-table-block/dialog/delete-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
class="w-100"
severity="warn"
:closable="false"
>Once confirmed, this action can't be reversed.</Message
>
Once confirmed, this action can't be reversed.
</Message>

<p class="pt-3.5 text-color-secondary">
This {{ informationForDeletion.title }} will be deleted along with any associated settings
Expand Down Expand Up @@ -112,10 +113,13 @@
})
const loading = ref(false)
const canDelete = ref(false)
const deleteDialogVisible = ref(false)
const removeItem = async () => {
if (canDelete.value === false) return
if (!meta.value.valid) return
loading.value = true
let toastConfig = {
closable: true,
Expand Down Expand Up @@ -162,10 +166,20 @@
() => props.informationForDeletion,
(value) => {
if (value) {
canDelete.value = false
resetForm()
deleteDialogVisible.value = props.informationForDeletion.deleteDialogVisible
}
},
{ deep: true }
)
watch(
() => confirmation.value,
(value) => {
if (value) {
canDelete.value = true
}
},
{ deep: true }
)
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('LoaderFunctionService', () => {
id: fixture.functionInstance.id,
edgeFunctionID: fixture.functionInstance.edge_function_id,
name: fixture.functionInstance.name,
args: JSON.stringify(fixture.functionInstance.args)
args: JSON.stringify(fixture.functionInstance.args, null, '\t')
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('EdgeFirewallFunctionsServices', () => {
id: fixture.functionInstance.id,
edgeFunctionID: fixture.functionInstance.edge_function,
name: fixture.functionInstance.name,
args: JSON.stringify(fixture.functionInstance.json_args)
args: JSON.stringify(fixture.functionInstance.json_args, null, '\t')
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ describe('EdgeServiceResourcesServices', () => {
statusCode: 201,
body: { id: '123' }
})

const version = 'v3'
const { sut } = makeSut()

await sut(fixtures.mock)

expect(requestSpy).toHaveBeenCalledWith({
method: 'POST',
url: `edge_services/${fixtures.mock.id}/resources`,
url: `${version}/edge_services/${fixtures.mock.id}/resources`,
body: {
name: 'X Edge Service',
trigger: 'TEST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ describe('EdgeServiceResourcesServices', () => {
const requestSpy = vi.spyOn(AxiosHttpClientAdapter, 'request').mockResolvedValueOnce({
statusCode: 204
})
const version = 'v3'
const { sut } = makeSut()

await sut(fixtures.mock)

expect(requestSpy).toHaveBeenCalledWith({
method: 'DELETE',
url: `edge_services/${fixtures.mock.edgeServiceId}/resources/${fixtures.mock.id}`
url: `${version}/edge_services/${fixtures.mock.edgeServiceId}/resources/${fixtures.mock.id}`
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ describe('EdgeServiceResourcesServices', () => {
statusCode: 200,
body: fixtures.mockResponse
})
const version = 'v3'
const { sut } = makeSut()

await sut(fixtures.mockPayload)
const { id, edgeServiceId } = fixtures.mockPayload

expect(requestSpy).toHaveBeenCalledWith({
url: `edge_services/${edgeServiceId}/resources/${id}`,
url: `${version}/edge_services/${edgeServiceId}/resources/${id}`,
method: 'PATCH',
body: fixtures.mockResponse
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ describe('EdgeServiceResourcesServices', () => {
})
const edgeServiceIdMock = 1
const { sut } = makeSut()

const version = 'v3'
await sut({
id: edgeServiceIdMock
})

expect(requestSpy).toHaveBeenCalledWith({
url: `edge_services/${edgeServiceIdMock}/resources?filter=&order_by=name&sort=asc&page=1&page_size=200`,
url: `${version}/edge_services/${edgeServiceIdMock}/resources?filter=&order_by=name&sort=asc&page=1&page_size=200`,
method: 'GET'
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ describe('EdgeServiceResourcesServices', () => {
const id = 812783
const edgeServiceId = 7879123
const { sut } = makeSut()
const version = 'v3'

await sut({
id,
edgeServiceId
})
expect(requestSpy).toHaveBeenCalledWith({
url: `edge_services/${edgeServiceId}/resources/${id}`,
url: `${version}/edge_services/${edgeServiceId}/resources/${id}`,
method: 'GET'
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const makeSut = () => {
describe('EdgeServiceServices', () => {
it('should return the API base url to edge services service', () => {
const { sut } = makeSut()
const correctApiUrl = 'edge_services'
const version = 'v3'
const correctApiUrl = `${version}/edge_services`

const baseUrl = sut()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fixtures = {
timezone: 'America/New_York',
language: 'en_US',
email: 'johndoe@example.com',
countryCallCode: { value: 'AF +93' },
countryCallCode: 'AF +93',
mobile: '+1-123-456-7890',
isAccountOwner: true,
teamsIds: 1,
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('UsersServices', () => {
last_name: fixtures.userMock.lastName,
timezone: fixtures.userMock.timezone,
language: fixtures.userMock.language,
country_call_code: fixtures.userMock.countryCallCode.value,
country_call_code: fixtures.userMock.countryCallCode,
email: fixtures.userMock.email,
mobile: fixtures.userMock.mobile,
is_account_owner: fixtures.userMock.isAccountOwner,
Expand Down
8 changes: 2 additions & 6 deletions src/tests/services/users-services/edit-user-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ const fixtures = {
timezone: 'GMT',
language: 'en',
email: 'test.test@azion.com',
countryCallCode: {
label: 'AL (Albania) +355',
labelFormat: 'AL +355',
value: 'AL - 355'
},
countryCallCode: 'AL - 355',
mobile: 12312312,
isAccountOwner: false,
teamsIds: [1580],
Expand Down Expand Up @@ -49,7 +45,7 @@ describe('UsersService', () => {
timezone: fixtures.userMock.timezone,
language: fixtures.userMock.language,
email: fixtures.userMock.email,
country_call_code: fixtures.userMock.countryCallCode.value,
country_call_code: fixtures.userMock.countryCallCode,
mobile: fixtures.userMock.mobile.toString(),
is_account_owner: fixtures.userMock.isAccountOwner,
teams_ids: fixtures.userMock.teamsIds,
Expand Down
Loading

0 comments on commit f948379

Please sign in to comment.