-
-
Notifications
You must be signed in to change notification settings - Fork 355
feat: implement tab close functionality with i18n support #2049
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
bb9d7f0
ff2e881
08faa61
233d918
27dd17f
3926d29
ea59dcd
dc01bea
f5367f7
f801c7e
c0f2df5
aa0ce39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,12 @@ | ||
| import {Badge, Button, Dropdown, Spin, Tabs} from 'antd'; | ||
| import {LinkOutlined} from '@ant-design/icons'; | ||
| import {Badge, Button, Spin, Tabs} from 'antd'; | ||
| import _ from 'lodash'; | ||
| import {useEffect} from 'react'; | ||
| import {useNavigate} from 'react-router'; | ||
|
|
||
| import {ADD_CLOUD_PROVIDER_TAB_KEY, SERVER_TYPES, SESSION_BUILDER_TABS} from '../../constants/session-builder'; | ||
| import {BUTTON} from '../../constants/antd-types'; | ||
| import {LINKS} from '../../constants/common'; | ||
| import { | ||
| ADD_CLOUD_PROVIDER_TAB_KEY, | ||
| SERVER_TYPES, | ||
| SESSION_BUILDER_TABS, | ||
| } from '../../constants/session-builder'; | ||
| import {ipcRenderer, openLink} from '../../polyfills'; | ||
| import {log} from '../../utils/logger'; | ||
| import AdvancedServerParams from './AdvancedServerParams.jsx'; | ||
|
|
@@ -24,11 +20,12 @@ | |
|
|
||
| const Session = (props) => { | ||
| const { | ||
| tabKey, | ||
| switchTabs, | ||
| serverType, | ||
| setServerType, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No such function exists. You probably wanted to use |
||
| server, | ||
| visibleProviders = [], | ||
| removeVisibleProvider, | ||
| caps, | ||
| capsUUID, | ||
| capsName, | ||
|
|
@@ -45,7 +42,7 @@ | |
|
|
||
| const navigate = useNavigate(); | ||
|
|
||
| const isAttaching = tabKey === 'attach'; | ||
| const isAttaching = serverType === 'attach'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this was changed. |
||
|
|
||
| const handleSelectServerTab = async (tab) => { | ||
| const {changeServerType, addCloudProvider} = props; | ||
|
|
@@ -62,14 +59,38 @@ | |
| } | ||
| }; | ||
|
|
||
| const getContextMenu = (tabKey) => ({ | ||
| items: [ | ||
| { | ||
| key: 'closeTab', | ||
| label: t('Close tab'), | ||
| onClick: () => handleCloseTab(tabKey), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this action will also trigger |
||
| disabled: tabKey === SERVER_TYPES.REMOTE | ||
| } | ||
| ] | ||
| }); | ||
|
|
||
| const handleContextMenu = (e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| }; | ||
|
|
||
| const handleCloseTab = (tabKey) => { | ||
| if (tabKey !== SERVER_TYPES.REMOTE) { | ||
| removeVisibleProvider(tabKey); | ||
| if (serverType === tabKey) { | ||
| setServerType(SERVER_TYPES.REMOTE); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| const { | ||
| setLocalServerParams, | ||
| getSavedSessions, | ||
| setSavedServerParams, | ||
| initFromSessionFile, | ||
| setStateFromSessionFile, | ||
| setVisibleProviders, | ||
| bindWindowClose, | ||
| initFromQueryString, | ||
| saveSessionAsFile, | ||
|
|
@@ -79,7 +100,6 @@ | |
| bindWindowClose(); | ||
| switchTabs(SESSION_BUILDER_TABS.CAPS_BUILDER); | ||
| await getSavedSessions(); | ||
| await setVisibleProviders(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why this was removed? |
||
| await setSavedServerParams(); | ||
| await setLocalServerParams(); | ||
| initFromQueryString(loadNewSession); | ||
|
|
@@ -114,7 +134,13 @@ | |
| return true; | ||
| } | ||
| return { | ||
| label: <div>{provider.tabhead()}</div>, | ||
| label: ( | ||
| <Dropdown menu={getContextMenu(providerName)} trigger={['contextMenu']}> | ||
| <div onContextMenu={(e) => handleContextMenu(e)}> | ||
| {provider.tabhead()} | ||
| </div> | ||
| </Dropdown> | ||
| ), | ||
| key: providerName, | ||
| children: provider.tab(props), | ||
| }; | ||
|
|
@@ -129,7 +155,7 @@ | |
| </div> | ||
|
|
||
| <Tabs | ||
| activeKey={tabKey} | ||
| activeKey={serverType} | ||
| onChange={switchTabs} | ||
| className={SessionStyles.scrollingTabCont} | ||
| items={[ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is enough to only add English resources. localized resources are synchronized automatically to crowdin as soon as the PR is merged and should not be changed manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only kept English resources