Skip to content

Commit

Permalink
refactor(components): adjust files position
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinplemelon committed Nov 28, 2024
1 parent 9dfc911 commit 28dce4f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 45 deletions.
6 changes: 2 additions & 4 deletions packages/components/streaming/StreamingACLForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ import {
StreamPermission,
StreamResourceType,
} from '@emqx/shared-ui-constants'
import { useLocale } from '@emqx/shared-ui-utils'
import { Component, computed } from 'vue'
import useStreamingAuth from '../hooks/useStreamingAuth'
import { useLocale, useStreamingAuth } from '@emqx/shared-ui-utils'
import { computed } from 'vue'
interface StreamACL {
principal_type: string
Expand All @@ -82,7 +81,6 @@ interface StreamACL {
}
const props = defineProps<{
tipComponent: Component
modelValue: StreamACL
isEdit: boolean
// TODO: try to optimize
Expand Down
3 changes: 1 addition & 2 deletions packages/components/streaming/StreamingAuthForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<script setup lang="ts">
import { StreamAuthType } from '@emqx/shared-ui-constants'
import { useLocale } from '@emqx/shared-ui-utils'
import { Component, computed } from 'vue'
import { computed } from 'vue'
interface StreamRecord {
user_name: string
Expand All @@ -32,7 +32,6 @@ interface StreamRecord {
}
const props = defineProps<{
tipComponent: Component
modelValue: StreamRecord
isEdit: boolean
// TODO: try to optimize
Expand Down
1 change: 1 addition & 0 deletions packages/utils/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './format'
export * from './download'
export * from './useBatchSettings'
export * from './useLocale'
export * from './useStreamingAuth'
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
import { StreamOperation, StreamPermission, StreamResourceType } from '@emqx/shared-ui-constants'
import { useLocale } from '@emqx/shared-ui-utils'
import { computed } from 'vue'
import { useLocale } from './useLocale'

export default (lang: string) => {
export const useStreamingAuth = (lang: string) => {
const { t } = useLocale(lang)

const permissionOptions = computed(() => {
return [
{
label: t('streaming.allow'),
value: StreamPermission.Allow,
},
{
label: t('streaming.deny'),
value: StreamPermission.Deny,
},
]
})
const resourceTypeOptions = computed(() => {
return [
{
label: t('acl.topic'),
value: StreamResourceType.Topic,
},
{
label: t('streaming.consumerGroupType'),
value: StreamResourceType.Group,
},
{
label: t('streaming.clusterType'),
value: StreamResourceType.Cluster,
},
]
})
const operationOptions = computed(() => {
return Object.values(StreamOperation).map((value) => {
return {
label: t(`streaming.aclOperationLabelDic.${value}`),
value,
}
})
const permissionOptions = [
{
label: t('streaming.allow'),
value: StreamPermission.Allow,
},
{
label: t('streaming.deny'),
value: StreamPermission.Deny,
},
]
const resourceTypeOptions = [
{
label: t('acl.topic'),
value: StreamResourceType.Topic,
},
{
label: t('streaming.consumerGroupType'),
value: StreamResourceType.Group,
},
{
label: t('streaming.clusterType'),
value: StreamResourceType.Cluster,
},
]
const operationOptions = Object.values(StreamOperation).map((value) => {
return {
label: t(`streaming.aclOperationLabelDic.${value}`),
value,
}
})

const validOperationMap: Record<StreamResourceType, Array<StreamOperation>> = {
Expand All @@ -65,7 +58,7 @@ export default (lang: string) => {
],
}
const getValidOperations = (resourceType: StreamResourceType) => {
const list = validOperationMap[resourceType]
const list = validOperationMap[resourceType] || []
return list.map((value) => {
return {
label: t(`streaming.aclOperationLabelDic.${value}`),
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"release": "npm publish"
},
"dependencies": {
"@emqx/shared-ui-constants": "link:../constants",
"@emqx/shared-ui-i18n": "link:../i18n",
"json-bigint": "^1.0.0",
"papaparse": "^5.4.1",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28dce4f

Please sign in to comment.