webui: move pages components

This commit is contained in:
Quentin Gliech 2020-02-13 20:00:03 +01:00
parent 8b85780d76
commit ce6f6a984b
No known key found for this signature in database
GPG Key ID: 22D62B84552719FC
44 changed files with 205 additions and 139 deletions

View File

@ -29,9 +29,13 @@ module.exports = {
position: 'after', position: 'after',
}, },
], ],
groups: [['builtin', 'external'], 'parent', ['sibling', 'index']], pathGroupsExcludedImportTypes: ["builtin"],
groups: [['builtin', 'external'], ['internal', 'parent'], ['sibling', 'index']],
'newlines-between': 'always', 'newlines-between': 'always',
}, },
], ],
}, },
settings: {
'import/internal-regex': '^src/',
},
}; };

View File

@ -1,68 +1,17 @@
import AppBar from '@material-ui/core/AppBar';
import CssBaseline from '@material-ui/core/CssBaseline';
import Toolbar from '@material-ui/core/Toolbar';
import {
createMuiTheme,
ThemeProvider,
makeStyles,
} from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import { Route, Switch } from 'react-router'; import { Route, Switch } from 'react-router';
import { Link } from 'react-router-dom';
import CurrentIdentity from './CurrentIdentity'; import Layout from './layout';
import BugQuery from './bug/BugQuery'; import BugPage from './pages/bug';
import ListQuery from './list/ListQuery'; import ListPage from './pages/list';
const theme = createMuiTheme({
palette: {
primary: {
main: '#263238',
},
},
});
const useStyles = makeStyles(theme => ({
offset: {
...theme.mixins.toolbar,
},
filler: {
flexGrow: 1,
},
appTitle: {
...theme.typography.h6,
color: 'white',
textDecoration: 'none',
display: 'flex',
alignItems: 'center',
},
logo: {
height: '42px',
marginRight: theme.spacing(2),
},
}));
export default function App() { export default function App() {
const classes = useStyles();
return ( return (
<ThemeProvider theme={theme}> <Layout>
<CssBaseline />
<AppBar position="fixed" color="primary">
<Toolbar>
<Link to="/" className={classes.appTitle}>
<img src="/logo.svg" className={classes.logo} alt="git-bug" />
git-bug
</Link>
<div className={classes.filler}></div>
<CurrentIdentity />
</Toolbar>
</AppBar>
<div className={classes.offset} />
<Switch> <Switch>
<Route path="/" exact component={ListQuery} /> <Route path="/" exact component={ListPage} />
<Route path="/bug/:id" exact component={BugQuery} /> <Route path="/bug/:id" exact component={BugPage} />
</Switch> </Switch>
</ThemeProvider> </Layout>
); );
} }

View File

@ -1,4 +1,4 @@
import { parse, stringify, quote } from '../list/Filter'; import { parse, stringify, quote } from 'src/pages/list/Filter';
it('parses a simple query', () => { it('parses a simple query', () => {
expect(parse('foo:bar')).toEqual({ expect(parse('foo:bar')).toEqual({

18
webui/src/apollo.ts Normal file
View File

@ -0,0 +1,18 @@
import ApolloClient from 'apollo-boost';
import {
IntrospectionFragmentMatcher,
InMemoryCache,
} from 'apollo-cache-inmemory';
import introspectionQueryResultData from './fragmentTypes';
const client = new ApolloClient({
uri: '/graphql',
cache: new InMemoryCache({
fragmentMatcher: new IntrospectionFragmentMatcher({
introspectionQueryResultData,
}),
}),
});
export default client;

View File

@ -1,6 +1,7 @@
import React from 'react';
import MAvatar from '@material-ui/core/Avatar'; import MAvatar from '@material-ui/core/Avatar';
import Tooltip from '@material-ui/core/Tooltip/Tooltip'; import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import React from 'react';
import { AuthoredFragment } from './fragments.generated'; import { AuthoredFragment } from './fragments.generated';

View File

@ -1,6 +1,7 @@
import { makeStyles } from '@material-ui/styles';
import React from 'react'; import React from 'react';
import { makeStyles } from '@material-ui/styles';
const useStyles = makeStyles({ const useStyles = makeStyles({
tag: { tag: {
maxWidth: '100%', maxWidth: '100%',

View File

@ -1,6 +1,7 @@
import { makeStyles } from '@material-ui/styles';
import React from 'react'; import React from 'react';
import { makeStyles } from '@material-ui/styles';
const useStyles = makeStyles({ const useStyles = makeStyles({
tag: { tag: {
maxWidth: '100%', maxWidth: '100%',

View File

@ -1,8 +1,9 @@
import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import moment from 'moment'; import moment from 'moment';
import React from 'react'; import React from 'react';
import Moment from 'react-moment'; import Moment from 'react-moment';
import Tooltip from '@material-ui/core/Tooltip/Tooltip';
const HOUR = 1000 * 3600; const HOUR = 1000 * 3600;
const DAY = 24 * HOUR; const DAY = 24 * HOUR;
const WEEK = 7 * DAY; const WEEK = 7 * DAY;

View File

@ -1,13 +1,15 @@
import React from 'react';
import { common } from '@material-ui/core/colors'; import { common } from '@material-ui/core/colors';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import { import {
getContrastRatio, getContrastRatio,
darken, darken,
} from '@material-ui/core/styles/colorManipulator'; } from '@material-ui/core/styles/colorManipulator';
import React from 'react';
import { Color } from 'src/gqlTypes';
import { LabelFragment } from './fragments.generated'; import { LabelFragment } from './fragments.generated';
import { Color } from '../gqlTypes';
// Minimum contrast between the background and the text color // Minimum contrast between the background and the text color
const contrastThreshold = 2.5; const contrastThreshold = 2.5;

View File

@ -1,36 +1,19 @@
import { createMuiTheme } from '@material-ui/core/styles';
import ThemeProvider from '@material-ui/styles/ThemeProvider';
import ApolloClient from 'apollo-boost';
import {
IntrospectionFragmentMatcher,
InMemoryCache,
} from 'apollo-cache-inmemory';
import React from 'react'; import React from 'react';
import { ApolloProvider } from 'react-apollo'; import { ApolloProvider } from 'react-apollo';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import ThemeProvider from '@material-ui/styles/ThemeProvider';
import App from './App'; import App from './App';
import introspectionQueryResultData from './fragmentTypes'; import apolloClient from './apollo';
import theme from './theme';
const theme = createMuiTheme();
const client = new ApolloClient({
uri: '/graphql',
cache: new InMemoryCache({
fragmentMatcher: new IntrospectionFragmentMatcher({
introspectionQueryResultData,
}),
}),
});
ReactDOM.render( ReactDOM.render(
<ApolloProvider client={client}> <ApolloProvider client={apolloClient}>
<BrowserRouter> <BrowserRouter>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<React.Suspense fallback={'Loading…'}>
<App /> <App />
</React.Suspense>
</ThemeProvider> </ThemeProvider>
</BrowserRouter> </BrowserRouter>
</ApolloProvider>, </ApolloProvider>,

View File

@ -1,6 +1,7 @@
import React from 'react';
import Avatar from '@material-ui/core/Avatar'; import Avatar from '@material-ui/core/Avatar';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import React from 'react';
import { useCurrentIdentityQuery } from './CurrentIdentity.generated'; import { useCurrentIdentityQuery } from './CurrentIdentity.generated';

View File

@ -0,0 +1,50 @@
import React from 'react';
import { Link } from 'react-router-dom';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import { makeStyles } from '@material-ui/core/styles';
import CurrentIdentity from './CurrentIdentity';
const useStyles = makeStyles(theme => ({
offset: {
...theme.mixins.toolbar,
},
filler: {
flexGrow: 1,
},
appTitle: {
...theme.typography.h6,
color: 'white',
textDecoration: 'none',
display: 'flex',
alignItems: 'center',
},
logo: {
height: '42px',
marginRight: theme.spacing(2),
},
}));
function Header() {
const classes = useStyles();
return (
<>
<AppBar position="fixed" color="primary">
<Toolbar>
<Link to="/" className={classes.appTitle}>
<img src="/logo.svg" className={classes.logo} alt="git-bug" />
git-bug
</Link>
<div className={classes.filler}></div>
<CurrentIdentity />
</Toolbar>
</AppBar>
<div className={classes.offset} />
</>
);
}
export default Header;

View File

@ -0,0 +1,18 @@
import React from 'react';
import CssBaseline from '@material-ui/core/CssBaseline';
import Header from './Header';
type Props = { children: React.ReactNode };
function Layout({ children }: Props) {
return (
<>
<CssBaseline />
<Header />
{children}
</>
);
}
export default Layout;

View File

@ -1,10 +1,11 @@
import Typography from '@material-ui/core/Typography/Typography';
import { makeStyles } from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import Author from '../components/Author'; import Typography from '@material-ui/core/Typography/Typography';
import Date from '../components/Date'; import { makeStyles } from '@material-ui/core/styles';
import Label from '../components/Label';
import Author from 'src/components/Author';
import Date from 'src/components/Date';
import Label from 'src/components/Label';
import { BugFragment } from './Bug.generated'; import { BugFragment } from './Bug.generated';
import CommentForm from './CommentForm'; import CommentForm from './CommentForm';

View File

@ -1,7 +1,8 @@
import CircularProgress from '@material-ui/core/CircularProgress';
import React from 'react'; import React from 'react';
import { RouteComponentProps } from 'react-router-dom'; import { RouteComponentProps } from 'react-router-dom';
import CircularProgress from '@material-ui/core/CircularProgress';
import Bug from './Bug'; import Bug from './Bug';
import { useGetBugQuery } from './BugQuery.generated'; import { useGetBugQuery } from './BugQuery.generated';

View File

@ -1,12 +1,13 @@
import React, { useState, useRef } from 'react';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import Tab from '@material-ui/core/Tab'; import Tab from '@material-ui/core/Tab';
import Tabs from '@material-ui/core/Tabs'; import Tabs from '@material-ui/core/Tabs';
import TextField from '@material-ui/core/TextField'; import TextField from '@material-ui/core/TextField';
import { makeStyles, Theme } from '@material-ui/core/styles'; import { makeStyles, Theme } from '@material-ui/core/styles';
import React, { useState, useRef } from 'react';
import Content from '../components/Content'; import Content from 'src/components/Content';
import { useAddCommentMutation } from './CommentForm.generated'; import { useAddCommentMutation } from './CommentForm.generated';
import { TimelineDocument } from './TimelineQuery.generated'; import { TimelineDocument } from './TimelineQuery.generated';

View File

@ -1,9 +1,10 @@
import { makeStyles } from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import Author from '../components/Author'; import { makeStyles } from '@material-ui/core/styles';
import Date from '../components/Date';
import Label from '../components/Label'; import Author from 'src/components/Author';
import Date from 'src/components/Date';
import Label from 'src/components/Label';
import { LabelChangeFragment } from './LabelChangeFragment.generated'; import { LabelChangeFragment } from './LabelChangeFragment.generated';

View File

@ -1,4 +1,4 @@
#import "../components/fragments.graphql" #import "../../components/fragments.graphql"
fragment LabelChange on LabelChangeTimelineItem { fragment LabelChange on LabelChangeTimelineItem {
date date

View File

@ -1,10 +1,11 @@
import Paper from '@material-ui/core/Paper';
import { makeStyles } from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import Author, { Avatar } from '../components/Author'; import Paper from '@material-ui/core/Paper';
import Date from '../components/Date'; import { makeStyles } from '@material-ui/core/styles';
import Content from '../components/Content';
import Author, { Avatar } from 'src/components/Author';
import Content from 'src/components/Content';
import Date from 'src/components/Date';
import { AddCommentFragment } from './MessageCommentFragment.generated'; import { AddCommentFragment } from './MessageCommentFragment.generated';
import { CreateFragment } from './MessageCreateFragment.generated'; import { CreateFragment } from './MessageCreateFragment.generated';

View File

@ -1,4 +1,4 @@
#import "../components/fragments.graphql" #import "../../components/fragments.graphql"
fragment AddComment on AddCommentTimelineItem { fragment AddComment on AddCommentTimelineItem {
createdAt createdAt

View File

@ -1,4 +1,4 @@
#import "../components/fragments.graphql" #import "../../components/fragments.graphql"
fragment Create on CreateTimelineItem { fragment Create on CreateTimelineItem {
createdAt createdAt

View File

@ -1,8 +1,9 @@
import { makeStyles } from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import Author from '../components/Author'; import { makeStyles } from '@material-ui/core/styles';
import Date from '../components/Date';
import Author from 'src/components/Author';
import Date from 'src/components/Date';
import { SetStatusFragment } from './SetStatusFragment.generated'; import { SetStatusFragment } from './SetStatusFragment.generated';

View File

@ -1,4 +1,4 @@
#import "../components/fragments.graphql" #import "../../components/fragments.graphql"
fragment SetStatus on SetStatusTimelineItem { fragment SetStatus on SetStatusTimelineItem {
date date

View File

@ -1,8 +1,9 @@
import { makeStyles } from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import Author from '../components/Author'; import { makeStyles } from '@material-ui/core/styles';
import Date from '../components/Date';
import Author from 'src/components/Author';
import Date from 'src/components/Date';
import { SetTitleFragment } from './SetTitleFragment.generated'; import { SetTitleFragment } from './SetTitleFragment.generated';

View File

@ -1,4 +1,4 @@
#import "../components/fragments.graphql" #import "../../components/fragments.graphql"
fragment SetTitle on SetTitleTimelineItem { fragment SetTitle on SetTitleTimelineItem {
date date

View File

@ -1,6 +1,7 @@
import { makeStyles } from '@material-ui/core/styles';
import React from 'react'; import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import LabelChange from './LabelChange'; import LabelChange from './LabelChange';
import Message from './Message'; import Message from './Message';
import SetStatus from './SetStatus'; import SetStatus from './SetStatus';

View File

@ -1,6 +1,7 @@
import CircularProgress from '@material-ui/core/CircularProgress';
import React from 'react'; import React from 'react';
import CircularProgress from '@material-ui/core/CircularProgress';
import Timeline from './Timeline'; import Timeline from './Timeline';
import { useTimelineQuery } from './TimelineQuery.generated'; import { useTimelineQuery } from './TimelineQuery.generated';

View File

@ -0,0 +1 @@
export { default } from './BugQuery';

View File

@ -1,4 +1,4 @@
#import "../components/fragments.graphql" #import "../../components/fragments.graphql"
fragment BugRow on Bug { fragment BugRow on Bug {
id id

View File

@ -1,15 +1,16 @@
import React from 'react';
import { Link } from 'react-router-dom';
import TableCell from '@material-ui/core/TableCell/TableCell'; import TableCell from '@material-ui/core/TableCell/TableCell';
import TableRow from '@material-ui/core/TableRow/TableRow'; import TableRow from '@material-ui/core/TableRow/TableRow';
import Tooltip from '@material-ui/core/Tooltip/Tooltip'; import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline'; import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';
import ErrorOutline from '@material-ui/icons/ErrorOutline'; import ErrorOutline from '@material-ui/icons/ErrorOutline';
import React from 'react';
import { Link } from 'react-router-dom';
import Date from '../components/Date'; import Date from 'src/components/Date';
import Label from '../components/Label'; import Label from 'src/components/Label';
import { Status } from '../gqlTypes'; import { Status } from 'src/gqlTypes';
import { BugRowFragment } from './BugRow.generated'; import { BugRowFragment } from './BugRow.generated';

View File

@ -1,12 +1,13 @@
import clsx from 'clsx';
import { LocationDescriptor } from 'history';
import React, { useState, useRef } from 'react';
import { Link } from 'react-router-dom';
import Menu from '@material-ui/core/Menu'; import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import { SvgIconProps } from '@material-ui/core/SvgIcon'; import { SvgIconProps } from '@material-ui/core/SvgIcon';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import ArrowDropDown from '@material-ui/icons/ArrowDropDown'; import ArrowDropDown from '@material-ui/icons/ArrowDropDown';
import clsx from 'clsx';
import { LocationDescriptor } from 'history';
import React, { useState, useRef } from 'react';
import { Link } from 'react-router-dom';
export type Query = { [key: string]: Array<string> }; export type Query = { [key: string]: Array<string> };

View File

@ -1,10 +1,11 @@
import { pipe } from '@arrows/composition'; import { pipe } from '@arrows/composition';
import { LocationDescriptor } from 'history';
import React from 'react';
import Toolbar from '@material-ui/core/Toolbar'; import Toolbar from '@material-ui/core/Toolbar';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline'; import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';
import ErrorOutline from '@material-ui/icons/ErrorOutline'; import ErrorOutline from '@material-ui/icons/ErrorOutline';
import { LocationDescriptor } from 'history';
import React from 'react';
import { import {
FilterDropdown, FilterDropdown,

View File

@ -1,6 +1,7 @@
import React from 'react';
import Table from '@material-ui/core/Table/Table'; import Table from '@material-ui/core/Table/Table';
import TableBody from '@material-ui/core/TableBody/TableBody'; import TableBody from '@material-ui/core/TableBody/TableBody';
import React from 'react';
import BugRow from './BugRow'; import BugRow from './BugRow';
import { BugListFragment } from './ListQuery.generated'; import { BugListFragment } from './ListQuery.generated';

View File

@ -1,3 +1,7 @@
import { ApolloError } from 'apollo-boost';
import React, { useState, useEffect, useRef } from 'react';
import { useLocation, useHistory, Link } from 'react-router-dom';
import IconButton from '@material-ui/core/IconButton'; import IconButton from '@material-ui/core/IconButton';
import InputBase from '@material-ui/core/InputBase'; import InputBase from '@material-ui/core/InputBase';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
@ -6,9 +10,6 @@ import ErrorOutline from '@material-ui/icons/ErrorOutline';
import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft'; import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft';
import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight'; import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight';
import Skeleton from '@material-ui/lab/Skeleton'; import Skeleton from '@material-ui/lab/Skeleton';
import { ApolloError } from 'apollo-boost';
import React, { useState, useEffect, useRef } from 'react';
import { useLocation, useHistory, Link } from 'react-router-dom';
import FilterToolbar from './FilterToolbar'; import FilterToolbar from './FilterToolbar';
import List from './List'; import List from './List';

View File

@ -0,0 +1 @@
export { default } from './ListQuery';

11
webui/src/theme.ts Normal file
View File

@ -0,0 +1,11 @@
import { createMuiTheme } from '@material-ui/core/styles';
const theme = createMuiTheme({
palette: {
primary: {
main: '#263238',
},
},
});
export default theme;

View File

@ -1,7 +1,11 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": ["dom", "dom.iterable", "esnext"], "lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, "esModuleInterop": true,
@ -14,7 +18,13 @@
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "noEmit": true,
"jsx": "react", "jsx": "react",
"typeRoots": ["node_modules/@types/", "types/"] "typeRoots": [
"node_modules/@types/",
"types/"
],
"baseUrl": "."
}, },
"include": ["src"] "include": [
"src"
]
} }