Skip to content

Commit

Permalink
refactor(schema): some text
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinplemelon committed Sep 25, 2024
1 parent 22aab94 commit ea3b805
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 23 deletions.
21 changes: 21 additions & 0 deletions src/hooks/Rule/schema/useExternalSchemaType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getLabelFromValueInOptionList } from '@/common/tools'
import { ExternalSchemaType } from '@/types/typeAlias'

type ExternalSchemaTypeValue = typeof ExternalSchemaType[keyof typeof ExternalSchemaType]

export default (): {
schemaTypeOpts: {
label: string
value: ExternalSchemaTypeValue
}[]
getLabelByValue: (value: ExternalSchemaTypeValue) => string
} => {
const schemaTypeOpts: Array<{ label: string; value: ExternalSchemaTypeValue }> = [
{ label: 'Confluent', value: ExternalSchemaType.Confluent },
]

const getLabelByValue = (value: ExternalSchemaTypeValue) =>
getLabelFromValueInOptionList(value, schemaTypeOpts)

return { schemaTypeOpts, getLabelByValue }
}
14 changes: 9 additions & 5 deletions src/i18n/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ export default {
zh: 'Schema Registry',
en: 'Schema Registry',
},
'internal-schema': {
zh: '内部 Schema',
en: 'Internal Schema',
},
'external-schema': {
zh: '外部 Schema Registry',
en: 'External Schema Registry',
zh: '外部 Schema',
en: 'External Schema',
},
'message-transform': {
zh: '消息转换',
Expand Down Expand Up @@ -424,9 +428,9 @@ export default {
zh: '慢订阅设置',
en: 'Slow Subscriptions Settings',
},
'schema-create': {
zh: '创建 Schema',
en: 'Create Schema',
'internal-schema-create': {
zh: '创建内部 Schema',
en: 'Create Internal Schema',
},
'external-schema-create': {
zh: '创建外部 Schema',
Expand Down
6 changes: 3 additions & 3 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,18 +880,18 @@ export const routes: Array<RouteRecordRaw> = [
children: [
{
path: 'internal',
name: 'schema',
name: 'internal-schema',
component: () => import('@/views/RuleEngine/Schema/Schema.vue'),
},
{
path: 'internal/create',
name: 'schema-create',
name: 'internal-schema-create',
component: () => import('@/views/RuleEngine/Schema/SchemaCreate.vue'),
meta: { hideInMenu: true },
},
{
path: 'internal/:schemaName',
name: 'schema-detail',
name: 'internal-schema-detail',
component: () => import('@/views/RuleEngine/Schema/SchemaDetail.vue'),
meta: { hideInMenu: true },
},
Expand Down
10 changes: 5 additions & 5 deletions src/views/RuleEngine/Schema/ExternalSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</el-button>
</div>
<el-table :data="schemaList" v-loading="isLoading">
<el-table-column prop="name" :label="t('Base.name')" />
<el-table-column prop="type" :label="tl('type')">
<el-table-column prop="name" :label="t('Base.name')" :min-width="200" />
<el-table-column prop="type" :label="tl('type')" :min-width="200">
<template #default="{ row }">
{{ getLabelByValue(row.type) }}
</template>
</el-table-column>
<el-table-column :label="$t('Base.operation')">
<el-table-column :label="$t('Base.operation')" :min-width="150">
<template #default="{ row }">
<el-button size="small" @click="goSchemaDetail(row.name)">
{{ $t('Base.setting') }}
Expand All @@ -31,7 +31,7 @@

<script lang="ts" setup>
import { deleteExternalSchema, getExternalSchemas } from '@/api/ruleengine'
import useSchemaType from '@/hooks/Rule/schema/useSchemaType'
import useExternalSchemaType from '@/hooks/Rule/schema/useExternalSchemaType'
import useI18nTl from '@/hooks/useI18nTl'
import useOperationConfirm from '@/hooks/useOperationConfirm'
import type { ExternalSchema } from '@/types/typeAlias'
Expand All @@ -46,7 +46,7 @@ const { tl, t } = useI18nTl('RuleEngine')
const schemaList: Ref<Array<ExternalSchema>> = ref([])
const isLoading = ref(false)
const { getLabelByValue } = useSchemaType()
const { getLabelByValue } = useExternalSchemaType()
const getSchemas = async () => {
try {
Expand Down
5 changes: 4 additions & 1 deletion src/views/RuleEngine/Schema/ExternalSchemaCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import useI18nTl from '@/hooks/useI18nTl'
import type { ExternalSchema } from '@/types/typeAlias'
import { ExternalSchemaType } from '@/types/typeAlias'
import { ElMessage } from 'element-plus'
import { cloneDeep } from 'lodash'
import { cloneDeep, isObject } from 'lodash'
import { defineEmits, defineProps, Ref, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import ExternalSchemaConfluentForm from './components/ExternalSchemaConfluentForm.vue'
Expand Down Expand Up @@ -73,6 +73,9 @@ const checkClipStatus = async () => {
if (query.action === 'copy' && query.target) {
const schema = await getExternalSchemaDetail(query.target.toString())
formData.value = { ...schema, name: countDuplicationName(query.target.toString()) }
if (isObject(formData.value.auth) && formData.value.auth.password) {
formData.value.auth.password = ''
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/RuleEngine/Schema/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ const getSchemas = async () => {
}
const goSchemaDetail = (name: string) =>
router.push({ name: 'schema-detail', params: { schemaName: name } })
router.push({ name: 'internal-schema-detail', params: { schemaName: name } })
const addSchema = () => {
router.push({ name: 'schema-create' })
router.push({ name: 'internal-schema-create' })
}
const handleCopy = (name: string) => {
router.push({ name: 'schema-create', query: { action: 'copy', target: name } })
router.push({ name: 'internal-schema-create', query: { action: 'copy', target: name } })
}
const handleDel = async (name: string) => {
Expand Down
6 changes: 3 additions & 3 deletions src/views/RuleEngine/Schema/SchemaCreate.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="schema-create" :class="[isInSinglePage ? 'app-wrapper' : '']">
<detail-header v-if="isInSinglePage" :item="{ name: title, routeName: 'schema' }" />
<detail-header v-if="isInSinglePage" :item="{ name: title, routeName: 'internal-schema' }" />
<el-card class="app-card schema-create-card">
<SchemaRegistryForm
class="schema-create-form"
Expand Down Expand Up @@ -83,7 +83,7 @@ const checkClipStatus = async () => {
const cancel = () => {
if (isInSinglePage.value) {
router.push({ name: 'schema' })
router.push({ name: 'internal-schema' })
} else {
emit('cancel')
}
Expand All @@ -96,7 +96,7 @@ const submit = async () => {
const ret = await createSchema(cloneDeep(formData.value))
if (isInSinglePage.value) {
ElMessage.success(t('Base.createSuccess'))
router.push({ name: 'schema' })
router.push({ name: 'internal-schema' })
} else {
emit('submitted', ret.name)
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/RuleEngine/Schema/SchemaDetail.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="schema-detail">
<div class="detail-top">
<detail-header :item="{ name: schemaName, routeName: 'schema' }" />
<detail-header :item="{ name: schemaName, routeName: 'internal-schema' }" />
<div class="btn-wrap">
<el-tooltip :content="$t('Base.delete')" placement="top">
<el-button
Expand Down Expand Up @@ -85,7 +85,7 @@ const handleUpdate = async () => {
await FormCom.value.validate()
await updateSchema(schemaName.value, omit(cloneDeep(schemaData.value), 'name'))
ElMessage.success(t('Base.updateSuccess'))
router.push({ name: 'schema' })
router.push({ name: 'internal-schema' })
} catch (error) {
console.error(error)
} finally {
Expand All @@ -103,7 +103,7 @@ const handleDelete = async () => {
})
await deleteSchema(schemaName.value)
ElMessage.success(t('Base.deleteSuccess'))
router.push({ name: 'schema' })
router.push({ name: 'internal-schema' })
} catch (error) {
//
}
Expand Down

0 comments on commit ea3b805

Please sign in to comment.