-
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-5197] feat: add edge services drawer to edge nodes services form (…
…#1813) * chore: updgrade project version to 1.24.0 * feat: add edge services drawer to edge nodes services form
- Loading branch information
1 parent
0502f9b
commit 5d8bd2b
Showing
6 changed files
with
222 additions
and
62 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
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,89 @@ | ||
<script setup> | ||
import CreateDrawerBlock from '@templates/create-drawer-block' | ||
import { refDebounced } from '@vueuse/core' | ||
import * as yup from 'yup' | ||
import { ref, inject, defineExpose } from 'vue' | ||
import FormFieldsEdgeService from '../FormFields/FormFieldsEdgeService' | ||
import { createEdgeServiceServices } from '@/services/edge-service-services' | ||
import { handleTrackerError } from '@/utils/errorHandlingTracker' | ||
defineOptions({ | ||
name: 'edge-services-drawer' | ||
}) | ||
const emit = defineEmits(['onSuccess']) | ||
/**@type {import('@/plugins/adapters/AnalyticsTrackerAdapter').AnalyticsTrackerAdapter} */ | ||
const tracker = inject('tracker') | ||
const showCreateEdgeServicesDrawer = ref(false) | ||
const DEBOUNCE_TIME_IN_MS = 300 | ||
const showCreateDrawer = refDebounced(showCreateEdgeServicesDrawer, DEBOUNCE_TIME_IN_MS) | ||
const validateCode = (val = '') => { | ||
const split = val.split(/\s*\n+\s*/).filter((row) => !!row) | ||
const isValid = split.every((row) => /^\w+\s*=[^]+$/.test(row)) | ||
return isValid | ||
} | ||
const validationSchema = yup.object({ | ||
name: yup.string().required().label('Name'), | ||
active: yup.boolean(), | ||
code: yup.string().test('formatInvalid', 'The format is invalid', validateCode) | ||
}) | ||
const initialValues = { | ||
name: '', | ||
code: '', | ||
active: true | ||
} | ||
const handleTrackSuccessCreated = () => { | ||
tracker.product.productCreated({ | ||
productName: 'Edge Service' | ||
}) | ||
} | ||
const handleTrackFailCreated = (error) => { | ||
const { fieldName, message } = handleTrackerError(error) | ||
tracker.product | ||
.failedToCreate({ | ||
productName: 'Edge Service', | ||
errorType: 'api', | ||
fieldName: fieldName.trim(), | ||
errorMessage: message | ||
}) | ||
.track() | ||
} | ||
const closeCreateDrawer = () => { | ||
showCreateEdgeServicesDrawer.value = false | ||
} | ||
const openCreateDrawer = () => { | ||
showCreateEdgeServicesDrawer.value = true | ||
} | ||
const handleCreateWithSuccess = (response) => { | ||
handleTrackSuccessCreated() | ||
emit('onSuccess', response.id) | ||
closeCreateDrawer() | ||
} | ||
defineExpose({ | ||
showCreateDrawer, | ||
openCreateDrawer | ||
}) | ||
</script> | ||
|
||
<template> | ||
<CreateDrawerBlock | ||
v-if="showCreateDrawer" | ||
v-model:visible="showCreateEdgeServicesDrawer" | ||
drawerId="create-edge-service-drawer" | ||
:createService="createEdgeServiceServices" | ||
:schema="validationSchema" | ||
:initialValues="initialValues" | ||
@onSuccess="handleCreateWithSuccess" | ||
@onResponseFail="handleTrackFailCreated" | ||
title="Create Edge Service" | ||
> | ||
<template #formFields> | ||
<FormFieldsEdgeService isDrawer /> | ||
</template> | ||
</CreateDrawerBlock> | ||
</template> |
Oops, something went wrong.