Skip to content

Commit

Permalink
Merge pull request #2736 from emqx/dev/1.9.1
Browse files Browse the repository at this point in the history
Sync code from refs/heads/dev/1.9.1 to enterprise
  • Loading branch information
Kinplemelon committed Jun 7, 2024
2 parents 0709cc0 + 794c032 commit 717a2ee
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 29 deletions.
18 changes: 8 additions & 10 deletions src/components/SchemaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ const SchemaForm = defineComponent({
prop.type === 'oneof' && prop.oneOf?.length && prop.oneOf?.some(({ $ref }) => $ref)

const handleSelectOneof = (parentProperty: Property, property: Property) => {
const isInit = _.isUndefined(parentProperty.selectedOneof)
parentProperty.selectedOneof = property.properties
parentProperty.default = property.default
const fieldValue = parentProperty.path && _.get(configForm.value, parentProperty.path)
Expand All @@ -289,16 +290,13 @@ const SchemaForm = defineComponent({
}
})
}
// Add new fields
Object.values(property.properties || {}).forEach((prop) => {
if (!prop.path) {
return
}
const currentValue = _.get(configForm.value, prop.path)
if (_.isUndefined(currentValue)) {
_.set(configForm.value, prop.path, createInitValueByType(prop))
}
})
// If it is initial and, props.needRecord is false, do not set
if ((!isInit || props.needRecord) && property.properties && parentProperty.path) {
// Add new fields
const newRecord = initRecordByComponents(property.properties)
_.set(configForm.value, parentProperty.path, _.get(newRecord, parentProperty.path))
}

rules.value = { ...rules.value, ...property.rules }
}

Expand Down
50 changes: 35 additions & 15 deletions src/types/schemas/rules.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export type RuleEngineRuleTestContext =
| RuleEngineCtxSchemaValidationFailed
| RuleEngineCtxDeliveryDropped
| RuleEngineCtxBridgeMqtt
| RuleEngineCtxCheckAuthnComplete
| RuleEngineCtxCheckAuthzComplete
| RuleEngineCtxConnack
| RuleEngineCtxDisconnected
Expand Down Expand Up @@ -402,21 +403,6 @@ export interface RuleEngineCtxSchemaValidationFailed {
qos?: number
}

export type RuleEngineRuleApplyTestContext =
| RuleEngineCtxSchemaValidationFailed
| RuleEngineCtxDeliveryDropped
| RuleEngineCtxBridgeMqtt
| RuleEngineCtxCheckAuthzComplete
| RuleEngineCtxConnack
| RuleEngineCtxDisconnected
| RuleEngineCtxConnected
| RuleEngineCtxDropped
| RuleEngineCtxAcked
| RuleEngineCtxDelivered
| RuleEngineCtxUnsub
| RuleEngineCtxSub
| RuleEngineCtxPub

export type RuleEngineCtxPubEventType =
typeof RuleEngineCtxPubEventType[keyof typeof RuleEngineCtxPubEventType]

Expand Down Expand Up @@ -587,6 +573,24 @@ export interface RuleEngineCtxCheckAuthzComplete {
result?: string
}

export type RuleEngineCtxCheckAuthnCompleteEventType =
typeof RuleEngineCtxCheckAuthnCompleteEventType[keyof typeof RuleEngineCtxCheckAuthnCompleteEventType]

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RuleEngineCtxCheckAuthnCompleteEventType = {
client_check_authn_complete: 'client_check_authn_complete',
} as const

export interface RuleEngineCtxCheckAuthnComplete {
event_type: RuleEngineCtxCheckAuthnCompleteEventType
clientid?: string
username?: string
reason_code?: string
peername?: string
is_anonymous?: boolean
is_superuser?: boolean
}

export type RuleEngineCtxBridgeMqttEventType =
typeof RuleEngineCtxBridgeMqttEventType[keyof typeof RuleEngineCtxBridgeMqttEventType]

Expand All @@ -607,6 +611,22 @@ export interface RuleEngineCtxBridgeMqtt {
qos?: number
}

export type RuleEngineRuleApplyTestContext =
| RuleEngineCtxSchemaValidationFailed
| RuleEngineCtxDeliveryDropped
| RuleEngineCtxBridgeMqtt
| RuleEngineCtxCheckAuthnComplete
| RuleEngineCtxCheckAuthzComplete
| RuleEngineCtxConnack
| RuleEngineCtxDisconnected
| RuleEngineCtxConnected
| RuleEngineCtxDropped
| RuleEngineCtxAcked
| RuleEngineCtxDelivered
| RuleEngineCtxUnsub
| RuleEngineCtxSub
| RuleEngineCtxPub

export type RuleEngineCtxAckedEventType =
typeof RuleEngineCtxAckedEventType[keyof typeof RuleEngineCtxAckedEventType]

Expand Down
6 changes: 2 additions & 4 deletions src/views/RuleEngine/Bridge/BridgeDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
v-model="showSecondConfirm"
:rule-list="usingBridgeRules"
:id="currentDeleteBridgeId"
:direction="delBridgeDirection"
@submitted="handleDeleteSuc"
/>
<DeleteWebhookAssociatedTip
Expand Down Expand Up @@ -304,7 +303,7 @@ const testConnection = async () => {
await customValidate(formCom.value)
isTesting.value = true
const data = await getDataForSubmit()
await testConnectivity(_.omit(data, 'id'))
await testConnectivity(_.omit(data, 'id') as any)
ElMessage.success(tl('connectionSuccessful'))
} catch (error) {
//
Expand Down Expand Up @@ -332,7 +331,7 @@ const updateBridgeInfo = async () => {
updateLoading.value = true
const data = await getDataForSubmit()
const res = await updateAction(data)
const res = await updateAction(data as any)
if (!isFromRule.value) {
ElMessage.success(t('Base.updateSuccess'))
router.push({ name: 'actions' })
Expand Down Expand Up @@ -382,7 +381,6 @@ const {
showDeleteWebhookAssociatedTip,
currentDelName,
handleDeleteSuc,
delBridgeDirection,
handleDeleteBridge,
} = useDeleteBridge(goBack)
const handleDelete = async () => {
Expand Down

0 comments on commit 717a2ee

Please sign in to comment.