Skip to content

Commit

Permalink
book/ changes (#156 in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
tima101 committed May 21, 2021
1 parent 354b944 commit d859a19
Show file tree
Hide file tree
Showing 217 changed files with 16,558 additions and 11,026 deletions.
5 changes: 5 additions & 0 deletions book/10-begin/api/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"watch": ["server"],
"exec": "ts-node --project tsconfig.server.json",
"ext": "ts"
}
5 changes: 3 additions & 2 deletions book/10-begin/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only --project tsconfig.server.json server/server.ts",
"dev": "nodemon server/server.ts",
"lint": "eslint . --ext .ts,.tsx",
"test": "jest"
},
Expand Down Expand Up @@ -57,8 +57,9 @@
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^26.4.2",
"nodemon": "^2.0.7",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"ts-node-dev": "^1.0.0-pre.44"
"ts-node": "^9.1.1"
}
}
719 changes: 440 additions & 279 deletions book/10-begin/api/yarn.lock

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions book/10-begin/app/components/common/Confirmer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ import React from 'react';

export let openConfirmDialogExternal;

class Confirmer extends React.Component {
public state = {
open: false,
title: 'Are you sure?',
message: '',
onAnswer: null,
};
type State = {
open: boolean;
title: string;
message: string;
onAnswer: (answer) => void;
};

class Confirmer extends React.Component<any, State> {
constructor(props) {
super(props);

this.state = {
open: false,
title: 'Are you sure?',
message: '',
onAnswer: null,
};

openConfirmDialogExternal = this.openConfirmDialog;
}

Expand Down
6 changes: 5 additions & 1 deletion book/10-begin/app/components/common/LoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ type Props = { invitationToken?: string };
type State = { email: string };

class LoginButton extends React.PureComponent<Props, State> {
public state = { email: '' };
constructor(props) {
super(props);

this.state = { email: '' };
}

public render() {
const { invitationToken } = this.props;
Expand Down
8 changes: 4 additions & 4 deletions book/10-begin/app/components/common/MemberChooser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ type Props = {
helperText?: string;
};

class MemberChooser extends React.Component<Props> {
public state = {
selectedItems: [],
};
type State = {
selectedItems: { label: string; id: string }[];
};

class MemberChooser extends React.Component<Props, State> {
constructor(props) {
super(props);

Expand Down
53 changes: 34 additions & 19 deletions book/10-begin/app/components/common/MenuWithLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import Link from 'next/link';
import { NextRouter, withRouter } from 'next/router';
import Router from 'next/router';
import React from 'react';

class MenuWithLinks extends React.PureComponent<{
type Props = {
options: any[];
router: NextRouter;
}> {
public state = {
anchorEl: null,
};
};

type State = {
anchorEl: Element | ((element: Element) => Element);
};

class MenuWithLinks extends React.PureComponent<Props, State> {
constructor(props) {
super(props);

this.state = {
anchorEl: null,
};
}

public render() {
const { options, children, router } = this.props;
Expand All @@ -35,25 +45,30 @@ class MenuWithLinks extends React.PureComponent<{
>
{options.map((option, i) =>
option.separator ? (
<hr style={{ width: '85%', margin: '10px auto' }} key={`separated-${i}`} />
) : (
<hr style={{ width: '95%', margin: '10px auto' }} key={`separated-${i}`} />
) : option.externalServer ? (
<MenuItem
onClick={() => {
if (option.externalServer) {
window.location.href = option.href;
} else {
Router.push(option.href, option.as || option.href);
}
onClick={(event) => {
event.preventDefault();
window.location.href = option.href;
this.handleClose();
}}
key={option.href}
style={{
fontWeight: router.asPath.includes(option.highlighterSlug) ? 600 : 300,
fontSize: '14px',
}}
key={option.href || option.text}
>
{option.text}
</MenuItem>
) : (
<Link key={option.href} href={option.href} as={option.as} passHref>
<MenuItem
key={option.href}
style={{
fontWeight: router.asPath.includes(option.highlighterSlug) ? 600 : 300,
fontSize: '14px',
}}
>
{option.text}
</MenuItem>
</Link>
),
)}
</Menu>
Expand Down
20 changes: 15 additions & 5 deletions book/10-begin/app/components/common/MenuWithMenuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import React from 'react';

class MenuWithMenuItems extends React.PureComponent<{
type Props = {
menuOptions: any;
itemOptions: any[];
}> {
public state = {
menuElem: null,
};
};

type State = {
menuElem: Element | ((element: Element) => Element);
};

class MenuWithMenuItems extends React.PureComponent<Props, State> {
constructor(props) {
super(props);

this.state = {
menuElem: null,
};
}

public render() {
const { menuOptions, itemOptions } = this.props;
Expand Down
15 changes: 10 additions & 5 deletions book/10-begin/app/components/common/Notifier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import React from 'react';

export let openSnackbarExternal;

class Notifier extends React.PureComponent {
public state = {
open: false,
message: '',
};
type State = {
open: boolean;
message: string;
};

class Notifier extends React.PureComponent<any, State> {
constructor(props) {
super(props);
openSnackbarExternal = this.openSnackbar;

this.state = {
open: false,
message: '',
};
}

public render() {
Expand Down
17 changes: 10 additions & 7 deletions book/10-begin/app/components/discussions/CreateDiscussionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ type State = {
};

class CreateDiscussionForm extends React.Component<Props, State> {
public state = {
name: '',
memberIds: [],
disabled: false,
content: '',
notificationType: 'default',
};
constructor(props) {
super(props);

this.state = {
name: '',
memberIds: [],
disabled: false,
content: '',
notificationType: 'default',
};
}
public render() {
const { open, isMobile, store } = this.props;
const { currentTeam, currentUser } = store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ type State = {
};

class DiscussionActionMenu extends React.Component<Props, State> {
public state = {
discussionFormOpen: false,
selectedDiscussion: null,
};
constructor(props) {
super(props);

this.state = {
discussionFormOpen: false,
selectedDiscussion: null,
};
}

public render() {
const { discussion, store } = this.props;
Expand Down
14 changes: 10 additions & 4 deletions book/10-begin/app/components/discussions/DiscussionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ import notify from '../../lib/notify';

type Props = { store: Store; team: Team; isMobile: boolean };

class DiscussionList extends React.Component<Props> {
public state = {
discussionFormOpen: false,
};
type State = { discussionFormOpen: boolean };

class DiscussionList extends React.Component<Props, State> {
constructor(props) {
super(props);

this.state = {
discussionFormOpen: false,
};
}

public componentDidMount() {
this.props.team.loadDiscussions().catch((err) => notify(err));
Expand Down
18 changes: 11 additions & 7 deletions book/10-begin/app/components/discussions/EditDiscussionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ type State = {
};

class EditDiscussionForm extends React.Component<Props, State> {
public state = {
name: '',
memberIds: [],
disabled: false,
discussionId: '',
notificationType: 'default',
};
constructor(props) {
super(props);

this.state = {
name: '',
memberIds: [],
disabled: false,
discussionId: '',
notificationType: 'default',
};
}

public static getDerivedStateFromProps(props: Props, state: State) {
const { discussion } = props;
Expand Down
10 changes: 7 additions & 3 deletions book/10-begin/app/components/posts/PostEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ type Props = {
type State = { htmlContent: string };

class PostEditor extends React.Component<Props, State> {
public state = {
htmlContent: '',
};
constructor(props) {
super(props);

this.state = {
htmlContent: '',
};
}

public render() {
const { htmlContent } = this.state;
Expand Down
14 changes: 9 additions & 5 deletions book/10-begin/app/components/posts/PostForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ type State = {
};

class PostForm extends React.Component<Props, State> {
public state = {
postId: null,
content: '',
disabled: false,
};
constructor(props) {
super(props);

this.state = {
postId: null,
content: '',
disabled: false,
};
}

public static getDerivedStateFromProps(props: Props, state: State) {
const { post } = props;
Expand Down
12 changes: 8 additions & 4 deletions book/10-begin/app/components/teams/InviteMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ type State = {
};

class InviteMember extends React.Component<Props, State> {
public state = {
email: '',
disabled: false,
};
constructor(props) {
super(props);

this.state = {
email: '',
disabled: false,
};
}

public render() {
const { open } = this.props;
Expand Down
5 changes: 5 additions & 0 deletions book/10-begin/app/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"watch": ["server"],
"exec": "ts-node --project tsconfig.server.json",
"ext": "ts"
}
5 changes: 3 additions & 2 deletions book/10-begin/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only --project tsconfig.server.json --ignore-watch .next --ignore-watch components --ignore-watch lib --ignore-watch pages server/server.ts",
"dev": "nodemon server/server.ts",
"build": "next build",
"lint": "eslint . --ext .ts,.tsx"
},
Expand Down Expand Up @@ -45,7 +45,8 @@
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.21.5",
"nodemon": "^2.0.7",
"prettier": "^2.2.1",
"ts-node-dev": "^1.0.0-pre.44"
"ts-node": "^9.1.1"
}
}
Loading

0 comments on commit d859a19

Please sign in to comment.