Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Copy workspace info #8265

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion web/app/components/header/account-dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Indicator from '../indicator'
import AccountAbout from '../account-about'
import { mailToSupport } from '../utils/util'
import WorkplaceSelector from './workplace-selector'
import Button from '@/app/components/base/button'
import classNames from '@/utils/classnames'
import I18n from '@/context/i18n'
import Avatar from '@/app/components/base/avatar'
Expand All @@ -21,6 +22,7 @@ import { useModalContext } from '@/context/modal-context'
import { LanguagesSupported } from '@/i18n/language'
import { useProviderContext } from '@/context/provider-context'
import { Plan } from '@/app/components/billing/type'
import { ToastContext } from '@/app/components/base/toast'

export type IAppSelector = {
isMobile: boolean
Expand All @@ -40,6 +42,8 @@ export default function AppSelector({ isMobile }: IAppSelector) {
const { setShowAccountSettingModal } = useModalContext()
const { plan } = useProviderContext()
const canEmailSupport = plan.type === Plan.professional || plan.type === Plan.team || plan.type === Plan.enterprise
const { notify } = useContext(ToastContext)
const { currentWorkspace } = useAppContext()

const handleLogout = async () => {
await logout({
Expand All @@ -53,6 +57,11 @@ export default function AppSelector({ isMobile }: IAppSelector) {
router.push('/signin')
}

const handleCopyWorkspaceInfo = async () => {
await navigator.clipboard.writeText(`${currentWorkspace?.name || ''}(${currentWorkspace?.id || ''})`)
notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') })
}

return (
<div className="">
<Menu as="div" className="relative inline-block text-left">
Expand Down Expand Up @@ -102,7 +111,15 @@ export default function AppSelector({ isMobile }: IAppSelector) {
</div>
</Menu.Item>
<div className='px-1 py-1'>
<div className='mt-2 px-3 text-xs font-medium text-gray-500'>{t('common.userProfile.workspace')}</div>
<div className='flex'>
<div className='mt-2 px-3 text-xs font-medium text-gray-500'>{t('common.userProfile.workspace')}</div>
<Button
className="rounded ml-2 mt-1 px-2 text-xs font-medium hover:bg-gray-200 bg-slate-100 text-gray-500"
size='small'
onClick={handleCopyWorkspaceInfo}
>{t('common.operation.copy')}
</Button>
</div>
<WorkplaceSelector />
</div>
<div className="px-1 py-1">
Expand Down