You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by zh...@apache.org on 2022/07/20 14:28:08 UTC
[incubator-seatunnel] branch dev updated: [Feat][UI] Add the user dropdown in the dashboard layout. (#2228)
This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new e96fbd884 [Feat][UI] Add the user dropdown in the dashboard layout. (#2228)
e96fbd884 is described below
commit e96fbd884be474f847ea38d2ab2b32e217742335
Author: songjianet <17...@qq.com>
AuthorDate: Wed Jul 20 22:28:03 2022 +0800
[Feat][UI] Add the user dropdown in the dashboard layout. (#2228)
---
.../src/layouts/dashboard/header/setting/index.tsx | 6 +++-
.../src/layouts/dashboard/header/user/index.tsx | 34 +++++++++++++-----
.../user/{index.tsx => use-user-dropdown.ts} | 41 +++++++++++++---------
seatunnel-ui/src/locales/en_US/menu.ts | 4 ++-
4 files changed, 58 insertions(+), 27 deletions(-)
diff --git a/seatunnel-ui/src/layouts/dashboard/header/setting/index.tsx b/seatunnel-ui/src/layouts/dashboard/header/setting/index.tsx
index cc8d30c31..291740da3 100644
--- a/seatunnel-ui/src/layouts/dashboard/header/setting/index.tsx
+++ b/seatunnel-ui/src/layouts/dashboard/header/setting/index.tsx
@@ -34,7 +34,11 @@ const Setting = defineComponent({
class='h-16 w-12'
style={{ cursor: 'pointer' }}
>
- <NDropdown trigger='click' options={this.dropdownOptions} onSelect={this.handleSelect}>
+ <NDropdown
+ trigger='click'
+ options={this.dropdownOptions}
+ onSelect={this.handleSelect}
+ >
<NIcon size='20'>
<SettingOutlined />
</NIcon>
diff --git a/seatunnel-ui/src/layouts/dashboard/header/user/index.tsx b/seatunnel-ui/src/layouts/dashboard/header/user/index.tsx
index ce19cc65a..582b7447b 100644
--- a/seatunnel-ui/src/layouts/dashboard/header/user/index.tsx
+++ b/seatunnel-ui/src/layouts/dashboard/header/user/index.tsx
@@ -15,19 +15,35 @@
* limitations under the License.
*/
-import { defineComponent } from 'vue'
-import { NSpace } from 'naive-ui'
+import { defineComponent, toRefs } from 'vue'
+import { NSpace, NDropdown } from 'naive-ui'
+import { useUserDropdown } from './use-user-dropdown'
const User = defineComponent({
- setup() {},
+ setup() {
+ const { state, handleSelect } = useUserDropdown()
+
+ return { ...toRefs(state), handleSelect }
+ },
render() {
return (
- <NSpace justify='center' align='center' class='h-16 w-12 mr-2'>
- <img
- class='h-10 w-10 rounded-full'
- src='https://avatars.githubusercontent.com/u/19239641?s=64&v=4'
- alt=''
- />
+ <NSpace
+ justify='center'
+ align='center'
+ class='h-16 w-12 mr-2'
+ style={{ cursor: 'pointer' }}
+ >
+ <NDropdown
+ trigger='click'
+ options={this.dropdownOptions}
+ onSelect={this.handleSelect}
+ >
+ <img
+ class='h-10 w-10 rounded-full'
+ src='https://avatars.githubusercontent.com/u/19239641?s=64&v=4'
+ alt=''
+ />
+ </NDropdown>
</NSpace>
)
}
diff --git a/seatunnel-ui/src/layouts/dashboard/header/user/index.tsx b/seatunnel-ui/src/layouts/dashboard/header/user/use-user-dropdown.ts
similarity index 54%
copy from seatunnel-ui/src/layouts/dashboard/header/user/index.tsx
copy to seatunnel-ui/src/layouts/dashboard/header/user/use-user-dropdown.ts
index ce19cc65a..0544c647d 100644
--- a/seatunnel-ui/src/layouts/dashboard/header/user/index.tsx
+++ b/seatunnel-ui/src/layouts/dashboard/header/user/use-user-dropdown.ts
@@ -15,22 +15,31 @@
* limitations under the License.
*/
-import { defineComponent } from 'vue'
-import { NSpace } from 'naive-ui'
+import { reactive } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useRouter } from 'vue-router'
+import type { Router } from 'vue-router'
-const User = defineComponent({
- setup() {},
- render() {
- return (
- <NSpace justify='center' align='center' class='h-16 w-12 mr-2'>
- <img
- class='h-10 w-10 rounded-full'
- src='https://avatars.githubusercontent.com/u/19239641?s=64&v=4'
- alt=''
- />
- </NSpace>
- )
+export function useUserDropdown() {
+ const router: Router = useRouter()
+ const { t } = useI18n()
+
+ const dropdownOptions = [
+ { key: 'help', label: t('menu.help') },
+ { key: 'logout', label: t('menu.logout') }
+ ]
+
+ const state = reactive({
+ dropdownOptions
+ })
+
+ const handleSelect = (key: string) => {
+ if (key === 'help') {
+ window.open('http://seatunnel.incubator.apache.org/versions/')
+ } else if (key === 'logout') {
+ router.push({ path: '/login' })
+ }
}
-})
-export default User
+ return { state, handleSelect }
+}
diff --git a/seatunnel-ui/src/locales/en_US/menu.ts b/seatunnel-ui/src/locales/en_US/menu.ts
index d20b48aa9..f931fed33 100644
--- a/seatunnel-ui/src/locales/en_US/menu.ts
+++ b/seatunnel-ui/src/locales/en_US/menu.ts
@@ -18,5 +18,7 @@
export default {
datapipes: 'Datapipes',
manage: 'Manage',
- user_manage: 'User Manage'
+ user_manage: 'User Manage',
+ help: 'Help',
+ logout: 'Logout'
}