mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
refactor: make "clone wiki" the first tab
This commit is contained in:
parent
5396df24af
commit
d8cd3cfcac
3 changed files with 28 additions and 13 deletions
|
|
@ -59,7 +59,7 @@ const previousToken = getGithubToken();
|
|||
previousToken && setHeaderToGraphqlClient(previousToken);
|
||||
|
||||
export default function AddWorkspace() {
|
||||
const [currentTab, currentTabSetter] = useState(0);
|
||||
const [currentTab, currentTabSetter] = useState('CloneOnlineWiki');
|
||||
const [isCreateMainWorkspace, isCreateMainWorkspaceSetter] = useState(countWorkspace() === 0);
|
||||
const [parentFolderLocation, parentFolderLocationSetter] = useState(getDesktopPath());
|
||||
const [existedFolderLocation, existedFolderLocationSetter] = useState(getDesktopPath());
|
||||
|
|
@ -138,6 +138,7 @@ export default function AddWorkspace() {
|
|||
accessToken={accessToken}
|
||||
githubWikiUrlSetter={githubWikiUrlSetter}
|
||||
userInfo={userInfo}
|
||||
wikiFolderNameSetter={wikiFolderNameSetter}
|
||||
isCreateMainWorkspace={isCreateMainWorkspace}
|
||||
/>
|
||||
</SyncContainer>
|
||||
|
|
@ -152,7 +153,7 @@ export default function AddWorkspace() {
|
|||
/>
|
||||
|
||||
{syncContainer}
|
||||
{currentTab === 0 && (
|
||||
{currentTab === 'CreateNewWiki' && (
|
||||
<Container>
|
||||
<NewWikiPathForm
|
||||
parentFolderLocation={parentFolderLocation}
|
||||
|
|
@ -177,7 +178,7 @@ export default function AddWorkspace() {
|
|||
/>
|
||||
</Container>
|
||||
)}
|
||||
{currentTab === 1 && (
|
||||
{currentTab === 'OpenLocalWiki' && (
|
||||
<Container>
|
||||
<ExistedWikiPathForm
|
||||
existedFolderLocationSetter={existedFolderLocationSetter}
|
||||
|
|
@ -201,7 +202,7 @@ export default function AddWorkspace() {
|
|||
/>
|
||||
</Container>
|
||||
)}
|
||||
{currentTab === 2 && (
|
||||
{currentTab === 'CloneOnlineWiki' && (
|
||||
<Container>
|
||||
<NewWikiPathForm
|
||||
parentFolderLocation={parentFolderLocation}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ type Props = {|
|
|||
accessToken?: string,
|
||||
githubWikiUrl: string,
|
||||
githubWikiUrlSetter: string => void,
|
||||
wikiFolderNameSetter: string => void,
|
||||
userInfo?: IUserInfo,
|
||||
isCreateMainWorkspace: boolean,
|
||||
|};
|
||||
|
|
@ -72,6 +73,7 @@ export default function SearchRepo({
|
|||
accessToken,
|
||||
githubWikiUrl,
|
||||
githubWikiUrlSetter,
|
||||
wikiFolderNameSetter,
|
||||
userInfo,
|
||||
isCreateMainWorkspace,
|
||||
}: Props) {
|
||||
|
|
@ -148,7 +150,10 @@ export default function SearchRepo({
|
|||
<ListItem
|
||||
button
|
||||
key={url}
|
||||
onClick={() => githubWikiUrlSetter(url)}
|
||||
onClick={() => {
|
||||
githubWikiUrlSetter(url);
|
||||
wikiFolderNameSetter(name);
|
||||
}}
|
||||
selected={trim(githubWikiUrl) === trim(url)}
|
||||
>
|
||||
<ListItemIcon>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import { invert } from 'lodash';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
|
|
@ -9,28 +10,36 @@ import Tab from '@material-ui/core/Tab';
|
|||
|
||||
function a11yProps(index) {
|
||||
return {
|
||||
id: `simple-tab-${index}`,
|
||||
id: index,
|
||||
'aria-controls': `simple-tabpanel-${index}`,
|
||||
};
|
||||
}
|
||||
|
||||
const tabIndexMap = {
|
||||
CloneOnlineWiki: 0,
|
||||
CreateNewWiki: 1,
|
||||
OpenLocalWiki: 2,
|
||||
};
|
||||
|
||||
export interface IProps {
|
||||
currentTab: number;
|
||||
currentTabSetter: number => void;
|
||||
currentTab: string;
|
||||
currentTabSetter: string => void;
|
||||
}
|
||||
export default function TabBar({ currentTab, currentTabSetter }: IProps) {
|
||||
const { t } = useTranslation();
|
||||
// DEBUG: console
|
||||
console.log(`currentTab`, currentTab);
|
||||
return (
|
||||
<AppBar position="static">
|
||||
<Paper square>
|
||||
<Tabs
|
||||
value={currentTab}
|
||||
onChange={(event, newValue) => currentTabSetter(newValue)}
|
||||
value={tabIndexMap[currentTab]}
|
||||
onChange={(event, newValue) => currentTabSetter(invert(tabIndexMap)[newValue])}
|
||||
aria-label={t('AddWorkspace.SwitchCreateNewOrOpenExisted')}
|
||||
>
|
||||
<Tab label={t('AddWorkspace.CreateNewWiki')} {...a11yProps(0)} />
|
||||
<Tab label={t('AddWorkspace.OpenLocalWiki')} {...a11yProps(1)} />
|
||||
<Tab label={t('AddWorkspace.CloneOnlineWiki')} {...a11yProps(2)} />
|
||||
<Tab label={t('AddWorkspace.CloneOnlineWiki')} {...a11yProps('CloneOnlineWiki')} />
|
||||
<Tab label={t('AddWorkspace.CreateNewWiki')} {...a11yProps('CreateNewWiki')} />
|
||||
<Tab label={t('AddWorkspace.OpenLocalWiki')} {...a11yProps('OpenLocalWiki')} />
|
||||
</Tabs>
|
||||
</Paper>
|
||||
</AppBar>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue