feat: try add token tabs

This commit is contained in:
tiddlygit-test 2021-04-12 00:50:34 +08:00
parent 06ff5750b5
commit f75a9b838f
3 changed files with 43 additions and 24 deletions

View file

@ -1,11 +1,10 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { Paper, Typography } from '@material-ui/core'; import { Paper, Typography, Tabs, Tab, TabPanel } from '@material-ui/core';
import SearchRepo from '@/components/github/SearchRepo'; import SearchRepo from '@/components/github/SearchRepo';
import { SupportedStorageServices } from '@services/types';
import { GithubTokenForm } from '../github/git-token-form'; const Container = styled(Paper)`
const SyncContainer = styled(Paper)`
margin-top: 5px; margin-top: 5px;
`; `;
const GithubRepoLink = styled(Typography)` const GithubRepoLink = styled(Typography)`
@ -16,25 +15,39 @@ const GithubRepoLink = styled(Typography)`
} }
`; `;
const a11yProps = (
index: SupportedStorageServices,
): {
id: string;
'aria-controls': string;
} => ({
id: index,
'aria-controls': `simple-tabpanel-${index}`,
});
/**
* Create storage provider's token.
* @returns
*/
export function TokenForm(): JSX.Element { export function TokenForm(): JSX.Element {
const [currentTab, currentTabSetter] = useState<SupportedStorageServices>(SupportedStorageServices.github);
return ( return (
<SyncContainer elevation={2} square> <Container elevation={2} square>
<GithubTokenForm> <Tabs
{githubWikiUrl?.length > 0 ? ( orientation="vertical"
<GithubRepoLink onClick={async () => await window.service.native.open(githubWikiUrl)} variant="subtitle2" align="center"> variant="scrollable"
({githubWikiUrl}) value={currentTab}
</GithubRepoLink> onChange={(_event, newValue: SupportedStorageServices) => currentTabSetter(newValue)}
) : undefined} aria-label="Vertical tabs example">
<SearchRepo <Tab label="GitHub" {...a11yProps(SupportedStorageServices.github)} />
githubWikiUrl={githubWikiUrl} <Tab label="GitLab" {...a11yProps(SupportedStorageServices.gitlab)} />
accessToken={accessToken} </Tabs>
githubWikiUrlSetter={githubWikiUrlSetter} <TabPanel value={currentTab} index={0}>
userInfo={userInfo} Item One
currentTab={currentTab} </TabPanel>
wikiFolderNameSetter={wikiFolderNameSetter} <TabPanel value={currentTab} index={1}>
isCreateMainWorkspace={isCreateMainWorkspace} Item Two
/> </TabPanel>
</GithubTokenForm> </Container>
</SyncContainer> );
) }
}

View file

@ -4,6 +4,8 @@ import { GraphQLClient, ClientContext } from 'graphql-hooks';
import { GITHUB_GRAPHQL_API } from '../../constants/auth'; import { GITHUB_GRAPHQL_API } from '../../constants/auth';
import { TokenForm } from '@/components/TokenForm';
import { Description } from './Description'; import { Description } from './Description';
import { NewWikiForm } from './NewWikiForm'; import { NewWikiForm } from './NewWikiForm';
@ -40,6 +42,8 @@ export default function AddWorkspace(): JSX.Element {
<TabBar currentTab={currentTab} currentTabSetter={currentTabSetter} /> <TabBar currentTab={currentTab} currentTabSetter={currentTabSetter} />
<Description isCreateMainWorkspace={isCreateMainWorkspace} isCreateMainWorkspaceSetter={isCreateMainWorkspaceSetter} /> <Description isCreateMainWorkspace={isCreateMainWorkspace} isCreateMainWorkspaceSetter={isCreateMainWorkspaceSetter} />
<TokenForm />
{currentTab === 'CreateNewWiki' && ( {currentTab === 'CreateNewWiki' && (
<Container> <Container>
<NewWikiForm form={form} isCreateMainWorkspace={isCreateMainWorkspace} /> <NewWikiForm form={form} isCreateMainWorkspace={isCreateMainWorkspace} />

View file

@ -6,6 +6,8 @@ export enum SupportedStorageServices {
local = 'local', local = 'local',
/** High availability git service without storage limit, but is blocked by GFW in China somehow */ /** High availability git service without storage limit, but is blocked by GFW in China somehow */
github = 'github', github = 'github',
/** Open source git service */
gitlab = 'gitlab',
/** SocialLinkedData, a privacy first DApp platform leading by Tim Berners-Lee, you can run a server by you own */ /** SocialLinkedData, a privacy first DApp platform leading by Tim Berners-Lee, you can run a server by you own */
solid = 'solid', solid = 'solid',
/** China's Collaboration platform for software development & code hosting, /** China's Collaboration platform for software development & code hosting,