Open platform to collect and prioritize feedback
tools: Format Typescript with Prettier (#315)
Luke Sheard27922598a9d3
diff --git a/.prettierrc b/.prettierrcnew file mode 100644index 000000000..fc0f50306--- /dev/null+++ b/.prettierrc@@ -0,0 +1,4 @@+{+ "printWidth": 120,+ "singleQuote": false+}diff --git a/Makefile b/Makefileindex a64870d14..fb3deaff0 100644--- a/Makefile+++ b/Makefile@@ -4,10 +4,13 @@ BUILD_TIME=$(shell date +"%Y.%m.%d.%H%M%S")build:rm -rf distgo build -ldflags='-s -w -X main.buildtime=${BUILD_TIME}' -o fider .- ./node_modules/.bin/webpack -p+ npx webpack -plint:- ./node_modules/.bin/tslint -c tslint.json 'public/**/*.{ts,tsx}'+ npx tslint -c tslint.json 'public/**/*.{ts,tsx}'++lint-fix:+ npx tslint -c tslint.json 'public/**/*.{ts,tsx}' --fix# Testingtest:@@ -32,7 +35,7 @@ e2e:watch:rm -rf distgin --buildArgs "-ldflags='-s -w -X main.buildtime=${BUILD_TIME}'" &- ./node_modules/.bin/webpack --watch+ npx webpack --watchrun:godotenv -f .env ./fiderdiff --git a/README.md b/README.mdindex e14577dc1..03b279471 100644--- a/README.md+++ b/README.md@@ -2,7 +2,7 @@# Fider · [](https://circleci.com/gh/getfider/fider/tree/master) [](https://codecov.io/gh/getfider/fider)-Fider is an open platform to collect and organize customer feedback. By using the platform, your community can share, vote and discuss on ideas they have to make your product or company even better.+Fider is an open platform to collect and organize customer feedback. By using the platform, your community can share, vote and discuss on ideas they have to make your product or company even better.You can [see it in action](https://feedback.fider.io/) or visit http://getfider.com to learn more about all features and how to get started.@@ -16,9 +16,9 @@ You can [see it in action](https://feedback.fider.io/) or visit http://getfider.We have a monthly [GitHub Milestone](https://github.com/getfider/fider/milestones) that lists everything that is due to be released on that month.-- **Found a bug?** Create an issue on [GitHub](https://github.com/getfider/fider/issues).-- **Want to request a feature?** Suggest it on [Feedback for Fider](https://feedback.fider.io/).-- **Got a question?** Send a Tweet to [@getfider](twitter.com/getfider) or email [email protected].+* **Found a bug?** Create an issue on [GitHub](https://github.com/getfider/fider/issues).+* **Want to request a feature?** Suggest it on [Feedback for Fider](https://feedback.fider.io/).+* **Got a question?** Send a Tweet to [@getfider](twitter.com/getfider) or email [email protected].Read how you can help the project on [CONTRIBUTING.md](CONTRIBUTING.md).@@ -26,5 +26,4 @@ Read how you can help the project on [CONTRIBUTING.md](CONTRIBUTING.md).Thanks to [BrowserStack](https://browserstack.com/) for providing us with free cross-browser testing for Fider.-[](https://browserstack.com/)diff --git a/package-lock.json b/package-lock.jsonindex be2b98ee5..e836e5935 100644--- a/package-lock.json+++ b/package-lock.json@@ -1555,6 +1555,16 @@"estraverse": "4.2.0"}},+ "eslint-plugin-prettier": {+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.0.tgz",+ "integrity": "sha512-floiaI4F7hRkTrFe8V2ItOK97QYrX75DjmdzmVITZoAP6Cn06oEDPQRsO6MlHEP/u2SxI3xQ52Kpjw6j5WGfeQ==",+ "dev": true,+ "requires": {+ "fast-diff": "1.1.2",+ "jest-docblock": "21.2.0"+ }+ },"esprima": {"version": "2.7.3","resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz",@@ -1880,6 +1890,12 @@"integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=","dev": true},+ "fast-diff": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.1.2.tgz",+ "integrity": "sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig==",+ "dev": true+ },"fast-json-stable-stringify": {"version": "2.0.0","resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",@@ -3717,6 +3733,12 @@"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=","dev": true},+ "jest-docblock": {+ "version": "21.2.0",+ "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz",+ "integrity": "sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==",+ "dev": true+ },"jquery": {"version": "3.3.1","resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",@@ -5603,6 +5625,12 @@"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=","dev": true},+ "prettier": {+ "version": "1.11.1",+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.11.1.tgz",+ "integrity": "sha512-T/KD65Ot0PB97xTrG8afQ46x3oiVhnfGjGESSI9NWYcG92+OUPZKkwHqGWXH2t9jK1crnQjubECW0FuOth+hxw==",+ "dev": true+ },"process": {"version": "0.11.10","resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",@@ -6892,6 +6920,22 @@}}},+ "tslint-config-prettier": {+ "version": "1.9.0",+ "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.9.0.tgz",+ "integrity": "sha512-glCHJJrJYXoP/nvhrmb7gt7q2Er0PaXu3zwySpIxRZvCYgBWt8l+Qi4VVTgFt5Moj/1klWg08PxxjE3/7hvp3Q==",+ "dev": true+ },+ "tslint-plugin-prettier": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/tslint-plugin-prettier/-/tslint-plugin-prettier-1.3.0.tgz",+ "integrity": "sha512-6UqeeV6EABp0RdQkW6eC1vwnAXcKMGJgPeJ5soXiKdSm2vv7c3dp+835CM8pjgx9l4uSa7tICm1Kli+SMsADDg==",+ "dev": true,+ "requires": {+ "eslint-plugin-prettier": "2.6.0",+ "tslib": "1.9.0"+ }+ },"tslint-react": {"version": "3.5.1","resolved": "https://registry.npmjs.org/tslint-react/-/tslint-react-3.5.1.tgz",diff --git a/package.json b/package.jsonindex 0441e0a5f..4b0cc61c8 100644--- a/package.json+++ b/package.json@@ -12,7 +12,6 @@"semantic-ui-css": "2.2.14"},"devDependencies": {- "reflect-metadata": "^0.1.12","@types/jquery": "^3.3.0","@types/markdown-it": "0.0.4","@types/mocha": "^2.2.48",@@ -27,10 +26,14 @@"file-loader": "^1.1.10","mocha": "^5.0.1","node-sass": "^4.7.2",+ "prettier": "^1.11.1",+ "reflect-metadata": "^0.1.12","sass-loader": "^6.0.6","selenium-webdriver": "^3.6.0","ts-loader": "^3.5.0","tslint": "^5.9.1",+ "tslint-config-prettier": "^1.9.0",+ "tslint-plugin-prettier": "^1.3.0","tslint-react": "^3.5.1","typescript": "^2.7.2","webpack": "^3.11.0",diff --git a/public/components/ShowIdeaResponse.tsx b/public/components/ShowIdeaResponse.tsxindex 796bbd363..01b5049c6 100644--- a/public/components/ShowIdeaResponse.tsx+++ b/public/components/ShowIdeaResponse.tsx@@ -1,6 +1,6 @@-import * as React from 'react';-import { User, IdeaResponse, IdeaStatus } from '@fider/models';-import { Gravatar, MultiLineText, Moment, UserName } from '@fider/components/common';+import * as React from "react";+import { User, IdeaResponse, IdeaStatus } from "@fider/models";+import { Gravatar, MultiLineText, Moment, UserName } from "@fider/components/common";interface IdeaResponseProps {status: number;@@ -38,14 +38,14 @@ export const ShowIdeaResponse = (props: IdeaResponseProps): JSX.Element => {return (<div className="fdr-response item ui segment"><span className={`ui mini label ${status.color}`}>{status.title}</span>- <Gravatar user={props.response.user}/> <UserName user={props.response.user} />+ <Gravatar user={props.response.user} /> <UserName user={props.response.user} /><span className="info">- <Moment date={props.response.respondedOn} />+ <Moment date={props.response.respondedOn} /></span>{status === IdeaStatus.Duplicate ? DuplicateDetails(props) : StatusDetails(props)}</div>);}- return <div/>;+ return <div />;};diff --git a/public/components/ShowTag.tsx b/public/components/ShowTag.tsxindex a1de9e78b..57724604b 100644--- a/public/components/ShowTag.tsx+++ b/public/components/ShowTag.tsx@@ -1,9 +1,9 @@-import * as React from 'react';-import { Tag } from '@fider/models';+import * as React from "react";+import { Tag } from "@fider/models";interface TagProps {tag: Tag;- size?: 'mini' | 'tiny' | 'small' | 'normal' | 'large';+ size?: "mini" | "tiny" | "small" | "normal" | "large";circular?: boolean;}@@ -21,25 +21,25 @@ const getRGB = (color: string) => {const idealTextColor = (color: string) => {const components = getRGB(color);- const bgDelta = (components.R * 0.299) + (components.G * 0.587) + (components.B * 0.114);- return (bgDelta > 140) ? '#333' : '#fff';+ const bgDelta = components.R * 0.299 + components.G * 0.587 + components.B * 0.114;+ return bgDelta > 140 ? "#333" : "#fff";};export const ShowTag = (props: TagProps) => {- const formatClass = props.circular === true ? 'empty circular' : '';- const sizeClass = props.size || 'normal';+ const formatClass = props.circular === true ? "empty circular" : "";+ const sizeClass = props.size || "normal";return (<div- title={`${props.tag.name}${!props.tag.isPublic ? ' (Private)' : ''}`}+ title={`${props.tag.name}${!props.tag.isPublic ? " (Private)" : ""}`}className={`ui label ${sizeClass} ${formatClass}`}style={{backgroundColor: `#${props.tag.color}`,color: idealTextColor(props.tag.color)}}>- {!props.tag.isPublic && !props.circular && <i className="lock icon"/>}- {props.circular ? '' : props.tag.name || 'Tag'}+ {!props.tag.isPublic && !props.circular && <i className="lock icon" />}+ {props.circular ? "" : props.tag.name || "Tag"}</div>);};diff --git a/public/components/SignInModal.tsx b/public/components/SignInModal.tsxindex bb09f4d66..f07413a20 100644--- a/public/components/SignInModal.tsx+++ b/public/components/SignInModal.tsx@@ -1,5 +1,5 @@-import * as React from 'react';-import { Modal, SignInControl } from '@fider/components/common';+import * as React from "react";+import { Modal, SignInControl } from "@fider/components/common";interface SignInModalProps {isOpen: boolean;@@ -16,8 +16,8 @@ export class SignInModal extends React.Component<SignInModalProps, SignInModalStsuper(props);this.state = {isOpen: this.props.isOpen,- email: '',- emailSent: false,+ email: "",+ emailSent: false};this.onEmailSent = this.onEmailSent.bind(this);@@ -32,32 +32,33 @@ export class SignInModal extends React.Component<SignInModalProps, SignInModalStprivate onEmailSent(email: string): void {this.setState({ email, emailSent: true }, () => {setTimeout(() => {- this.setState({ email: '', emailSent: false });+ this.setState({ email: "", emailSent: false });}, 5000);});}public render() {- const content = this.state.emailSent- ? (+ const content = this.state.emailSent ? (<>- <p>We have just sent a confirmation link to <b>{this.state.email}</b>. <br /> Click the link and you’ll be signed in.</p>- <p><a href="#" onClick={() => this.setState({ isOpen: false, emailSent: false })}>OK</a></p>+ <p>+ We have just sent a confirmation link to <b>{this.state.email}</b>. <br /> Click the link and you’ll be signed+ in.+ </p>+ <p>+ <a href="#" onClick={() => this.setState({ isOpen: false, emailSent: false })}>+ OK+ </a>+ </p></>- )- : (+ ) : (<SignInControl useEmail={true} onEmailSent={this.onEmailSent} />);return (<Modal.Window isOpen={this.state.isOpen}>- <Modal.Header>- Sign in to raise your voice- </Modal.Header>+ <Modal.Header>Sign in to raise your voice</Modal.Header>- <Modal.Content>- {content}- </Modal.Content>+ <Modal.Content>{content}</Modal.Content></Modal.Window>);}diff --git a/public/components/SupportCounter.tsx b/public/components/SupportCounter.tsxindex 03e5960ad..cd9cf6ef7 100644--- a/public/components/SupportCounter.tsx+++ b/public/components/SupportCounter.tsx@@ -1,9 +1,9 @@-import './SupportCounter.scss';+import "./SupportCounter.scss";-import * as React from 'react';-import { Idea, User, IdeaStatus } from '@fider/models';-import { page, actions, device, classSet } from '@fider/services';-import { SignInModal } from '@fider/components';+import * as React from "react";+import { Idea, User, IdeaStatus } from "@fider/models";+import { page, actions, device, classSet } from "@fider/services";+import { SignInModal } from "@fider/components";interface SupportCounterProps {user?: User;@@ -17,13 +17,12 @@ interface SupportCounterState {}export class SupportCounter extends React.Component<SupportCounterProps, SupportCounterState> {-constructor(props: SupportCounterProps) {super(props);this.state = {supported: props.idea.viewerSupported,total: props.idea.totalSupporters,- showSignIn: false,+ showSignIn: false};}@@ -37,7 +36,7 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportconst response = await action(this.props.idea.number);if (response.ok) {- this.setState((state) => ({+ this.setState(state => ({supported: !state.supported,total: state.total + (state.supported ? -1 : 1)}));@@ -48,16 +47,13 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportconst status = IdeaStatus.Get(this.props.idea.status);const className = classSet({- 'supported': !status.closed && this.state.supported,- 'disabled': status.closed,- 'no-touch': !device.isTouch(),+ supported: !status.closed && this.state.supported,+ disabled: status.closed,+ "no-touch": !device.isTouch()});const vote = (- <button- className={className}- onClick={async () => await this.supportOrUndo()}- >+ <button className={className} onClick={async () => await this.supportOrUndo()}><i className="medium caret up icon" />{this.state.total}</button>@@ -70,12 +66,10 @@ export class SupportCounter extends React.Component<SupportCounterProps, Support</button>);- return (+ return (<><SignInModal isOpen={this.state.showSignIn} />- <div className="c-support-counter">- {status.closed ? disabled : vote}- </div>+ <div className="c-support-counter">{status.closed ? disabled : vote}</div></>);}diff --git a/public/components/common/Button.tsx b/public/components/common/Button.tsxindex 234abe860..cff945aa3 100644--- a/public/components/common/Button.tsx+++ b/public/components/common/Button.tsx@@ -1,14 +1,14 @@-import * as React from 'react';-import { classSet } from '@fider/services';+import * as React from "react";+import { classSet } from "@fider/services";interface ButtonProps {className?: string;simple?: boolean;disabled?: boolean;href?: string;- color?: 'green' | 'red';+ color?: "green" | "red";fluid?: boolean;- size?: 'mini' | 'tiny' | 'small' | 'normal' | 'large';+ size?: "mini" | "tiny" | "small" | "normal" | "large";onClick?: (event: ButtonClickEvent) => Promise<any>;}@@ -16,7 +16,7 @@ interface ButtonState {clicked: boolean;}-import './Button.scss';+import "./Button.scss";export class ButtonClickEvent {private shouldEnable = true;@@ -32,8 +32,8 @@ export class Button extends React.Component<ButtonProps, ButtonState> {private unmounted: boolean = false;public static defaultProps: Partial<ButtonProps> = {- size: 'normal',- fluid: false,+ size: "normal",+ fluid: false};public constructor(props: ButtonProps) {@@ -69,14 +69,14 @@ export class Button extends React.Component<ButtonProps, ButtonState> {public render() {const className = classSet({- 'c-button': true,- 'as-link': this.props.simple,- 'fluid': this.props.fluid,+ "c-button": true,+ "as-link": this.props.simple,+ fluid: this.props.fluid,[this.props.size!]: this.props.size,[this.props.color!]: this.props.color,- 'loading': this.state.clicked,- 'disabled': this.state.clicked || this.props.disabled,- [this.props.className!]: this.props.className,+ loading: this.state.clicked,+ disabled: this.state.clicked || this.props.disabled,+ [this.props.className!]: this.props.className});if (this.props.href) {@@ -87,7 +87,7 @@ export class Button extends React.Component<ButtonProps, ButtonState> {);} else {return (- <button type="button" className={className} onClick={(e) => this.click(e)}>+ <button type="button" className={className} onClick={e => this.click(e)}>{this.props.children}</button>);diff --git a/public/components/common/DisplayError.tsx b/public/components/common/DisplayError.tsxindex 49175648f..395b5c43c 100644--- a/public/components/common/DisplayError.tsx+++ b/public/components/common/DisplayError.tsx@@ -1,12 +1,12 @@-import * as React from 'react';-import { Failure } from '@fider/services';+import * as React from "react";+import { Failure } from "@fider/services";const arrayToTag = (items: string[]) => {- return items.map((m) => <li key={m}>{m}</li>);+ return items.map(m => <li key={m}>{m}</li>);};interface DisplayErrorProps {- pointing?: 'above' | 'below';+ pointing?: "above" | "below";error?: Failure;fields?: string[];}@@ -16,7 +16,7 @@ export const DisplayError = (props: DisplayErrorProps) => {return null;}- const pointing = props.pointing || 'below';+ const pointing = props.pointing || "below";let items: JSX.Element[] = [];@@ -26,17 +26,14 @@ export const DisplayError = (props: DisplayErrorProps) => {for (const field of props.fields || Object.keys(props.error.failures)) {if (props.error.failures.hasOwnProperty(field)) {const tags = arrayToTag(props.error.failures[field]);- tags.forEach((t) => items.push(t));+ tags.forEach(t => items.push(t));}}}- return (- items.length > 0- ? (- <div className={`display-error ui pointing ${pointing} red basic label`}>- <ul>{items}</ul>- </div>- ) : null- );+ return items.length > 0 ? (+ <div className={`display-error ui pointing ${pointing} red basic label`}>+ <ul>{items}</ul>+ </div>+ ) : null;};diff --git a/public/components/common/EnvironmentInfo.tsx b/public/components/common/EnvironmentInfo.tsxindex b99286532..b947b809c 100644--- a/public/components/common/EnvironmentInfo.tsx+++ b/public/components/common/EnvironmentInfo.tsx@@ -1,5 +1,5 @@-import * as React from 'react';-import { SystemSettings } from '@fider/models';+import * as React from "react";+import { SystemSettings } from "@fider/models";interface EnvironmentInfoProps {system: SystemSettings;@@ -7,19 +7,14 @@ interface EnvironmentInfoProps {export class EnvironmentInfo extends React.Component<EnvironmentInfoProps, {}> {public render() {- if (this.props.system.environment === 'production') {+ if (this.props.system.environment === "production") {return null;}return (- <div- id="environment-info"- className=" ui mini negative message no-border no-margin"- >- Env: {this.props.system.environment} |- Compiler: {this.props.system.compiler} |- Version: {this.props.system.version} |- BuildTime: {this.props.system.buildTime}+ <div id="environment-info" className=" ui mini negative message no-border no-margin">+ Env: {this.props.system.environment} | Compiler: {this.props.system.compiler} | Version:{" "}+ {this.props.system.version} | BuildTime: {this.props.system.buildTime}</div>);}diff --git a/public/components/common/Footer.tsx b/public/components/common/Footer.tsxindex 96b57afab..9d20475dc 100644--- a/public/components/common/Footer.tsx+++ b/public/components/common/Footer.tsx@@ -1,11 +1,11 @@-import * as React from 'react';-const logo = require('@fider/assets/images/logo-small.png');+import * as React from "react";+const logo = require("@fider/assets/images/logo-small.png");export const Footer = () => {return (<div id="footer" className="ui vertical footer segment"><div className="ui center aligned container">- <div className="ui inverted section divider"/>+ <div className="ui inverted section divider" /><div className="ui horizontal small divided link list"><div id="powered-by"><a className="item" target="_blank" href="http://getfider.com/">diff --git a/public/components/common/Form.tsx b/public/components/common/Form.tsxindex 131b1a983..67b037b3c 100644--- a/public/components/common/Form.tsx+++ b/public/components/common/Form.tsx@@ -1,6 +1,6 @@-import * as React from 'react';-import { Failure } from '@fider/services';-import { DisplayError } from './';+import * as React from "react";+import { Failure } from "@fider/services";+import { DisplayError } from "./";interface FormProps {onSubmit?: () => Promise<any>;@@ -34,7 +34,7 @@ export class Form extends React.Component<FormProps, FormState> {public render() {return (- <form autoComplete="off" className="ui form" onSubmit={(e) => this.submit(e)}>+ <form autoComplete="off" className="ui form" onSubmit={e => this.submit(e)}><DisplayError error={this.state && this.state.failure} />{this.props.children}</form>diff --git a/public/components/common/Gravatar.tsx b/public/components/common/Gravatar.tsxindex fc305ce63..340403fb8 100644--- a/public/components/common/Gravatar.tsx+++ b/public/components/common/Gravatar.tsx@@ -1,13 +1,13 @@-import * as React from 'react';-import { page } from '@fider/services';-import { User, UserRole } from '@fider/models';+import * as React from "react";+import { page } from "@fider/services";+import { User, UserRole } from "@fider/models";interface GravatarProps {user?: User;}export const Gravatar = (props: GravatarProps) => {- const name = props.user ? props.user.name : '_';+ const name = props.user ? props.user.name : "_";const id = props.user ? props.user.id : 0;const url = `${page.getBaseUrl()}/avatars/50/${id}/${encodeURIComponent(name)}`;@@ -16,8 +16,8 @@ export const Gravatar = (props: GravatarProps) => {let element: any;return (<img- ref={(e) => element = e}- className={`ui fdr-avatar image ${isCollaborator && 'staff'}`}+ ref={e => (element = e)}+ className={`ui fdr-avatar image ${isCollaborator && "staff"}`}title={name}src={url}/>diff --git a/public/components/common/Header.tsx b/public/components/common/Header.tsxindex dc9bf61f6..58a165715 100644--- a/public/components/common/Header.tsx+++ b/public/components/common/Header.tsx@@ -1,9 +1,9 @@-import './Header.scss';+import "./Header.scss";-import * as React from 'react';-import { SystemSettings, CurrentUser, Tenant } from '@fider/models';-import { SignInModal, SignInControl, EnvironmentInfo, Gravatar } from '@fider/components';-import { page, actions } from '@fider/services';+import * as React from "react";+import { SystemSettings, CurrentUser, Tenant } from "@fider/models";+import { SignInModal, SignInControl, EnvironmentInfo, Gravatar } from "@fider/components";+import { page, actions } from "@fider/services";interface HeaderProps {user?: CurrentUser;@@ -17,7 +17,6 @@ interface HeaderState {}export class Header extends React.Component<HeaderProps, HeaderState> {-constructor(props: HeaderProps) {super(props);this.state = {@@ -28,7 +27,7 @@ export class Header extends React.Component<HeaderProps, HeaderState> {public componentDidMount(): void {if (this.props.user) {- actions.getTotalUnreadNotifications().then((result) => {+ actions.getTotalUnreadNotifications().then(result => {if (result.ok && result.data > 0) {this.setState({ unreadNotifications: result.data });}@@ -45,51 +44,63 @@ export class Header extends React.Component<HeaderProps, HeaderState> {public render() {const items = this.props.user && (<div className="ui vertical menu">- <div className="name header">- <i className="user icon" />- {this.props.user.name}- </div>- <a href="/settings" className="item">Settings</a>- <a href="/notifications" className="item">- Notifications- {this.state.unreadNotifications > 0 && <div className="ui mini circular red label">{this.state.unreadNotifications}</div>}- </a>- <div className="divider" />- {- this.props.user.isCollaborator && [- <div key={1} className="header">- <i className="setting icon" />- Administration- </div>,- <a key={2} href="/admin" className="item">General Settings</a>,- <a key={3} href="/admin/members" className="item">Members</a>,- <a key={4} href="/admin/tags" className="item">Tags</a>,- <div key={5} className="divider" />- ]- }- <a href="/signout?redirect=/" className="item signout">Sign out</a>+ <div className="name header">+ <i className="user icon" />+ {this.props.user.name}+ </div>+ <a href="/settings" className="item">+ Settings+ </a>+ <a href="/notifications" className="item">+ Notifications+ {this.state.unreadNotifications > 0 && (+ <div className="ui mini circular red label">{this.state.unreadNotifications}</div>+ )}+ </a>+ <div className="divider" />+ {this.props.user.isCollaborator && [+ <div key={1} className="header">+ <i className="setting icon" />+ Administration+ </div>,+ <a key={2} href="/admin" className="item">+ General Settings+ </a>,+ <a key={3} href="/admin/members" className="item">+ Members+ </a>,+ <a key={4} href="/admin/tags" className="item">+ Tags+ </a>,+ <div key={5} className="divider" />+ ]}+ <a href="/signout?redirect=/" className="item signout">+ Sign out+ </a></div>);return (<div className="c-header">- <EnvironmentInfo system={this.props.system}/>+ <EnvironmentInfo system={this.props.system} /><SignInModal isOpen={this.state.showSignIn} /><div id="menu" className="ui small borderless menu"><div className="ui container"><a href="/" className="header item">{this.props.tenant.name}</a>- <div onClick={() => this.showModal()} className={`ui right simple dropdown item signin ${!this.props.user && 'subtitle'}`}>+ <div+ onClick={() => this.showModal()}+ className={`ui right simple dropdown item signin ${!this.props.user && "subtitle"}`}+ >{this.props.user && <Gravatar user={this.props.user} />}{this.state.unreadNotifications > 0 && <div className="unread-dot" />}- {!this.props.user && 'Sign in'} {this.props.user && <i className="dropdown icon" />}+ {!this.props.user && "Sign in"} {this.props.user && <i className="dropdown icon" />}{items}</div></div></div></div>);-- }+ }}diff --git a/public/components/common/Loader.tsx b/public/components/common/Loader.tsxindex a73e42bbc..9038e72d6 100644--- a/public/components/common/Loader.tsx+++ b/public/components/common/Loader.tsx@@ -1,4 +1,4 @@-import * as React from 'react';+import * as React from "react";interface LoaderState {show: boolean;@@ -10,7 +10,7 @@ export class Loader extends React.Component<{}, LoaderState> {super(props);this.unmounted = false;this.state = {- show: false,+ show: false};}@@ -28,6 +28,6 @@ export class Loader extends React.Component<{}, LoaderState> {}public render() {- return this.state.show && <div className="ui active centered inline loader"/>;+ return this.state.show && <div className="ui active centered inline loader" />;}}diff --git a/public/components/common/Modal.tsx b/public/components/common/Modal.tsxindex 68e9c0563..b1622a5fb 100644--- a/public/components/common/Modal.tsx+++ b/public/components/common/Modal.tsx@@ -1,14 +1,14 @@-import './Modal.scss';+import "./Modal.scss";-import * as React from 'react';-import * as ReactDOM from 'react-dom';-import { SystemSettings, CurrentUser, Tenant } from '@fider/models';-import { SignInControl, EnvironmentInfo, Gravatar } from '@fider/components/common';-import { page, actions, classSet } from '@fider/services';+import * as React from "react";+import * as ReactDOM from "react-dom";+import { SystemSettings, CurrentUser, Tenant } from "@fider/models";+import { SignInControl, EnvironmentInfo, Gravatar } from "@fider/components/common";+import { page, actions, classSet } from "@fider/services";interface ModalWindowProps {isOpen: boolean;- size?: 'small' | 'large';+ size?: "small" | "large";canClose?: boolean;center?: boolean;}@@ -23,22 +23,22 @@ class ModalWindow extends React.Component<ModalWindowProps, ModalWindowState> {constructor(props: ModalWindowProps) {super(props);this.state = {- isOpen: this.props.isOpen,+ isOpen: this.props.isOpen};}public static defaultProps: Partial<ModalWindowProps> = {- size: 'small',+ size: "small",canClose: true,- center: true,+ center: true};public componentDidMount() {- document.addEventListener('keydown', this.keyDown, false);+ document.addEventListener("keydown", this.keyDown, false);}public componentWillUnmount() {- document.removeEventListener('keydown', this.keyDown, false);+ document.removeEventListener("keydown", this.keyDown, false);}public componentWillReceiveProps(nextProps: ModalWindowProps) {@@ -48,82 +48,66 @@ class ModalWindow extends React.Component<ModalWindowProps, ModalWindowState> {}private keyDown = (event: KeyboardEvent) => {- if (event.keyCode === 27) { // ESC+ if (event.keyCode === 27) {+ // ESCthis.close();- } else if (event.keyCode === 9) { // TAB+ } else if (event.keyCode === 9) {+ // TABevent.preventDefault();}- }+ };private close = () => {if (this.props.canClose) {this.setState({ isOpen: false });}- }+ };private swallow = (evt: React.MouseEvent<HTMLDivElement>) => {evt.stopPropagation();- }+ };private getContainer = (): HTMLElement => {if (!this.root) {- this.root = document.getElementById('root-modal')!;+ this.root = document.getElementById("root-modal")!;}return this.root;- }+ };public render() {if (!this.state.isOpen) {- document.body.style.overflow = '';+ document.body.style.overflow = "";return null;}- document.body.style.overflow = 'hidden';+ document.body.style.overflow = "hidden";const className = classSet({- 'c-modal__window': true,- 'center': this.props.center,- [this.props.size!]: true,+ "c-modal__window": true,+ center: this.props.center,+ [this.props.size!]: true});- return ReactDOM.createPortal((- <div- aria-disabled={true}- className="c-modal__dimmer"- onClick={this.close}- >- <div- className={className}- onClick={this.swallow}- >+ return ReactDOM.createPortal(+ <div aria-disabled={true} className="c-modal__dimmer" onClick={this.close}>+ <div className={className} onClick={this.swallow}>{this.props.children}</div>- </div>- ), this.getContainer());+ </div>,+ this.getContainer()+ );}}export const Modal = {Window: ModalWindow,Header: (props: { children: React.ReactNode }) => {- return (- <div className="c-modal__header">- {props.children}- </div>- );+ return <div className="c-modal__header">{props.children}</div>;},Content: (props: { children: React.ReactNode }) => {- return (- <div className="c-modal__content">- {props.children}- </div>- );+ return <div className="c-modal__content">{props.children}</div>;},Footer: (props: { children: React.ReactNode }) => {- return (- <div className="c-modal__footer">- {props.children}- </div>- );+ return <div className="c-modal__footer">{props.children}</div>;}};diff --git a/public/components/common/Moment.tsx b/public/components/common/Moment.tsxindex 7b7266530..73b83f045 100644--- a/public/components/common/Moment.tsx+++ b/public/components/common/Moment.tsx@@ -1,5 +1,5 @@-import * as React from 'react';-import { formatDate, timeSince } from '@fider/services';+import * as React from "react";+import { formatDate, timeSince } from "@fider/services";interface MomentText {date: Date | string;@@ -14,7 +14,7 @@ export const Moment = (props: MomentText) => {const date = props.date instanceof Date ? props.date : new Date(props.date);const diff = (now.getTime() - date.getTime()) / (60 * 60 * 24 * 1000);- const display = (diff >= 365) ? formatDate(props.date) : timeSince(now, date);+ const display = diff >= 365 ? formatDate(props.date) : timeSince(now, date);return (<span className="date" title={formatDate(props.date)}>diff --git a/public/components/common/MultiLineText.tsx b/public/components/common/MultiLineText.tsxindex 9d53a90f2..1124c9dce 100644--- a/public/components/common/MultiLineText.tsx+++ b/public/components/common/MultiLineText.tsx@@ -1,13 +1,19 @@-import * as React from 'react';-import * as md from 'markdown-it';+import * as React from "react";+import * as md from "markdown-it";-const full = md('commonmark', { html: false, breaks: true, linkify: true }).enable(['linkify', 'strikethrough']);-const simple = md('commonmark', { html: false, breaks: true, linkify: true }).enable(['linkify', 'strikethrough']).disable([ 'heading', 'image' ]);+const full = md("commonmark", {+ html: false,+ breaks: true,+ linkify: true+}).enable(["linkify", "strikethrough"]);+const simple = md("commonmark", { html: false, breaks: true, linkify: true })+ .enable(["linkify", "strikethrough"])+ .disable(["heading", "image"]);interface MultiLineText {className?: string;text?: string;- style: 'full' | 'simple';+ style: "full" | "simple";}export const MultiLineText = (props: MultiLineText) => {@@ -15,11 +21,11 @@ export const MultiLineText = (props: MultiLineText) => {return <p />;}- const func = props.style === 'full' ? full : simple;+ const func = props.style === "full" ? full : simple;return (<div- className={`markdown-body ${props.className || ''}`}- dangerouslySetInnerHTML={{__html: func.render(props.text)}}+ className={`markdown-body ${props.className || ""}`}+ dangerouslySetInnerHTML={{ __html: func.render(props.text) }}/>);};diff --git a/public/components/common/SignInControl.tsx b/public/components/common/SignInControl.tsxindex e7b782bfb..2157046f6 100644--- a/public/components/common/SignInControl.tsx+++ b/public/components/common/SignInControl.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { SocialSignInButton, Form, Button } from '@fider/components/common';-import { AuthSettings } from '@fider/models';-import { page, device, actions } from '@fider/services';+import * as React from "react";+import { SocialSignInButton, Form, Button } from "@fider/components/common";+import { AuthSettings } from "@fider/models";+import { page, device, actions } from "@fider/services";interface SignInControlState {email: string;@@ -21,16 +21,17 @@ export class SignInControl extends React.Component<SignInControlProps, SignInConthis.settings = page.authSettings();this.state = {- email: '',+ email: ""};}private onEmailKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {- if (event.keyCode === 13) { // ENTER+ if (event.keyCode === 13) {+ // ENTERthis.signIn();event.preventDefault();}- }+ };private async signIn() {const result = await actions.signIn(this.state.email);@@ -46,69 +47,60 @@ export class SignInControl extends React.Component<SignInControlProps, SignInConpublic render() {const google = this.settings.providers.google && (- <div className="column">- <SocialSignInButton- oauthEndpoint={this.settings.endpoint}- provider="google"- />- </div>- );+ <div className="column">+ <SocialSignInButton oauthEndpoint={this.settings.endpoint} provider="google" />+ </div>+ );const facebook = this.settings.providers.facebook && (- <div className="column">- <SocialSignInButton- oauthEndpoint={this.settings.endpoint}- provider="facebook"- />- </div>- );+ <div className="column">+ <SocialSignInButton oauthEndpoint={this.settings.endpoint} provider="facebook" />+ </div>+ );const github = this.settings.providers.github && (- <div className="column">- <SocialSignInButton- oauthEndpoint={this.settings.endpoint}- provider="github"- />- </div>- );+ <div className="column">+ <SocialSignInButton oauthEndpoint={this.settings.endpoint} provider="github" />+ </div>+ );const hasOAuth = !!(google || facebook || github);return (<div className="signin-options">- {- hasOAuth && (- <div>- <div className="ui stackable three column centered grid">- {facebook}- {google}- {github}- </div>- <p className="info">We'll never post to any of your accounts</p>- <div className="ui horizontal divider">OR</div>- </div>- )- }+ {hasOAuth && (+ <div>+ <div className="ui stackable three column centered grid">+ {facebook}+ {google}+ {github}+ </div>+ <p className="info">We'll never post to any of your accounts</p>+ <div className="ui horizontal divider">OR</div>+ </div>+ )}- { this.props.useEmail && <div>+ {this.props.useEmail && (+ <div><p>Enter your email address to sign in</p>- <Form ref={(f) => { this.form = f!; }}>+ <Form+ ref={f => {+ this.form = f!;+ }}+ ><div id="email-signin" className="ui small action fluid input">- <input- autoFocus={!device.isTouch()}- onChange={(e) => this.setState({ email: e.currentTarget.value })}- onKeyDown={this.onEmailKeyDown}- type="text"- placeholder="[email protected]"- className="small"- />- <Button- color="green"- disabled={this.state.email === ''}- onClick={() => this.signIn()}- >- Sign in- </Button>+ <input+ autoFocus={!device.isTouch()}+ onChange={e => this.setState({ email: e.currentTarget.value })}+ onKeyDown={this.onEmailKeyDown}+ type="text"+ placeholder="[email protected]"+ className="small"+ />+ <Button color="green" disabled={this.state.email === ""} onClick={() => this.signIn()}>+ Sign in+ </Button></div></Form>- </div> }+ </div>+ )}</div>);}diff --git a/public/components/common/SocialSignInButton.tsx b/public/components/common/SocialSignInButton.tsxindex 551a068d9..cf7c62066 100644--- a/public/components/common/SocialSignInButton.tsx+++ b/public/components/common/SocialSignInButton.tsx@@ -1,23 +1,23 @@-import * as React from 'react';-import { Button } from '@fider/components/common';+import * as React from "react";+import { Button } from "@fider/components/common";interface SocialSignInButtonProps {oauthEndpoint: string;- provider: 'google' | 'facebook' | 'github';+ provider: "google" | "facebook" | "github";}const providers = {google: {- name: 'Google',- class: 'social google',+ name: "Google",+ class: "social google"},facebook: {- name: 'Facebook',- class: 'social facebook',+ name: "Facebook",+ class: "social facebook"},github: {- name: 'GitHub',- class: 'social github',+ name: "GitHub",+ class: "social github"}};diff --git a/public/components/common/UserName.tsx b/public/components/common/UserName.tsxindex d4e495f72..c573f0c2f 100644--- a/public/components/common/UserName.tsx+++ b/public/components/common/UserName.tsx@@ -1,5 +1,5 @@-import * as React from 'react';-import { User, UserRole } from '@fider/models';+import * as React from "react";+import { User, UserRole } from "@fider/models";interface UserNameProps {user: User;@@ -7,5 +7,5 @@ interface UserNameProps {export const UserName = (props: UserNameProps) => {const isCollaborator = props.user.role >= UserRole.Collaborator;- return <span className={`name ${isCollaborator ? 'staff' : ''}`}>{props.user.name}</span>;+ return <span className={`name ${isCollaborator ? "staff" : ""}`}>{props.user.name}</span>;};diff --git a/public/components/common/index.tsx b/public/components/common/index.tsxindex 5a78b3d5c..56a46188e 100644--- a/public/components/common/index.tsx+++ b/public/components/common/index.tsx@@ -1,16 +1,16 @@-export * from './Button';-export * from './Form';-export * from './MultiLineText';-export * from './DisplayError';-export * from './EnvironmentInfo';-export * from './Gravatar';-export * from './Footer';-export * from './Header';-export * from './SocialSignInButton';-export * from './SignInControl';-export * from './Moment';-export * from './UserName';-export * from './Modal';-export * from './Loader';-import Textarea from 'react-textarea-autosize';+export * from "./Button";+export * from "./Form";+export * from "./MultiLineText";+export * from "./DisplayError";+export * from "./EnvironmentInfo";+export * from "./Gravatar";+export * from "./Footer";+export * from "./Header";+export * from "./SocialSignInButton";+export * from "./SignInControl";+export * from "./Moment";+export * from "./UserName";+export * from "./Modal";+export * from "./Loader";+import Textarea from "react-textarea-autosize";export { Textarea };diff --git a/public/components/index.tsx b/public/components/index.tsxindex ca723d5f2..c1bd75003 100644--- a/public/components/index.tsx+++ b/public/components/index.tsx@@ -1,5 +1,5 @@-export * from './ShowIdeaResponse';-export * from './ShowTag';-export * from './SignInModal';-export * from './SupportCounter';-export * from './common';+export * from "./ShowIdeaResponse";+export * from "./ShowTag";+export * from "./SignInModal";+export * from "./SupportCounter";+export * from "./common";diff --git a/public/index.tsx b/public/index.tsxindex ae1297a5d..4675bdfe1 100644--- a/public/index.tsx+++ b/public/index.tsx@@ -1,51 +1,51 @@-import * as React from 'react';-import * as ReactDOM from 'react-dom';-import { resolveRootComponent } from '@fider/router';-import { Header, Footer } from '@fider/components/common';-import { analytics } from '@fider/services';-import * as $ from 'jquery';+import * as React from "react";+import * as ReactDOM from "react-dom";+import { resolveRootComponent } from "@fider/router";+import { Header, Footer } from "@fider/components/common";+import { analytics } from "@fider/services";+import * as $ from "jquery";const w = window as any;w.$ = w.jQuery = $;-import 'semantic-ui-css/components/site.min.js';-import 'semantic-ui-css/components/transition.min.js';-import 'semantic-ui-css/components/dropdown.min.js';+import "semantic-ui-css/components/site.min.js";+import "semantic-ui-css/components/transition.min.js";+import "semantic-ui-css/components/dropdown.min.js";-import 'semantic-ui-css/components/reset.min.css';-import 'semantic-ui-css/components/site.min.css';-import 'semantic-ui-css/components/segment.min.css';-import 'semantic-ui-css/components/loader.min.css';-import 'semantic-ui-css/components/table.min.css';-import 'semantic-ui-css/components/checkbox.min.css';-import 'semantic-ui-css/components/transition.min.css';-import 'semantic-ui-css/components/header.min.css';-import 'semantic-ui-css/components/form.min.css';-import 'semantic-ui-css/components/container.min.css';-import 'semantic-ui-css/components/dropdown.min.css';-import 'semantic-ui-css/components/input.min.css';-import 'semantic-ui-css/components/label.min.css';-import 'semantic-ui-css/components/list.min.css';-import 'semantic-ui-css/components/divider.min.css';-import 'semantic-ui-css/components/item.min.css';-import 'semantic-ui-css/components/grid.min.css';-import 'semantic-ui-css/components/icon.min.css';-import 'semantic-ui-css/components/message.min.css';-import 'semantic-ui-css/components/menu.min.css';-import 'semantic-ui-css/components/comment.min.css';-import '@fider/assets/styles/main.scss';+import "semantic-ui-css/components/reset.min.css";+import "semantic-ui-css/components/site.min.css";+import "semantic-ui-css/components/segment.min.css";+import "semantic-ui-css/components/loader.min.css";+import "semantic-ui-css/components/table.min.css";+import "semantic-ui-css/components/checkbox.min.css";+import "semantic-ui-css/components/transition.min.css";+import "semantic-ui-css/components/header.min.css";+import "semantic-ui-css/components/form.min.css";+import "semantic-ui-css/components/container.min.css";+import "semantic-ui-css/components/dropdown.min.css";+import "semantic-ui-css/components/input.min.css";+import "semantic-ui-css/components/label.min.css";+import "semantic-ui-css/components/list.min.css";+import "semantic-ui-css/components/divider.min.css";+import "semantic-ui-css/components/item.min.css";+import "semantic-ui-css/components/grid.min.css";+import "semantic-ui-css/components/icon.min.css";+import "semantic-ui-css/components/message.min.css";+import "semantic-ui-css/components/menu.min.css";+import "semantic-ui-css/components/comment.min.css";+import "@fider/assets/styles/main.scss";-w.props = { };+w.props = {};w.set = (key: string, value: any): void => {w.props[key] = value;};-window.addEventListener('error', (evt: ErrorEvent) => {+window.addEventListener("error", (evt: ErrorEvent) => {analytics.error(evt.error);});-document.addEventListener('DOMContentLoaded', () => {- const root = document.getElementById('root');+document.addEventListener("DOMContentLoaded", () => {+ const root = document.getElementById("root");if (root) {const config = resolveRootComponent(location.pathname);ReactDOM.render(diff --git a/public/models/idea.ts b/public/models/idea.tsindex 07d7503a0..02b8cb18b 100644--- a/public/models/idea.ts+++ b/public/models/idea.ts@@ -1,4 +1,4 @@-import { User } from './identity';+import { User } from "./identity";export interface Idea {id: number;@@ -17,20 +17,22 @@ export interface Idea {}export class IdeaStatus {- constructor(public value: number,- public title: string,- public slug: string,- public show: boolean,- public closed: boolean,- public filterable: boolean,- public color: string) { }+ constructor(+ public value: number,+ public title: string,+ public slug: string,+ public show: boolean,+ public closed: boolean,+ public filterable: boolean,+ public color: string+ ) {}- public static Open = new IdeaStatus(0, 'Open', 'open', false, false, false, '');- public static Planned = new IdeaStatus(4, 'Planned', 'planned', true, false, true, 'violet');- public static Started = new IdeaStatus(1, 'Started', 'started', true, false, true, 'blue');- public static Completed = new IdeaStatus(2, 'Completed', 'completed', true, true, true, 'green');- public static Declined = new IdeaStatus(3, 'Declined', 'declined', true, true, true, 'red');- public static Duplicate = new IdeaStatus(5, 'Duplicate', 'duplicate', true, true, false, 'yellow');+ public static Open = new IdeaStatus(0, "Open", "open", false, false, false, "");+ public static Planned = new IdeaStatus(4, "Planned", "planned", true, false, true, "violet");+ public static Started = new IdeaStatus(1, "Started", "started", true, false, true, "blue");+ public static Completed = new IdeaStatus(2, "Completed", "completed", true, true, true, "green");+ public static Declined = new IdeaStatus(3, "Declined", "declined", true, true, true, "red");+ public static Duplicate = new IdeaStatus(5, "Duplicate", "duplicate", true, true, false, "yellow");public static Get(value: number): IdeaStatus {for (const status of IdeaStatus.All) {@@ -47,7 +49,7 @@ export class IdeaStatus {IdeaStatus.Started,IdeaStatus.Completed,IdeaStatus.Duplicate,- IdeaStatus.Declined,+ IdeaStatus.Declined];}diff --git a/public/models/identity.ts b/public/models/identity.tsindex cad2fe34f..9a1e5b9b1 100644--- a/public/models/identity.ts+++ b/public/models/identity.ts@@ -16,7 +16,7 @@ export interface User {export enum UserRole {Visitor = 1,Collaborator = 2,- Administrator = 3,+ Administrator = 3}export interface CurrentUser {diff --git a/public/models/index.ts b/public/models/index.tsindex 4a0af17e0..f94e89c92 100644--- a/public/models/index.ts+++ b/public/models/index.ts@@ -1,4 +1,4 @@-export * from './idea';-export * from './identity';-export * from './settings';-export * from './notification';+export * from "./idea";+export * from "./identity";+export * from "./settings";+export * from "./notification";diff --git a/public/models/notification.ts b/public/models/notification.tsindex b6f15b6bf..bcdca5124 100644--- a/public/models/notification.ts+++ b/public/models/notification.ts@@ -1,4 +1,3 @@-export interface Notification {id: number;title: string;diff --git a/public/models/settings.ts b/public/models/settings.tsindex c3a1ca524..5080a6b38 100644--- a/public/models/settings.ts+++ b/public/models/settings.ts@@ -12,9 +12,9 @@ export interface SystemSettings {export interface AuthSettings {endpoint: string;providers: {- google: boolean,- facebook: boolean,- github: boolean+ google: boolean;+ facebook: boolean;+ github: boolean;};}diff --git a/public/pages/AdminHome/AdminHome.page.tsx b/public/pages/AdminHome/AdminHome.page.tsxindex 2043c12ff..b7107dedb 100644--- a/public/pages/AdminHome/AdminHome.page.tsx+++ b/public/pages/AdminHome/AdminHome.page.tsx@@ -1,8 +1,8 @@-import * as React from 'react';+import * as React from "react";-import { SystemSettings, CurrentUser, Tenant } from '@fider/models';-import { Button, ButtonClickEvent, Textarea, DisplayError } from '@fider/components/common';-import { actions, page, Failure } from '@fider/services';+import { SystemSettings, CurrentUser, Tenant } from "@fider/models";+import { Button, ButtonClickEvent, Textarea, DisplayError } from "@fider/components/common";+import { actions, page, Failure } from "@fider/services";interface AdminHomePageProps {user: CurrentUser;@@ -19,7 +19,6 @@ interface AdminHomePageState {}export class AdminHomePage extends React.Component<AdminHomePageProps, AdminHomePageState> {-constructor(props: AdminHomePageProps) {super(props);@@ -38,7 +37,7 @@ export class AdminHomePage extends React.Component<AdminHomePageProps, AdminHomethis.state.title,this.state.invitation,this.state.welcomeMessage,- this.state.cname,+ this.state.cname);if (result.ok) {e.preventEnable();@@ -62,7 +61,7 @@ export class AdminHomePage extends React.Component<AdminHomePageProps, AdminHome<div className="ui grid"><div className="eight wide computer sixteen wide mobile column"><div className="ui form">- <DisplayError fields={['title']} error={this.state.error} />+ <DisplayError fields={["title"]} error={this.state.error} /><div className="field"><label htmlFor="title">Title</label><input@@ -71,28 +70,36 @@ export class AdminHomePage extends React.Component<AdminHomePageProps, AdminHomemaxLength={60}disabled={!this.props.user.isAdministrator}value={this.state.title}- onChange={(e) => this.setState({ title: e.currentTarget.value })}+ onChange={e => this.setState({ title: e.currentTarget.value })}/><div className="info"><p>Use this field to change the title that is shown on the top of your page.</p></div></div>- <DisplayError fields={['welcomeMessage']} error={this.state.error} />+ <DisplayError fields={["welcomeMessage"]} error={this.state.error} /><div className="field"><label htmlFor="welcome-message">Welcome Message</label><Textareaid="welcome-message"disabled={!this.props.user.isAdministrator}- onChange={(e) => this.setState({ welcomeMessage: e.currentTarget.value })}+ onChange={e => this.setState({ welcomeMessage: e.currentTarget.value })}value={this.state.welcomeMessage}/><div className="info"><p>Use this space to change message of your initial page.</p>- <p>Common use case for this area is a brief description of what is your company/product, why you created this space and how the visitors can collaborate.</p>- <p>This field is powered by CommonMark. You can style and add links to your message. Learn more at <a target="_blank" href="http://commonmark.org/help/">http://commonmark.org/help/</a>.</p>+ <p>+ Common use case for this area is a brief description of what is your company/product, why you+ created this space and how the visitors can collaborate.+ </p>+ <p>+ This field is powered by CommonMark. You can style and add links to your message. Learn more at{" "}+ <a target="_blank" href="http://commonmark.org/help/">+ {"http://commonmark.org/help/"}+ </a>.+ </p></div></div>- <DisplayError fields={['invitation']} error={this.state.error} />+ <DisplayError fields={["invitation"]} error={this.state.error} /><div className="field"><label htmlFor="invitation">Invitation</label><input@@ -101,45 +108,57 @@ export class AdminHomePage extends React.Component<AdminHomePageProps, AdminHomemaxLength={60}disabled={!this.props.user.isAdministrator}value={this.state.invitation}- onChange={(e) => this.setState({ invitation: e.currentTarget.value })}+ onChange={e => this.setState({ invitation: e.currentTarget.value })}/><div className="info"><p>This is your customized message to invite visitors to share their ideas and suggestions.</p></div></div>- {- !page.isSingleHostMode() && [- <DisplayError key={1} fields={['cname']} error={this.state.error} />,- <div key={2} className="field">- <label htmlFor="cname">Custom Domain</label>- <input- id="cname"- type="text"- placeholder="feedback.yourcompany.com"- maxLength={100}- disabled={!this.props.user.isAdministrator}- value={this.state.cname}- onChange={(e) => this.setState({ cname: e.currentTarget.value })}- />- <div className="info">- {- this.state.cname ? [- <p key={0}>Enter the following record into your DNS zone records:</p>,- <p key={1}><strong>{this.state.cname}</strong> CNAME <strong>{this.props.tenant.subdomain}{this.props.system.domain}</strong></p>,- <p key={2}>Please note that it may take up to 72 hours for the change to take effect worldwide due to DNS propagation.</p>- ] :- <p>Custom domains allow you to access your app via your own domain name (for example, <code>feedback.yourcomany.com</code>).</p>- }- </div>+ {!page.isSingleHostMode() && [+ <DisplayError key={1} fields={["cname"]} error={this.state.error} />,+ <div key={2} className="field">+ <label htmlFor="cname">Custom Domain</label>+ <input+ id="cname"+ type="text"+ placeholder="feedback.yourcompany.com"+ maxLength={100}+ disabled={!this.props.user.isAdministrator}+ value={this.state.cname}+ onChange={e => this.setState({ cname: e.currentTarget.value })}+ />+ <div className="info">+ {this.state.cname ? (+ [+ <p key={0}>Enter the following record into your DNS zone records:</p>,+ <p key={1}>+ <strong>{this.state.cname}</strong> CNAME{" "}+ <strong>+ {this.props.tenant.subdomain}+ {this.props.system.domain}+ </strong>+ </p>,+ <p key={2}>+ Please note that it may take up to 72 hours for the change to take effect worldwide due to DNS+ propagation.+ </p>+ ]+ ) : (+ <p>+ Custom domains allow you to access your app via your own domain name (for example,{" "}+ <code>feedback.yourcomany.com</code>).+ </p>+ )}</div>- ]- }- {- this.props.user.isAdministrator &&+ </div>+ ]}+ {this.props.user.isAdministrator && (<div className="field">- <Button color="green" size="large" onClick={async (e) => await this.confirm(e)}>Confirm</Button>+ <Button color="green" size="large" onClick={async e => await this.confirm(e)}>+ Confirm+ </Button></div>- }+ )}</div></div></div>diff --git a/public/pages/AdminHome/index.ts b/public/pages/AdminHome/index.tsindex 145a6b5a8..db6776489 100644--- a/public/pages/AdminHome/index.ts+++ b/public/pages/AdminHome/index.ts@@ -1 +1 @@-export * from './AdminHome.page';+export * from "./AdminHome.page";diff --git a/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx b/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsxindex 9834fad2d..100fb5dae 100644--- a/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx+++ b/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx@@ -1,8 +1,8 @@-import * as React from 'react';+import * as React from "react";-import { HomePage, HomePageProps } from '../';-import { Modal, Form, Button } from '@fider/components/common';-import { page, actions } from '@fider/services';+import { HomePage, HomePageProps } from "../";+import { Modal, Form, Button } from "@fider/components/common";+import { page, actions } from "@fider/services";interface CompleteSignInProfilePageState {name: string;@@ -14,16 +14,16 @@ export class CompleteSignInProfilePage extends React.Component<HomePageProps, Coconstructor(props: HomePageProps) {super(props);- this.key = page.getQueryString('k');+ this.key = page.getQueryString("k");this.state = {- name: '',+ name: ""};}private async submit() {const result = await actions.completeProfile(this.key, this.state.name);if (result.ok) {- location.href = '/';+ location.href = "/";} else if (result.error) {this.form.setFailure(result.error);}@@ -35,21 +35,25 @@ export class CompleteSignInProfilePage extends React.Component<HomePageProps, Co<Modal.Window canClose={false} isOpen={true}><Modal.Header>Complete your profile</Modal.Header><Modal.Content>- <p>Because this is your first sign in, please input your display name.</p>- <Form ref={(f) => { this.form = f!; }}>- <div className="ui small action fluid input">- <input- onChange={(e) => this.setState({ name: e.currentTarget.value })}- type="text"- maxLength={100}- placeholder="Your display name"- className="small"- />- <Button onClick={() => this.submit()} size="small" color="green" disabled={this.state.name === ''}>- Submit- </Button>- </div>- </Form>+ <p>Because this is your first sign in, please input your display name.</p>+ <Form+ ref={f => {+ this.form = f!;+ }}+ >+ <div className="ui small action fluid input">+ <input+ onChange={e => this.setState({ name: e.currentTarget.value })}+ type="text"+ maxLength={100}+ placeholder="Your display name"+ className="small"+ />+ <Button onClick={() => this.submit()} size="small" color="green" disabled={this.state.name === ""}>+ Submit+ </Button>+ </div>+ </Form></Modal.Content></Modal.Window>{React.createElement(HomePage, this.props)}diff --git a/public/pages/CompleteSignInProfile/index.ts b/public/pages/CompleteSignInProfile/index.tsindex ff76f853d..c202aa12a 100644--- a/public/pages/CompleteSignInProfile/index.ts+++ b/public/pages/CompleteSignInProfile/index.ts@@ -1 +1 @@-export * from './CompleteSignInProfile.page';+export * from "./CompleteSignInProfile.page";diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsxindex 666f09218..bd36baaa4 100644--- a/public/pages/Home/Home.page.tsx+++ b/public/pages/Home/Home.page.tsx@@ -1,10 +1,10 @@-import './Home.page.scss';+import "./Home.page.scss";-import * as React from 'react';-import { Idea, Tag, IdeaStatus, CurrentUser, Tenant } from '@fider/models';-import { MultiLineText } from '@fider/components';-import { IdeaInput, ListIdeas, IdeasContainer } from './';-import { page, actions } from '@fider/services';+import * as React from "react";+import { Idea, Tag, IdeaStatus, CurrentUser, Tenant } from "@fider/models";+import { MultiLineText } from "@fider/components";+import { IdeaInput, ListIdeas, IdeasContainer } from "./";+import { page, actions } from "@fider/services";export interface HomePageProps {user?: CurrentUser;@@ -21,7 +21,9 @@ export interface HomePageState {const Lonely = () => {return (<div className="center">- <p><i className="icon lightbulb" aria-hidden="true" /></p>+ <p>+ <i className="icon lightbulb" aria-hidden="true" />+ </p><p>It's lonely out here. Start by sharing an idea!</p></div>);@@ -32,11 +34,10 @@ const defaultWelcomeMessage = `## Welcome to our feedback forum!We'd love to hear what you're thinking about. What can we do better? This is the place for you to vote, discuss and share ideas.`;export class HomePage extends React.Component<HomePageProps, HomePageState> {-constructor(props: HomePageProps) {super(props);this.state = {- title: '',+ title: ""};}@@ -45,25 +46,29 @@ export class HomePage extends React.Component<HomePageProps, HomePageState> {<div className="page ui container"><div className="ui grid stackable"><div className="six wide column">- <MultiLineText className="welcome-message" text={this.props.tenant.welcomeMessage || defaultWelcomeMessage} style="full" />+ <MultiLineText+ className="welcome-message"+ text={this.props.tenant.welcomeMessage || defaultWelcomeMessage}+ style="full"+ /><IdeaInputuser={this.props.user}- placeholder={this.props.tenant.invitation || 'I suggest you...'}- onTitleChanged={(title) => this.setState({ title })}+ placeholder={this.props.tenant.invitation || "I suggest you..."}+ onTitleChanged={title => this.setState({ title })}/></div><div className="ten wide column">- {- Object.keys(this.props.countPerStatus).length === 0- ? <Lonely />- : <IdeasContainer+ {Object.keys(this.props.countPerStatus).length === 0 ? (+ <Lonely />+ ) : (+ <IdeasContaineruser={this.props.user}ideas={this.props.ideas}tags={this.props.tags}countPerStatus={this.props.countPerStatus}newIdeaTitle={this.state.title}/>- }+ )}</div></div></div>diff --git a/public/pages/Home/components/IdeaFilter.tsx b/public/pages/Home/components/IdeaFilter.tsxindex 79eac55b9..3bf9a5350 100644--- a/public/pages/Home/components/IdeaFilter.tsx+++ b/public/pages/Home/components/IdeaFilter.tsx@@ -1,71 +1,96 @@-import * as React from 'react';-import { Idea, IdeaStatus } from '@fider/models';+import * as React from "react";+import { Idea, IdeaStatus } from "@fider/models";export type IdeaFilterFunction = (ideas: Idea[]) => Idea[];interface IdeaFilterProps {- activeFilter: string;- countPerStatus: { [key: string]: number };- filterChanged: (name: string) => void;+ activeFilter: string;+ countPerStatus: { [key: string]: number };+ filterChanged: (name: string) => void;}-const names: {[key: string]: string} = {- 'trending': 'trending',- 'recent': 'recent',- 'most-wanted': 'most wanted',- 'most-discussed': 'most discussed',- 'planned': 'planned',- 'started': 'started',- 'completed': 'completed',- 'declined': 'declined'+const names: { [key: string]: string } = {+ trending: "trending",+ recent: "recent",+ "most-wanted": "most wanted",+ "most-discussed": "most discussed",+ planned: "planned",+ started: "started",+ completed: "completed",+ declined: "declined"};export class IdeaFilter extends React.Component<IdeaFilterProps, {}> {- private element?: HTMLDivElement;+ private element?: HTMLDivElement;- constructor(props: IdeaFilterProps) {- super(props);- }+ constructor(props: IdeaFilterProps) {+ super(props);+ }++ public componentDidMount() {+ $(this.element).dropdown({+ onChange: (value: string) => {+ this.props.filterChanged(value);+ }+ });+ }- public componentDidMount() {- $(this.element).dropdown({- onChange: (value: string) => {- this.props.filterChanged(value);- }- });+ public render() {+ let activeFilter = this.props.activeFilter;+ if (!(this.props.activeFilter in names)) {+ activeFilter = "trending";}- public render() {- let activeFilter = this.props.activeFilter;- if (!(this.props.activeFilter in names)) {- activeFilter = 'trending';- }+ const statusFilterItems = IdeaStatus.All.filter(s => s.filterable && this.props.countPerStatus[s.value]).map(s => (+ <div+ key={s.value}+ className={`item ${activeFilter === s.slug && "active"}`}+ data-value={s.slug}+ data-text={s.title.toLowerCase()}+ >+ {s.title}+ <a className="ui mini circular label">{this.props.countPerStatus[s.value]}</a>+ </div>+ ));- const statusFilterItems = IdeaStatus.All.filter((s) => s.filterable && this.props.countPerStatus[s.value]).map((s) => (- <div key={s.value} className={`item ${activeFilter === s.slug && 'active'}`} data-value={s.slug} data-text={s.title.toLowerCase()}>- {s.title}- <a className="ui mini circular label">{this.props.countPerStatus[s.value]}</a>- </div>- ));-- return (- <>- <div className="content">- Showing {' '}- <div className="ideas-filter ui inline dropdown" ref={(e) => this.element = e!}>- <div className="text">{names[activeFilter]}</div>- <i className="dropdown icon" />- <div className="menu">- <div className="header">What do you want to see?</div>- <div className={`item ${activeFilter === 'trending' && 'active'}`} data-value="trending" data-text="trending">Trending</div>- <div className={`item ${activeFilter === 'recent' && 'active'}`} data-value="recent" data-text="recent">Recent</div>- <div className={`item ${activeFilter === 'most-wanted' && 'active'}`} data-value="most-wanted" data-text="most wanted">Most Wanted</div>- <div className={`item ${activeFilter === 'most-discussed' && 'active'}`} data-value="most-discussed" data-text="most discussed">Most Discussed</div>- {statusFilterItems}- </div>- </div>+ return (+ <>+ <div className="content">+ Showing{" "}+ <div className="ideas-filter ui inline dropdown" ref={e => (this.element = e!)}>+ <div className="text">{names[activeFilter]}</div>+ <i className="dropdown icon" />+ <div className="menu">+ <div className="header">What do you want to see?</div>+ <div+ className={`item ${activeFilter === "trending" && "active"}`}+ data-value="trending"+ data-text="trending"+ >+ Trending</div>- </>- );- }+ <div className={`item ${activeFilter === "recent" && "active"}`} data-value="recent" data-text="recent">+ Recent+ </div>+ <div+ className={`item ${activeFilter === "most-wanted" && "active"}`}+ data-value="most-wanted"+ data-text="most wanted"+ >+ Most Wanted+ </div>+ <div+ className={`item ${activeFilter === "most-discussed" && "active"}`}+ data-value="most-discussed"+ data-text="most discussed"+ >+ Most Discussed+ </div>+ {statusFilterItems}+ </div>+ </div>+ </div>+ </>+ );+ }}diff --git a/public/pages/Home/components/IdeaInput.tsx b/public/pages/Home/components/IdeaInput.tsxindex 12291ddf7..11739f7c3 100644--- a/public/pages/Home/components/IdeaInput.tsx+++ b/public/pages/Home/components/IdeaInput.tsx@@ -1,8 +1,8 @@-import * as React from 'react';-import { DisplayError, Button, ButtonClickEvent, Form, Textarea } from '@fider/components/common';-import { SignInModal } from '@fider/components';-import { page, cache, actions, Failure } from '@fider/services';-import { CurrentUser } from '@fider/models';+import * as React from "react";+import { DisplayError, Button, ButtonClickEvent, Form, Textarea } from "@fider/components/common";+import { SignInModal } from "@fider/components";+import { page, cache, actions, Failure } from "@fider/services";+import { CurrentUser } from "@fider/models";interface IdeaInputProps {user?: CurrentUser;@@ -11,105 +11,109 @@ interface IdeaInputProps {}interface IdeaInputState {- title: string;- description: string;- focused: boolean;- showSignIn: boolean;+ title: string;+ description: string;+ focused: boolean;+ showSignIn: boolean;}-const CACHE_TITLE_KEY = 'IdeaInput-Title';-const CACHE_DESCRIPTION_KEY = 'IdeaInput-Description';+const CACHE_TITLE_KEY = "IdeaInput-Title";+const CACHE_DESCRIPTION_KEY = "IdeaInput-Description";export class IdeaInput extends React.Component<IdeaInputProps, IdeaInputState> {- private title?: HTMLInputElement;- private form?: Form;+ private title?: HTMLInputElement;+ private form?: Form;- constructor(props: IdeaInputProps) {- super(props);- this.state = {- title: !!this.props.user && cache.get(CACHE_TITLE_KEY) || '',- description: !!this.props.user && cache.get(CACHE_DESCRIPTION_KEY) || '',- focused: false,- showSignIn: false,- };- if (this.state) {- this.props.onTitleChanged(this.state.title);- }+ constructor(props: IdeaInputProps) {+ super(props);+ this.state = {+ title: (!!this.props.user && cache.get(CACHE_TITLE_KEY)) || "",+ description: (!!this.props.user && cache.get(CACHE_DESCRIPTION_KEY)) || "",+ focused: false,+ showSignIn: false+ };+ if (this.state) {+ this.props.onTitleChanged(this.state.title);}+ }- public componentDidMount() {- if (this.props.user && this.title) {- this.title.focus();- }+ public componentDidMount() {+ if (this.props.user && this.title) {+ this.title.focus();}+ }- private onTitleFocused() {- if (!this.props.user && this.title) {- this.title.blur();- this.setState({ showSignIn: true });- }+ private onTitleFocused() {+ if (!this.props.user && this.title) {+ this.title.blur();+ this.setState({ showSignIn: true });}+ }- private onTitleChanged(title: string) {- cache.set(CACHE_TITLE_KEY, title);- this.setState({ title });- this.props.onTitleChanged(title);- }+ private onTitleChanged(title: string) {+ cache.set(CACHE_TITLE_KEY, title);+ this.setState({ title });+ this.props.onTitleChanged(title);+ }- private onDescriptionChanged(description: string) {- cache.set(CACHE_DESCRIPTION_KEY, description);- this.setState({ description });- }+ private onDescriptionChanged(description: string) {+ cache.set(CACHE_DESCRIPTION_KEY, description);+ this.setState({ description });+ }- private async submit(event: ButtonClickEvent) {- if (this.state.title) {- const result = await actions.createIdea(this.state.title, this.state.description);- if (result.ok) {- if (this.form) {- this.form.clearFailure();- }- cache.remove(CACHE_TITLE_KEY, CACHE_DESCRIPTION_KEY);- location.href = `/ideas/${result.data.number}/${result.data.slug}`;- event.preventEnable();- } else if (result.error && this.form) {- this.form.setFailure(result.error);+ private async submit(event: ButtonClickEvent) {+ if (this.state.title) {+ const result = await actions.createIdea(this.state.title, this.state.description);+ if (result.ok) {+ if (this.form) {+ this.form.clearFailure();}+ cache.remove(CACHE_TITLE_KEY, CACHE_DESCRIPTION_KEY);+ location.href = `/ideas/${result.data.number}/${result.data.slug}`;+ event.preventEnable();+ } else if (result.error && this.form) {+ this.form.setFailure(result.error);}}+ }- public render() {- const details = (- <div>- <div className="field">- <Textarea- onChange={(e) => this.onDescriptionChanged(e.currentTarget.value)}- defaultValue={this.state.description}- placeholder="Describe your idea"- />- </div>- <Button color="green" onClick={(e) => this.submit(e)}>- Submit- </Button>+ public render() {+ const details = (+ <div>+ <div className="field">+ <Textarea+ onChange={e => this.onDescriptionChanged(e.currentTarget.value)}+ defaultValue={this.state.description}+ placeholder="Describe your idea"+ /></div>- );+ <Button color="green" onClick={e => this.submit(e)}>+ Submit+ </Button>+ </div>+ );- return (+ return (<><SignInModal isOpen={this.state.showSignIn} />- <Form ref={(f) => { this.form = f!; }} >+ <Form+ ref={f => {+ this.form = f!;+ }}+ ><inputid="new-idea-input"type="text"- ref={(e) => this.title = e!}+ ref={e => (this.title = e!)}onFocus={() => this.onTitleFocused()}maxLength={100}defaultValue={this.state.title}- onChange={(e) => this.onTitleChanged(e.currentTarget.value)}+ onChange={e => this.onTitleChanged(e.currentTarget.value)}placeholder={this.props.placeholder}/>{this.state.title && details}</Form></>- );- }+ );+ }}diff --git a/public/pages/Home/components/IdeasContainer.tsx b/public/pages/Home/components/IdeasContainer.tsxindex 6a856459e..ef35618ec 100644--- a/public/pages/Home/components/IdeasContainer.tsx+++ b/public/pages/Home/components/IdeasContainer.tsx@@ -1,10 +1,10 @@-import * as React from 'react';+import * as React from "react";-import { IdeaInput, ListIdeas, TagsFilter, IdeaFilter } from '../';+import { IdeaInput, ListIdeas, TagsFilter, IdeaFilter } from "../";-import { Idea, Tag, IdeaStatus, CurrentUser } from '@fider/models';-import { Loader, MultiLineText } from '@fider/components';-import { page, actions } from '@fider/services';+import { Idea, Tag, IdeaStatus, CurrentUser } from "@fider/models";+import { Loader, MultiLineText } from "@fider/components";+import { page, actions } from "@fider/services";interface IdeasContainerProps {user?: CurrentUser;@@ -23,129 +23,134 @@ interface IdeasContainerState {}export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasContainerState> {- private timer: any;+ private timer: any;- constructor(props: IdeasContainerProps) {- super(props);- const query = page.getQueryString('q');- const tags = page.getQueryStringArray('t');- const filter = page.getQueryString('f');+ constructor(props: IdeasContainerProps) {+ super(props);+ const query = page.getQueryString("q");+ const tags = page.getQueryStringArray("t");+ const filter = page.getQueryString("f");- this.state = {- ideas: [],- loading: false,- filter,- query,- tags- };- }+ this.state = {+ ideas: [],+ loading: false,+ filter,+ query,+ tags+ };+ }- public componentWillReceiveProps(nextProps: IdeasContainerProps) {- if (nextProps.newIdeaTitle) {- this.searchIdeas(nextProps.newIdeaTitle, '', [], 200);- } else if (this.state.query || this.state.filter || this.state.tags.length > 0) {- this.searchIdeas(this.state.query, this.state.filter, this.state.tags);- } else {- this.setState({ loading: false, ideas: nextProps.ideas });- }+ public componentWillReceiveProps(nextProps: IdeasContainerProps) {+ if (nextProps.newIdeaTitle) {+ this.searchIdeas(nextProps.newIdeaTitle, "", [], 200);+ } else if (this.state.query || this.state.filter || this.state.tags.length > 0) {+ this.searchIdeas(this.state.query, this.state.filter, this.state.tags);+ } else {+ this.setState({ loading: false, ideas: nextProps.ideas });}+ }- private changeFilterCriteria<K extends keyof IdeasContainerState>(obj: Pick<IdeasContainerState, K>, delay: number = 0): void {- this.setState(obj, () => {- const query = this.state.query.trim().toLowerCase();- page.replaceState(page.toQueryString({+ private changeFilterCriteria<K extends keyof IdeasContainerState>(+ obj: Pick<IdeasContainerState, K>,+ delay: number = 0+ ): void {+ this.setState(obj, () => {+ const query = this.state.query.trim().toLowerCase();+ page.replaceState(+ page.toQueryString({t: this.state.tags,q: query,- f: this.state.filter,- }));-- this.searchIdeas(query, this.state.filter, this.state.tags, delay);- });- }+ f: this.state.filter+ })+ );- private async searchIdeas(query: string, filter: string, tags: string[], delay: number = 0) {- clearTimeout(this.timer);- this.setState({ loading: true });- this.timer = setTimeout(() => {- actions.searchIdeas(query, filter, tags).then((response) => {- if (this.state.loading) {- this.setState({ loading: false, ideas: response.data });- }- });- }, delay);- }+ this.searchIdeas(query, this.state.filter, this.state.tags, delay);+ });+ }- public render() {- if (this.props.newIdeaTitle) {- return (- <>- <h3 className="ui dividing header">- <i className="lightbulb icon blue" />- <div className="content">- Similar ideas- <div className="sub header">Consider voting on existing ideas before posting a new one.</div>- </div>- </h3>- {- this.state.loading- ? <Loader />- : <ListIdeas- ideas={this.state.ideas}- tags={this.props.tags}- user={this.props.user}- emptyText={`No similar ideas matched '${this.props.newIdeaTitle}'.`}- />- }- </>- );- }+ private async searchIdeas(query: string, filter: string, tags: string[], delay: number = 0) {+ clearTimeout(this.timer);+ this.setState({ loading: true });+ this.timer = setTimeout(() => {+ actions.searchIdeas(query, filter, tags).then(response => {+ if (this.state.loading) {+ this.setState({ loading: false, ideas: response.data });+ }+ });+ }, delay);+ }+ public render() {+ if (this.props.newIdeaTitle) {return (<>- <div className="ui grid">- {- !this.state.query && <div className="ten wide mobile ten wide tablet twelve wide computer column filter-column">- <IdeaFilter- activeFilter={this.state.filter}- filterChanged={(filter) => this.changeFilterCriteria({ filter })}- countPerStatus={this.props.countPerStatus}- />- </div>- }- <div className={!this.state.query ? `six wide mobile six wide tablet four wide computer column` : 'column'}>- <div className="ui search">- <div className="ui icon fluid input">- <input- onChange={(x) => this.changeFilterCriteria({ query: x.currentTarget.value }, 200)}- value={this.state.query}- type="text"- placeholder="Search..."- />- {- this.state.query- ? <i onClick={() => this.changeFilterCriteria({ query: '' })} className="cancel link icon" />- : <i className="search icon" />- }- </div>- </div>+ <h3 className="ui dividing header">+ <i className="lightbulb icon blue" />+ <div className="content">+ Similar ideas+ <div className="sub header">Consider voting on existing ideas before posting a new one.</div></div>- </div>- <TagsFilter- tags={this.props.tags}- selectionChanged={(tags) => this.changeFilterCriteria({ tags })}- defaultSelection={this.state.tags}- />- {- this.state.loading- ? <Loader />- : <ListIdeas+ </h3>+ {this.state.loading ? (+ <Loader />+ ) : (+ <ListIdeasideas={this.state.ideas}tags={this.props.tags}user={this.props.user}- emptyText={'No results matched your search, try something different.'}+ emptyText={`No similar ideas matched '${this.props.newIdeaTitle}'.`}/>- }+ )}</>);}++ return (+ <>+ <div className="ui grid">+ {!this.state.query && (+ <div className="ten wide mobile ten wide tablet twelve wide computer column filter-column">+ <IdeaFilter+ activeFilter={this.state.filter}+ filterChanged={filter => this.changeFilterCriteria({ filter })}+ countPerStatus={this.props.countPerStatus}+ />+ </div>+ )}+ <div className={!this.state.query ? `six wide mobile six wide tablet four wide computer column` : "column"}>+ <div className="ui search">+ <div className="ui icon fluid input">+ <input+ onChange={x => this.changeFilterCriteria({ query: x.currentTarget.value }, 200)}+ value={this.state.query}+ type="text"+ placeholder="Search..."+ />+ {this.state.query ? (+ <i onClick={() => this.changeFilterCriteria({ query: "" })} className="cancel link icon" />+ ) : (+ <i className="search icon" />+ )}+ </div>+ </div>+ </div>+ </div>+ <TagsFilter+ tags={this.props.tags}+ selectionChanged={tags => this.changeFilterCriteria({ tags })}+ defaultSelection={this.state.tags}+ />+ {this.state.loading ? (+ <Loader />+ ) : (+ <ListIdeas+ ideas={this.state.ideas}+ tags={this.props.tags}+ user={this.props.user}+ emptyText={"No results matched your search, try something different."}+ />+ )}+ </>+ );+ }}diff --git a/public/pages/Home/components/ListIdeas.tsx b/public/pages/Home/components/ListIdeas.tsxindex eb18ff9ce..23128b271 100644--- a/public/pages/Home/components/ListIdeas.tsx+++ b/public/pages/Home/components/ListIdeas.tsx@@ -1,6 +1,6 @@-import * as React from 'react';-import { Idea, Tag, IdeaStatus, CurrentUser } from '@fider/models';-import { ShowTag, ShowIdeaResponse, SupportCounter, Gravatar, MultiLineText, Moment } from '@fider/components';+import * as React from "react";+import { Idea, Tag, IdeaStatus, CurrentUser } from "@fider/models";+import { ShowTag, ShowIdeaResponse, SupportCounter, Gravatar, MultiLineText, Moment } from "@fider/components";const defaultShowCount = 20;@@ -15,75 +15,64 @@ interface ListIdeasState {showCount: number;}-const ListIdeaItem = (props: { idea: Idea, user?: CurrentUser, tags: Tag[] }) => {+const ListIdeaItem = (props: { idea: Idea; user?: CurrentUser; tags: Tag[] }) => {return (<div className="item"><SupportCounter user={props.user} idea={props.idea} /><div className="content">- {- props.idea.totalComments > 0 &&+ {props.idea.totalComments > 0 && (<div className="info right">- {props.idea.totalComments} <i className="comments outline icon"/>+ {props.idea.totalComments} <i className="comments outline icon" /></div>- }+ )}<a className="title" href={`/ideas/${props.idea.number}/${props.idea.slug}`}>{props.idea.title}</a><MultiLineText className="description" text={props.idea.description} style="simple" /><ShowIdeaResponse status={props.idea.status} response={props.idea.response} />- {- props.tags.map((tag) => (- <ShowTag key={tag.id} size="tiny" tag={tag} />- ))- }+ {props.tags.map(tag => <ShowTag key={tag.id} size="tiny" tag={tag} />)}</div></div>);};export class ListIdeas extends React.Component<ListIdeasProps, ListIdeasState> {- constructor(props: ListIdeasProps) {- super(props);- this.state = {- showCount: defaultShowCount,- };- }-- private showMore(event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>): void {- event.preventDefault();- this.setState({- showCount: this.state.showCount + defaultShowCount- });- }+ constructor(props: ListIdeasProps) {+ super(props);+ this.state = {+ showCount: defaultShowCount+ };+ }- public render() {- if (this.props.ideas.length === 0) {- return <p className="no-ideas-found">{this.props.emptyText}</p>;- }+ private showMore(event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>): void {+ event.preventDefault();+ this.setState({+ showCount: this.state.showCount + defaultShowCount+ });+ }- const ideasToList = this.props.ideas.slice(0, this.state.showCount);- return (- <div className="ui divided unstackable items fdr-idea-list">- {- ideasToList.map((idea) =>- <ListIdeaItem- key={idea.id}- user={this.props.user}- idea={idea}- tags={this.props.tags.filter((tag) => idea.tags.indexOf(tag.slug) >= 0)}- />)- }- {- this.props.ideas.length > this.state.showCount &&- <h5- className="ui blue header show-more"- onTouchEnd={(e) => this.showMore(e)}- onClick={(e) => this.showMore(e)}- >- View {this.props.ideas.length - this.state.showCount} more ideas- </h5>- }- </div>- );+ public render() {+ if (this.props.ideas.length === 0) {+ return <p className="no-ideas-found">{this.props.emptyText}</p>;}++ const ideasToList = this.props.ideas.slice(0, this.state.showCount);+ return (+ <div className="ui divided unstackable items fdr-idea-list">+ {ideasToList.map(idea => (+ <ListIdeaItem+ key={idea.id}+ user={this.props.user}+ idea={idea}+ tags={this.props.tags.filter(tag => idea.tags.indexOf(tag.slug) >= 0)}+ />+ ))}+ {this.props.ideas.length > this.state.showCount && (+ <h5 className="ui blue header show-more" onTouchEnd={e => this.showMore(e)} onClick={e => this.showMore(e)}>+ View {this.props.ideas.length - this.state.showCount} more ideas+ </h5>+ )}+ </div>+ );+ }}diff --git a/public/pages/Home/components/TagsFilter.tsx b/public/pages/Home/components/TagsFilter.tsxindex 4916e2a84..3db8e4845 100644--- a/public/pages/Home/components/TagsFilter.tsx+++ b/public/pages/Home/components/TagsFilter.tsx@@ -1,6 +1,6 @@-import * as React from 'react';-import { Tag } from '@fider/models';-import { ShowTag } from '@fider/components/ShowTag';+import * as React from "react";+import { Tag } from "@fider/models";+import { ShowTag } from "@fider/components/ShowTag";interface TagsFilterProps {tags: Tag[];@@ -24,8 +24,8 @@ export class TagsFilter extends React.Component<TagsFilterProps, TagsFilterStatepublic componentDidMount() {const $element = $(this.element);- this.props.defaultSelection.forEach((t) => {- $element.dropdown('set selected', t);+ this.props.defaultSelection.forEach(t => {+ $element.dropdown("set selected", t);});$element.dropdown({onAdd: (value: string) => {@@ -49,29 +49,27 @@ export class TagsFilter extends React.Component<TagsFilterProps, TagsFilterState}return (- <div className={`tags-filter ${this.state.selected.length > 0 ? 'has-selection' : ''}`}>- <div className={`ui multiple dropdown `} ref={(e) => this.element = e!}>- <i className="filter icon"/>+ <div className={`tags-filter ${this.state.selected.length > 0 ? "has-selection" : ""}`}>+ <div className={`ui multiple dropdown `} ref={e => (this.element = e!)}>+ <i className="filter icon" /><span className="text">Filter by tag...</span><div className="menu"><div className="ui icon search input">- <i className="search icon"/>- <input type="text" placeholder="Search tags..."/>+ <i className="search icon" />+ <input type="text" placeholder="Search tags..." /></div>- <div className="divider"/>+ <div className="divider" /><div className="header">- <i className="tags icon"/>+ <i className="tags icon" />Tag</div><div className="scrolling menu">- {- this.props.tags.map((t) => (- <div key={t.id} className="item" data-value={t.slug}>- <ShowTag tag={t} circular={true}/>- {t.name}- </div>- ))- }+ {this.props.tags.map(t => (+ <div key={t.id} className="item" data-value={t.slug}>+ <ShowTag tag={t} circular={true} />+ {t.name}+ </div>+ ))}</div></div></div>diff --git a/public/pages/Home/index.ts b/public/pages/Home/index.tsindex 10df34892..bfea53594 100644--- a/public/pages/Home/index.ts+++ b/public/pages/Home/index.ts@@ -1,6 +1,6 @@-export * from './Home.page';-export * from './components/TagsFilter';-export * from './components/IdeaFilter';-export * from './components/IdeaInput';-export * from './components/ListIdeas';-export * from './components/IdeasContainer';+export * from "./Home.page";+export * from "./components/TagsFilter";+export * from "./components/IdeaFilter";+export * from "./components/IdeaInput";+export * from "./components/ListIdeas";+export * from "./components/IdeasContainer";diff --git a/public/pages/ManageMembers/ManageMembers.page.tsx b/public/pages/ManageMembers/ManageMembers.page.tsxindex 5f5e241a4..f7240c7d3 100644--- a/public/pages/ManageMembers/ManageMembers.page.tsx+++ b/public/pages/ManageMembers/ManageMembers.page.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { Button, Gravatar, UserName } from '@fider/components/common';-import { User, CurrentUser, UserRole } from '@fider/models';-import { actions } from '@fider/services';+import * as React from "react";+import { Button, Gravatar, UserName } from "@fider/components/common";+import { User, CurrentUser, UserRole } from "@fider/models";+import { actions } from "@fider/services";interface ManageMembersPageState {administrators: User[];@@ -19,163 +19,160 @@ interface ManageMembersPageProps {}export class ManageMembersPage extends React.Component<ManageMembersPageProps, ManageMembersPageState> {+ constructor(props: ManageMembersPageProps) {+ super(props);+ this.state = this.groupUsers();+ }- constructor(props: ManageMembersPageProps) {- super(props);- this.state = this.groupUsers();+ private async changeRole(user: User, role: UserRole): Promise<any> {+ const response = await actions.changeUserRole(user.id, role);+ if (response.ok) {+ user.role = role;+ this.setState(this.groupUsers());}+ }- private async changeRole(user: User, role: UserRole): Promise<any> {- const response = await actions.changeUserRole(user.id, role);- if (response.ok) {- user.role = role;- this.setState(this.groupUsers());- }- }+ private groupUsers(): ManageMembersPageState {+ const usersByRole = this.props.users.reduce<{ [key: number]: User[] }>((groups, x) => {+ groups[x.role] = [x].concat(groups[x.role] || []);+ return groups;+ }, {});- private groupUsers(): ManageMembersPageState {- const usersByRole = this.props.users.reduce<{ [key: number]: User[] }>((groups, x) => {- groups[x.role] = [ x ].concat(groups[x.role] || []);- return groups;- }, {});+ return {+ administrators: usersByRole[UserRole.Administrator] || [],+ collaborators: usersByRole[UserRole.Collaborator] || [],+ visitors: usersByRole[UserRole.Visitor] || [],+ filteredNewAdministrators: [],+ filteredNewCollaborators: [],+ newAdministratorFilter: "",+ newCollaboratorFilter: ""+ };+ }- return {- administrators: usersByRole[UserRole.Administrator] || [],- collaborators: usersByRole[UserRole.Collaborator] || [],- visitors: usersByRole[UserRole.Visitor] || [],- filteredNewAdministrators: [],- filteredNewCollaborators: [],- newAdministratorFilter: '',- newCollaboratorFilter: '',- };+ private showUser(user: User, role: UserRole, addable: boolean, removable: boolean) {+ if (user.id === this.props.user.id || this.props.user.role !== UserRole.Administrator) {+ removable = false;}- private showUser(user: User, role: UserRole, addable: boolean, removable: boolean) {- if (user.id === this.props.user.id || this.props.user.role !== UserRole.Administrator) {- removable = false;- }-- return (- <div key={user.id} className="item">- <Gravatar user={user} />- <div className="content">- <UserName user={user} />- </div>- <div className="right floated content">- {- removable &&- <Button size="tiny" color="red" onClick={() => this.changeRole(user, UserRole.Visitor)} className="showover">- <i className="remove icon" />Remove- </Button>- }- {- addable &&- <Button size="tiny" color="green" onClick={() => this.changeRole(user, role)} className="showover">- <i className="add icon" />Add- </Button>- }- </div>+ return (+ <div key={user.id} className="item">+ <Gravatar user={user} />+ <div className="content">+ <UserName user={user} /></div>- );- }-- private filterVisitors(property: string, text: string) {- let filtered: User[] = [];- if (text) {- filtered = this.state.visitors.filter((x) => x.name.toLowerCase().indexOf(text.toLowerCase()) >= 0);- }+ <div className="right floated content">+ {removable && (+ <Button+ size="tiny"+ color="red"+ onClick={() => this.changeRole(user, UserRole.Visitor)}+ className="showover"+ >+ <i className="remove icon" />Remove+ </Button>+ )}+ {addable && (+ <Button size="tiny" color="green" onClick={() => this.changeRole(user, role)} className="showover">+ <i className="add icon" />Add+ </Button>+ )}+ </div>+ </div>+ );+ }- if (property === 'administrator') {- this.setState({- newAdministratorFilter: text,- filteredNewAdministrators: filtered- });- } else if (property === 'collaborator') {- this.setState({- newCollaboratorFilter: text,- filteredNewCollaborators: filtered- });- }+ private filterVisitors(property: string, text: string) {+ let filtered: User[] = [];+ if (text) {+ filtered = this.state.visitors.filter(x => x.name.toLowerCase().indexOf(text.toLowerCase()) >= 0);}- public render() {- return (- <div className="page ui container">- <h2 className="ui header">- <i className="circular users icon" />- <div className="content">- Members- <div className="sub header">Manage your account administrators and collaborators.</div>- </div>- </h2>+ if (property === "administrator") {+ this.setState({+ newAdministratorFilter: text,+ filteredNewAdministrators: filtered+ });+ } else if (property === "collaborator") {+ this.setState({+ newCollaboratorFilter: text,+ filteredNewCollaborators: filtered+ });+ }+ }- <div className="ui grid">+ public render() {+ return (+ <div className="page ui container">+ <h2 className="ui header">+ <i className="circular users icon" />+ <div className="content">+ Members+ <div className="sub header">Manage your account administrators and collaborators.</div>+ </div>+ </h2>- <div className="eight wide computer sixteen wide mobile column">- <div className="ui segment">- <h4 className="ui header">Administrators</h4>- <p className="info">Administrators have full access to edit and manage content, permissions and settings.</p>- <div className="ui middle aligned very relaxed selection list">- {this.state.administrators.map((x) => this.showUser(x, UserRole.Administrator, false, true))}- </div>- {- this.props.user.role === UserRole.Administrator &&- <div className="ui mini form">- <p>Add new administrator</p>- <div className="mini field">- <input- type="text"- value={this.state.newAdministratorFilter}- onChange={(x) => this.filterVisitors('administrator', x.currentTarget.value)}- placeholder="Search users by name"- />- </div>- <div className="ui middle aligned very relaxed selection list">- {this.state.filteredNewAdministrators.map((x) => this.showUser(x, UserRole.Administrator, true, false))}- </div>- {- this.state.newAdministratorFilter &&- this.state.filteredNewAdministrators.length === 0 &&- <p className="info">No users to show.</p>- }- </div>- }+ <div className="ui grid">+ <div className="eight wide computer sixteen wide mobile column">+ <div className="ui segment">+ <h4 className="ui header">Administrators</h4>+ <p className="info">+ Administrators have full access to edit and manage content, permissions and settings.+ </p>+ <div className="ui middle aligned very relaxed selection list">+ {this.state.administrators.map(x => this.showUser(x, UserRole.Administrator, false, true))}</div>+ {this.props.user.role === UserRole.Administrator && (+ <div className="ui mini form">+ <p>Add new administrator</p>+ <div className="mini field">+ <input+ type="text"+ value={this.state.newAdministratorFilter}+ onChange={x => this.filterVisitors("administrator", x.currentTarget.value)}+ placeholder="Search users by name"+ />+ </div>+ <div className="ui middle aligned very relaxed selection list">+ {this.state.filteredNewAdministrators.map(x =>+ this.showUser(x, UserRole.Administrator, true, false)+ )}+ </div>+ {this.state.newAdministratorFilter &&+ this.state.filteredNewAdministrators.length === 0 && <p className="info">No users to show.</p>}+ </div>+ )}</div>+ </div>- <div className="eight wide computer sixteen wide mobile column">- <div className="ui segment">- <h4 className="ui header">Collaborators</h4>- <p className="info">Collaborators can edit and manage content, but not permissions and settings.</p>- <div className="ui middle aligned very relaxed selection list">- {this.state.collaborators.map((x) => this.showUser(x, UserRole.Collaborator, false, true))}- </div>- {- this.props.user.role === UserRole.Administrator &&- <div className="ui mini form">- <p>Add new collaborator</p>- <div className="mini field">- <input- type="text"- value={this.state.newCollaboratorFilter}- onChange={(x) => this.filterVisitors('collaborator', x.currentTarget.value)}- placeholder="Search users by name"- />- </div>- <div className="ui middle aligned very relaxed selection list">- {this.state.filteredNewCollaborators.map((x) => this.showUser(x, UserRole.Collaborator, true, false))}- </div>- {- this.state.newCollaboratorFilter &&- this.state.filteredNewCollaborators.length === 0 &&- <p className="info">No users to show.</p>- }- </div>- }+ <div className="eight wide computer sixteen wide mobile column">+ <div className="ui segment">+ <h4 className="ui header">Collaborators</h4>+ <p className="info">Collaborators can edit and manage content, but not permissions and settings.</p>+ <div className="ui middle aligned very relaxed selection list">+ {this.state.collaborators.map(x => this.showUser(x, UserRole.Collaborator, false, true))}</div>+ {this.props.user.role === UserRole.Administrator && (+ <div className="ui mini form">+ <p>Add new collaborator</p>+ <div className="mini field">+ <input+ type="text"+ value={this.state.newCollaboratorFilter}+ onChange={x => this.filterVisitors("collaborator", x.currentTarget.value)}+ placeholder="Search users by name"+ />+ </div>+ <div className="ui middle aligned very relaxed selection list">+ {this.state.filteredNewCollaborators.map(x => this.showUser(x, UserRole.Collaborator, true, false))}+ </div>+ {this.state.newCollaboratorFilter &&+ this.state.filteredNewCollaborators.length === 0 && <p className="info">No users to show.</p>}+ </div>+ )}</div></div></div>- );- }+ </div>+ );+ }}diff --git a/public/pages/ManageMembers/index.ts b/public/pages/ManageMembers/index.tsindex 9ec65e569..5fb42f75f 100644--- a/public/pages/ManageMembers/index.ts+++ b/public/pages/ManageMembers/index.ts@@ -1 +1 @@-export * from './ManageMembers.page';+export * from "./ManageMembers.page";diff --git a/public/pages/ManageTags/ManageTags.page.tsx b/public/pages/ManageTags/ManageTags.page.tsxindex e6b9b8dba..6662d89b6 100644--- a/public/pages/ManageTags/ManageTags.page.tsx+++ b/public/pages/ManageTags/ManageTags.page.tsx@@ -1,10 +1,10 @@-import * as React from 'react';-import { Button, Gravatar, UserName } from '@fider/components/common';-import { ShowTag } from '@fider/components/ShowTag';-import { Tag, CurrentUser, UserRole } from '@fider/models';+import * as React from "react";+import { Button, Gravatar, UserName } from "@fider/components/common";+import { ShowTag } from "@fider/components/ShowTag";+import { Tag, CurrentUser, UserRole } from "@fider/models";-import { TagForm, TagFormState } from './';-import { actions, Failure } from '@fider/services';+import { TagForm, TagFormState } from "./";+import { actions, Failure } from "@fider/services";interface ManageTagsPageProps {user: CurrentUser;@@ -19,154 +19,161 @@ interface ManageTagsPageState {}export class ManageTagsPage extends React.Component<ManageTagsPageProps, ManageTagsPageState> {+ constructor(props: ManageTagsPageProps) {+ super(props);+ this.state = {+ isAdding: false,+ allTags: this.props.tags+ };+ }- constructor(props: ManageTagsPageProps) {- super(props);- this.state = {- isAdding: false,- allTags: this.props.tags- };+ private async saveNewTag(data: TagFormState): Promise<Failure | undefined> {+ const result = await actions.createTag(data.name, data.color, data.isPublic);+ if (result.ok) {+ this.setState({+ isAdding: false,+ allTags: this.state.allTags.concat(result.data)+ });+ } else {+ return result.error;}+ }- private async saveNewTag(data: TagFormState): Promise<Failure | undefined> {- const result = await actions.createTag(data.name, data.color, data.isPublic);- if (result.ok) {- this.setState({- isAdding: false,- allTags: this.state.allTags.concat(result.data)- });- } else {- return result.error;- }+ private async updateTag(tag: Tag, data: TagFormState): Promise<Failure | undefined> {+ const result = await actions.updateTag(tag.slug, data.name, data.color, data.isPublic);+ if (result.ok) {+ tag.name = result.data.name;+ tag.slug = result.data.slug;+ tag.color = result.data.color;+ tag.isPublic = result.data.isPublic;+ this.setState({+ editing: undefined+ });+ } else {+ return result.error;}+ }- private async updateTag(tag: Tag, data: TagFormState): Promise<Failure | undefined> {- const result = await actions.updateTag(tag.slug, data.name, data.color, data.isPublic);- if (result.ok) {- tag.name = result.data.name;- tag.slug = result.data.slug;- tag.color = result.data.color;- tag.isPublic = result.data.isPublic;- this.setState({- editing: undefined- });- } else {- return result.error;- }+ private async deleteTag(tag: Tag) {+ const result = await actions.deleteTag(tag.slug);+ const idx = this.state.allTags.indexOf(tag);+ if (result.ok) {+ this.setState({+ deleting: undefined,+ allTags: this.state.allTags.splice(idx, 1) && this.state.allTags+ });}+ }- private async deleteTag(tag: Tag) {- const result = await actions.deleteTag(tag.slug);- const idx = this.state.allTags.indexOf(tag);- if (result.ok) {- this.setState({- deleting: undefined,- allTags: this.state.allTags.splice(idx, 1) && this.state.allTags- });+ public render() {+ const items = this.state.allTags.map(t => {+ if (this.state.editing === t.id) {+ return (+ <div key={t.id} className="item">+ <TagForm+ name={t.name}+ color={t.color}+ isPublic={t.isPublic}+ onSave={async data => this.updateTag(t, data)}+ onCancel={() => this.setState({ editing: undefined })}+ />+ </div>+ );}- }-- public render() {- const items = this.state.allTags.map(- (t) => {- if (this.state.editing === t.id) {- return (- <div key={t.id} className="item">- <TagForm- name={t.name}- color={t.color}- isPublic={t.isPublic}- onSave={async (data) => this.updateTag(t, data)}- onCancel={() => this.setState({ editing: undefined })}- />- </div>- );- }- if (this.state.deleting === t.id) {- return (- <div key={t.id} className="item">- <div className="content">- <b>Are you sure?</b> <span>The tag <ShowTag tag={t} /> will be removed from all ideas.</span>- </div>- <Button- className="right floated"- onClick={async () => this.setState({ deleting: undefined })}- >- Cancel- </Button>- <Button- color="red"- className="right floated"- onClick={() => this.deleteTag(t)}- >- Delete tag- </Button>- </div>- );- }+ if (this.state.deleting === t.id) {+ return (+ <div key={t.id} className="item">+ <div className="content">+ <b>Are you sure?</b>{" "}+ <span>+ The tag <ShowTag tag={t} /> will be removed from all ideas.+ </span>+ </div>+ <Button className="right floated" onClick={async () => this.setState({ deleting: undefined })}>+ Cancel+ </Button>+ <Button color="red" className="right floated" onClick={() => this.deleteTag(t)}>+ Delete tag+ </Button>+ </div>+ );+ }- return (- <div key={t.id} className="item">- <ShowTag tag={t} />- {- this.props.user.isAdministrator && [- <Button- key={0}- onClick={async () => this.setState({ isAdding: false, editing: undefined, deleting: t.id })}- className="right floated"- >- <i className="remove icon" />Remove- </Button>,- <Button- key={1}- onClick={async () => this.setState({ isAdding: false, editing: t.id, deleting: undefined })}- className="right floated"- >- <i className="edit icon" />Edit- </Button>- ]+ return (+ <div key={t.id} className="item">+ <ShowTag tag={t} />+ {this.props.user.isAdministrator && [+ <Button+ key={0}+ onClick={async () =>+ this.setState({+ isAdding: false,+ editing: undefined,+ deleting: t.id+ })}- </div>- );- }+ className="right floated"+ >+ <i className="remove icon" />Remove+ </Button>,+ <Button+ key={1}+ onClick={async () =>+ this.setState({+ isAdding: false,+ editing: t.id,+ deleting: undefined+ })+ }+ className="right floated"+ >+ <i className="edit icon" />Edit+ </Button>+ ]}+ </div>);+ });- return (- <div className="page ui container">- <h2 className="ui header">- <i className="circular tags icon" />- <div className="content">- Tags- <div className="sub header">Manage your account tags.</div>- </div>- </h2>+ return (+ <div className="page ui container">+ <h2 className="ui header">+ <i className="circular tags icon" />+ <div className="content">+ Tags+ <div className="sub header">Manage your account tags.</div>+ </div>+ </h2>- {- this.props.user.isAdministrator && (- this.state.isAdding- ? <div className="ui segment">- <TagForm- onSave={async (data) => this.saveNewTag(data)}- onCancel={() => this.setState({ isAdding: false })}- />- </div>- : <Button- color="green"- onClick={async (e) => this.setState({ isAdding: true, deleting: undefined, editing: undefined })}- >- Add new- </Button>- )- }+ {this.props.user.isAdministrator &&+ (this.state.isAdding ? (+ <div className="ui segment">+ <TagForm+ onSave={async data => this.saveNewTag(data)}+ onCancel={() => this.setState({ isAdding: false })}+ />+ </div>+ ) : (+ <Button+ color="green"+ onClick={async e =>+ this.setState({+ isAdding: true,+ deleting: undefined,+ editing: undefined+ })+ }+ >+ Add new+ </Button>+ ))}- <div className="ui segment">- <div className="ui middle aligned very relaxed divided list">+ <div className="ui segment">+ <div className="ui middle aligned very relaxed divided list">{items.length ? items : <div className="content">There aren’t any tags yet.</div>}- </div></div>-</div>- );- }+ </div>+ );+ }}diff --git a/public/pages/ManageTags/components/TagForm.tsx b/public/pages/ManageTags/components/TagForm.tsxindex 831fb6912..cc7d62042 100644--- a/public/pages/ManageTags/components/TagForm.tsx+++ b/public/pages/ManageTags/components/TagForm.tsx@@ -1,10 +1,10 @@-import './TagForm.scss';+import "./TagForm.scss";-import * as React from 'react';-import { Button, ButtonClickEvent, DisplayError } from '@fider/components/common';-import { ShowTag } from '@fider/components/ShowTag';-import { Tag } from '@fider/models';-import { Failure } from '@fider/services';+import * as React from "react";+import { Button, ButtonClickEvent, DisplayError } from "@fider/components/common";+import { ShowTag } from "@fider/components/ShowTag";+import { Tag } from "@fider/models";+import { Failure } from "@fider/services";interface TagFormProps {name?: string;@@ -26,14 +26,14 @@ export class TagForm extends React.Component<TagFormProps, TagFormState> {super(props);this.state = {color: props.color || this.randomizeColor(),- name: props.name || '',+ name: props.name || "",isPublic: props.isPublic || false};}private randomizeColor(): string {- const letters = '0123456789ABCDEF';- let color = '';+ const letters = "0123456789ABCDEF";+ let color = "";for (let i = 0; i < 6; i++) {color += letters[Math.floor(Math.random() * 16)];}@@ -55,30 +55,27 @@ export class TagForm extends React.Component<TagFormProps, TagFormState> {<label>Name</label><inputclassName="name"- onChange={(e) => this.setState({ name: e.currentTarget.value })}+ onChange={e => this.setState({ name: e.currentTarget.value })}type="text"placeholder="New tag name"value={this.state.name}/>- <DisplayError fields={['name']} error={this.state.error} pointing="above" />+ <DisplayError fields={["name"]} error={this.state.error} pointing="above" /></div><div className="three wide field"><label>Color- <span- className="info clickable"- onClick={() => this.setState({ color: this.randomizeColor() })}- >+ <span className="info clickable" onClick={() => this.setState({ color: this.randomizeColor() })}>randomize</span></label><inputclassName="color"- onChange={(e) => this.setState({ color: e.currentTarget.value })}+ onChange={e => this.setState({ color: e.currentTarget.value })}type="text"value={this.state.color}/>- <DisplayError fields={['color']} error={this.state.error} pointing="above" />+ <DisplayError fields={["color"]} error={this.state.error} pointing="above" /></div><div className="two wide field"><div className="grouped fields">@@ -90,7 +87,7 @@ export class TagForm extends React.Component<TagFormProps, TagFormState> {type="radio"name="visibility"checked={this.state.isPublic}- onChange={(e) => this.setState({ isPublic: true })}+ onChange={e => this.setState({ isPublic: true })}/><label htmlFor="visibility-public">Public</label></div>@@ -102,7 +99,7 @@ export class TagForm extends React.Component<TagFormProps, TagFormState> {type="radio"name="visibility"checked={!this.state.isPublic}- onChange={(e) => this.setState({ isPublic: false })}+ onChange={e => this.setState({ isPublic: false })}/><label htmlFor="visibility-private">Private</label></div>@@ -114,7 +111,7 @@ export class TagForm extends React.Component<TagFormProps, TagFormState> {<ShowTagtag={{id: 0,- slug: '',+ slug: "",name: this.state.name,color: this.state.color,isPublic: this.state.isPublic@@ -123,7 +120,9 @@ export class TagForm extends React.Component<TagFormProps, TagFormState> {</div></div><Button onClick={async () => this.props.onCancel()}>Cancel</Button>- <Button color="green" onClick={(e) => this.onSave(e)}>Save</Button>+ <Button color="green" onClick={e => this.onSave(e)}>+ Save+ </Button></div>);}diff --git a/public/pages/ManageTags/index.ts b/public/pages/ManageTags/index.tsindex e65db27b6..2b25a9ba0 100644--- a/public/pages/ManageTags/index.ts+++ b/public/pages/ManageTags/index.ts@@ -1,2 +1,2 @@-export * from './ManageTags.page';-export * from './components/TagForm';+export * from "./ManageTags.page";+export * from "./components/TagForm";diff --git a/public/pages/MyNotifications/MyNotifications.page.tsx b/public/pages/MyNotifications/MyNotifications.page.tsxindex 27ddd7bbb..fd61b9268 100644--- a/public/pages/MyNotifications/MyNotifications.page.tsx+++ b/public/pages/MyNotifications/MyNotifications.page.tsx@@ -1,10 +1,10 @@-import './MyNotifications.page.scss';+import "./MyNotifications.page.scss";-import * as React from 'react';+import * as React from "react";-import { CurrentUser, Notification } from '@fider/models';-import { MultiLineText, Moment } from '@fider/components';-import { page, actions } from '@fider/services';+import { CurrentUser, Notification } from "@fider/models";+import { MultiLineText, Moment } from "@fider/components";+import { page, actions } from "@fider/services";interface MyNotificationsPageProps {notifications: Notification[];@@ -16,29 +16,31 @@ interface MyNotificationsPageState {}export class MyNotificationsPage extends React.Component<MyNotificationsPageProps, MyNotificationsPageState> {-constructor(props: MyNotificationsPageProps) {super(props);- const [ unread, recent ] = (this.props.notifications || []).reduce((result, item) => {- result[item.read ? 1 : 0].push(item);- return result;- }, [ [] as Notification[], [] as Notification[] ]);+ const [unread, recent] = (this.props.notifications || []).reduce(+ (result, item) => {+ result[item.read ? 1 : 0].push(item);+ return result;+ },+ [[] as Notification[], [] as Notification[]]+ );this.state = {unread,- recent,+ recent};}private items(notifications: Notification[]): JSX.Element[] {- return notifications.map((n) => {+ return notifications.map(n => {return (<span key={n.id} className="item"><a href={`/notifications/${n.id}`}><MultiLineText text={n.title} style="simple" /><span className="info">- <Moment date={n.createdOn} />+ <Moment date={n.createdOn} /></span></a></span>@@ -68,32 +70,24 @@ export class MyNotificationsPage extends React.Component<MyNotificationsPageProp<div className="ten wide computer sixteen wide mobile column"><h4>Unread- {- this.state.unread.length > 0 &&- <span- className="mark-as-read"- onClick={() => this.markAllAsRead()}- >+ {this.state.unread.length > 0 && (+ <span className="mark-as-read" onClick={() => this.markAllAsRead()}>Mark All as Read</span>- }+ )}</h4><div className="ui list">{this.state.unread.length > 0 && this.items(this.state.unread)}{this.state.unread.length === 0 && <span className="info">No unread notifications.</span>}</div>- {- this.state.recent.length > 0 &&+ {this.state.recent.length > 0 && (<><h4>Read on last 30 days</h4>- <div className="ui list">- {this.items(this.state.recent)}- </div>+ <div className="ui list">{this.items(this.state.recent)}</div></>- }+ )}</div></div>-</div>);}diff --git a/public/pages/MyNotifications/index.ts b/public/pages/MyNotifications/index.tsindex ad0397606..9b3c5df4c 100644--- a/public/pages/MyNotifications/index.ts+++ b/public/pages/MyNotifications/index.ts@@ -1 +1 @@-export * from './MyNotifications.page';+export * from "./MyNotifications.page";diff --git a/public/pages/MySettings/MySettings.page.tsx b/public/pages/MySettings/MySettings.page.tsxindex d8ed0780e..f1d9fe934 100644--- a/public/pages/MySettings/MySettings.page.tsx+++ b/public/pages/MySettings/MySettings.page.tsx@@ -1,12 +1,12 @@-import './MySettings.page.scss';+import "./MySettings.page.scss";-import * as React from 'react';+import * as React from "react";-import { Modal, Form, DisplayError, Button, Gravatar } from '@fider/components/common';-import { NotificationSettings } from './';+import { Modal, Form, DisplayError, Button, Gravatar } from "@fider/components/common";+import { NotificationSettings } from "./";-import { CurrentUser, UserSettings } from '@fider/models';-import { Failure, actions } from '@fider/services';+import { CurrentUser, UserSettings } from "@fider/models";+import { Failure, actions } from "@fider/services";interface MySettingsPageState {showModal: boolean;@@ -23,13 +23,12 @@ interface MySettingsPageProps {}export class MySettingsPage extends React.Component<MySettingsPageProps, MySettingsPageState> {-constructor(props: MySettingsPageProps) {super(props);this.state = {showModal: false,changingEmail: false,- newEmail: '',+ newEmail: "",name: this.props.user.name,settings: this.props.settings};@@ -47,7 +46,11 @@ export class MySettingsPage extends React.Component<MySettingsPageProps, MySettiprivate async submitNewEmail() {const result = await actions.changeUserEmail(this.state.newEmail);if (result.ok) {- this.setState({ error: undefined, changingEmail: false, showModal: true });+ this.setState({+ error: undefined,+ changingEmail: false,+ showModal: true+ });} else if (result.error) {this.setState({ error: result.error });}@@ -60,8 +63,15 @@ export class MySettingsPage extends React.Component<MySettingsPageProps, MySetti<Modal.Header>Confirm your new email</Modal.Header><Modal.Content><div>- <p>We have just sent a confirmation link to <b>{this.state.newEmail}</b>. <br /> Click the link to update your email.</p>- <p><a href="#" onClick={() => this.setState({ showModal: false })}>OK</a></p>+ <p>+ We have just sent a confirmation link to <b>{this.state.newEmail}</b>. <br /> Click the link to update+ your email.+ </p>+ <p>+ <a href="#" onClick={() => this.setState({ showModal: false })}>+ OK+ </a>+ </p></div></Modal.Content></Modal.Window>@@ -78,49 +88,69 @@ export class MySettingsPage extends React.Component<MySettingsPageProps, MySetti<div className="ten wide computer sixteen wide mobile column"><div className="ui form"><div className="field">- <label htmlFor="email">Avatar</label>- <p><Gravatar user={this.props.user} /></p>- <div className="info">- <p>- This site uses <a href="https://en.gravatar.com/" target="blank">Gravatar</a> to display profile avatars. <br/>- A letter avatar based on your name is generated for profiles without a Gravatar.- </p>- </div>+ <label htmlFor="email">Avatar</label>+ <p>+ <Gravatar user={this.props.user} />+ </p>+ <div className="info">+ <p>+ This site uses{" "}+ <a href="https://en.gravatar.com/" target="blank">+ Gravatar+ </a>{" "}+ to display profile avatars. <br />+ A letter avatar based on your name is generated for profiles without a Gravatar.+ </p>+ </div></div>- <DisplayError fields={['email']} error={this.state.error} />+ <DisplayError fields={["email"]} error={this.state.error} /><div className="field">- <label htmlFor="email">Email <span className="info">Your email is private and will never be displayed to anyone.</span></label>- {- this.state.changingEmail ?- <>- <p>- <input- id="new-email"- type="text"- style={{maxWidth: '200px', marginRight: '10px'}}- maxLength={200}- placeholder={this.props.user.email}- value={this.state.newEmail}- onChange={(e) => this.setState({ newEmail: e.currentTarget.value })}- />- <Button color="green" size="mini" onClick={async () => await this.submitNewEmail()}>Confirm</Button>- <Button size="mini" onClick={async () => this.setState({ changingEmail: false, error: undefined })}>Cancel</Button>- </p>- </>- :+ <label htmlFor="email">+ Email <span className="info">Your email is private and will never be displayed to anyone.</span>+ </label>+ {this.state.changingEmail ? (+ <><p>- {- this.props.user.email- ? <b>{this.props.user.email}</b>- : <span className="info">Your account doesn't have an email.</span>- }- <span className="ui info clickable" onClick={() => this.setState({ changingEmail: true })}>change</span>+ <input+ id="new-email"+ type="text"+ style={{ maxWidth: "200px", marginRight: "10px" }}+ maxLength={200}+ placeholder={this.props.user.email}+ value={this.state.newEmail}+ onChange={e => this.setState({ newEmail: e.currentTarget.value })}+ />+ <Button color="green" size="mini" onClick={async () => await this.submitNewEmail()}>+ Confirm+ </Button>+ <Button+ size="mini"+ onClick={async () =>+ this.setState({+ changingEmail: false,+ error: undefined+ })+ }+ >+ Cancel+ </Button></p>- }-+ </>+ ) : (+ <p>+ {this.props.user.email ? (+ <b>{this.props.user.email}</b>+ ) : (+ <span className="info">Your account doesn't have an email.</span>+ )}+ <span className="ui info clickable" onClick={() => this.setState({ changingEmail: true })}>+ change+ </span>+ </p>+ )}</div>- <DisplayError fields={['name']} error={this.state.error} />+ <DisplayError fields={["name"]} error={this.state.error} /><div className="field"><label htmlFor="name">Name</label><input@@ -128,18 +158,20 @@ export class MySettingsPage extends React.Component<MySettingsPageProps, MySettitype="text"maxLength={100}value={this.state.name}- onChange={(e) => this.setState({ name: e.currentTarget.value })}+ onChange={e => this.setState({ name: e.currentTarget.value })}/></div><NotificationSettingsuser={this.props.user}settings={this.props.settings}- settingsChanged={(settings) => this.setState({ settings })}+ settingsChanged={settings => this.setState({ settings })}/><div className="field">- <Button color="green" size="large" onClick={async () => await this.confirm()}>Confirm</Button>+ <Button color="green" size="large" onClick={async () => await this.confirm()}>+ Confirm+ </Button></div></div></div>diff --git a/public/pages/MySettings/components/NotificationSettings.tsx b/public/pages/MySettings/components/NotificationSettings.tsxindex 6d3e2c50d..23dbdf705 100644--- a/public/pages/MySettings/components/NotificationSettings.tsx+++ b/public/pages/MySettings/components/NotificationSettings.tsx@@ -1,6 +1,6 @@-import * as React from 'react';+import * as React from "react";-import { CurrentUser, UserSettings } from '@fider/models';+import { CurrentUser, UserSettings } from "@fider/models";interface NotificationSettingsProps {user: CurrentUser;@@ -33,7 +33,7 @@ export class NotificationSettings extends React.Component<NotificationSettingsPr}private toggle(settingsKey: string, channel: Channel) {- const settings = {...this.state.settings};+ const settings = { ...this.state.settings };settings[settingsKey] = (parseInt(this.state.settings[settingsKey], 10) ^ channel).toString();this.setState({ settings });@@ -41,12 +41,12 @@ export class NotificationSettings extends React.Component<NotificationSettingsPr}private icon(settingsKey: string, channel: Channel) {- const i = this.isEnabled(settingsKey, channel)- ? <i className="green large toggle on icon" />- : <i className="large toggle off icon" />;- const text = channel === WebChannel- ? 'Web *'- : 'Email';+ const i = this.isEnabled(settingsKey, channel) ? (+ <i className="green large toggle on icon" />+ ) : (+ <i className="large toggle off icon" />+ );+ const text = channel === WebChannel ? "Web *" : "Email";return (<span className="option" onClick={this.toggle.bind(this, settingsKey, channel)}>{i} {text}@@ -60,13 +60,29 @@ export class NotificationSettings extends React.Component<NotificationSettingsPrconst emailEnabled = this.isEnabled(settingsKey, EmailChannel);if (!webEnabled && !emailEnabled) {- return <p className="info">You'll <strong>NOT</strong> receive any notification about this event.</p>;+ return (+ <p className="info">+ You'll <strong>NOT</strong> receive any notification about this event.+ </p>+ );} else if (webEnabled && !emailEnabled) {- return <p className="info">You'll receive <strong>web</strong> notifications about {about}.</p>;+ return (+ <p className="info">+ You'll receive <strong>web</strong> notifications about {about}.+ </p>+ );} else if (!webEnabled && emailEnabled) {- return <p className="info">You'll receive <strong>email</strong> notifications about {about}.</p>;+ return (+ <p className="info">+ You'll receive <strong>email</strong> notifications about {about}.+ </p>+ );} else if (webEnabled && emailEnabled) {- return <p className="info">You'll receive <strong>web</strong> and <strong>email</strong> notifications about {about}.</p>;+ return (+ <p className="info">+ You'll receive <strong>web</strong> and <strong>email</strong> notifications about {about}.+ </p>+ );}return null;}@@ -82,26 +98,34 @@ export class NotificationSettings extends React.Component<NotificationSettingsPr<div className="ui segments notifications-settings"><div className="ui segment"><span className="event-title">New Idea</span>- {this.info('event_notification_new_idea', 'new ideas posted on this site', 'new ideas posted on this site')}+ {this.info("event_notification_new_idea", "new ideas posted on this site", "new ideas posted on this site")}<p>- {this.icon('event_notification_new_idea', WebChannel)}- {this.icon('event_notification_new_idea', EmailChannel)}+ {this.icon("event_notification_new_idea", WebChannel)}+ {this.icon("event_notification_new_idea", EmailChannel)}</p></div><div className="ui segment"><span className="event-title">Discussion</span>- {this.info('event_notification_new_comment', 'comments on ideas you\'ve subscribed to', 'comments on all ideas unless individually unsubscribed')}+ {this.info(+ "event_notification_new_comment",+ "comments on ideas you've subscribed to",+ "comments on all ideas unless individually unsubscribed"+ )}<p>- {this.icon('event_notification_new_comment', WebChannel)}- {this.icon('event_notification_new_comment', EmailChannel)}+ {this.icon("event_notification_new_comment", WebChannel)}+ {this.icon("event_notification_new_comment", EmailChannel)}</p></div><div className="ui segment"><span className="event-title">Status Changed</span>- {this.info('event_notification_change_status', 'status change on ideas you\'ve subscribed to', 'status change on all ideas unless individually unsubscribed')}+ {this.info(+ "event_notification_change_status",+ "status change on ideas you've subscribed to",+ "status change on all ideas unless individually unsubscribed"+ )}<p>- {this.icon('event_notification_change_status', WebChannel)}- {this.icon('event_notification_change_status', EmailChannel)}+ {this.icon("event_notification_change_status", WebChannel)}+ {this.icon("event_notification_change_status", EmailChannel)}</p></div></div>diff --git a/public/pages/MySettings/index.ts b/public/pages/MySettings/index.tsindex 6b10fa593..992f2ac78 100644--- a/public/pages/MySettings/index.ts+++ b/public/pages/MySettings/index.ts@@ -1,2 +1,2 @@-export * from './MySettings.page';-export * from './components/NotificationSettings';+export * from "./MySettings.page";+export * from "./components/NotificationSettings";diff --git a/public/pages/ShowIdea/ShowIdea.page.tsx b/public/pages/ShowIdea/ShowIdea.page.tsxindex 57e424b97..d6a9fc52b 100644--- a/public/pages/ShowIdea/ShowIdea.page.tsx+++ b/public/pages/ShowIdea/ShowIdea.page.tsx@@ -1,12 +1,22 @@-import './ShowIdea.page.scss';--import * as React from 'react';--import { CurrentUser, Comment, Idea, Tag } from '@fider/models';-import { page, actions, Failure } from '@fider/services';--import { TagsPanel, DiscussionPanel, ResponseForm, NotificationsPanel, ModerationPanel } from './';-import { SupportCounter, ShowIdeaResponse, DisplayError, Button, Textarea, UserName, Gravatar, Moment, MultiLineText } from '@fider/components';+import "./ShowIdea.page.scss";++import * as React from "react";++import { CurrentUser, Comment, Idea, Tag } from "@fider/models";+import { page, actions, Failure } from "@fider/services";++import { TagsPanel, DiscussionPanel, ResponseForm, NotificationsPanel, ModerationPanel } from "./";+import {+ SupportCounter,+ ShowIdeaResponse,+ DisplayError,+ Button,+ Textarea,+ UserName,+ Gravatar,+ Moment,+ MultiLineText+} from "@fider/components";interface ShowIdeaPageProps {user?: CurrentUser;@@ -24,14 +34,13 @@ interface ShowIdeaPageState {}export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPageState> {-constructor(props: ShowIdeaPageProps) {super(props);this.state = {editMode: false,newTitle: this.props.idea.title,- newDescription: this.props.idea.description,+ newDescription: this.props.idea.description};page.setTitle(`${this.props.idea.title} · ${document.title}`);@@ -63,47 +72,57 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag<SupportCounter user={this.props.user} idea={this.props.idea} /><div className="idea-header">- { this.state.editMode- ? [+ {this.state.editMode ? (+ [<div key={1} className="ui input huge fluid">- <input type="text" maxLength={100} onChange={(e) => this.setState({ newTitle: e.currentTarget.value })} defaultValue={this.state.newTitle} />+ <input+ type="text"+ maxLength={100}+ onChange={e => this.setState({ newTitle: e.currentTarget.value })}+ defaultValue={this.state.newTitle}+ /></div>,- <DisplayError key={0} fields={['title']} pointing="above" error={this.state.error} />+ <DisplayError key={0} fields={["title"]} pointing="above" error={this.state.error} />]- : <h1 className="ui header">{this.props.idea.title}</h1>- }+ ) : (+ <h1 className="ui header">{this.props.idea.title}</h1>+ )}<span className="info">- Shared <Moment date={this.props.idea.createdOn} /> by <Gravatar user={this.props.idea.user} /> <UserName user={this.props.idea.user} />+ Shared <Moment date={this.props.idea.createdOn} /> by <Gravatar user={this.props.idea.user} />{" "}+ <UserName user={this.props.idea.user} /></span></div></div></div><span className="subtitle">Description</span>- {- this.state.editMode- ? <div className="ui form">- <div className="field">- <DisplayError fields={['description']} error={this.state.error} />- <Textarea onChange={(e) => this.setState({ newDescription: e.currentTarget.value })} defaultValue={this.state.newDescription} />- </div>+ {this.state.editMode ? (+ <div className="ui form">+ <div className="field">+ <DisplayError fields={["description"]} error={this.state.error} />+ <Textarea+ onChange={e => this.setState({ newDescription: e.currentTarget.value })}+ defaultValue={this.state.newDescription}+ /></div>- : this.props.idea.description- ? <MultiLineText className="description" text={this.props.idea.description} style="simple" />- : <p className="description">This idea doesn't have a description.</p>- }+ </div>+ ) : this.props.idea.description ? (+ <MultiLineText className="description" text={this.props.idea.description} style="simple" />+ ) : (+ <p className="description">This idea doesn't have a description.</p>+ )}<ShowIdeaResponse status={this.props.idea.status} response={this.props.idea.response} />-</div><div className="action-col">- {- this.props.user && this.props.user.isCollaborator && [- <span key={0} className="subtitle">Actions</span>,- this.state.editMode- ?+ {this.props.user &&+ this.props.user.isCollaborator && [+ <span key={0} className="subtitle">+ Actions+ </span>,+ this.state.editMode ? (<div key={1} className="ui list"><div className="item"><Button color="green" size="small" fluid={true} onClick={async () => this.saveChanges()}>@@ -111,24 +130,28 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag</Button></div><div className="item">- <Button fluid={true} size="small" onClick={async () => this.setState({ error: undefined, editMode: false })}>+ <Button+ fluid={true}+ size="small"+ onClick={async () => this.setState({ error: undefined, editMode: false })}+ ><i className="cancel icon" /> Cancel</Button></div></div>- :+ ) : (<div key={1} className="ui list"><div className="item">- <Button fluid={true} size="small" onClick={async () => this.setState({ editMode: true })}>- <i className="edit icon" /> Edit- </Button>+ <Button fluid={true} size="small" onClick={async () => this.setState({ editMode: true })}>+ <i className="edit icon" /> Edit+ </Button></div><div className="item"><ResponseForm idea={this.props.idea} /></div></div>- ]- }+ )+ ]}<TagsPanel user={this.props.user} idea={this.props.idea} tags={this.props.tags} /><NotificationsPanel user={this.props.user} idea={this.props.idea} subscribed={this.props.subscribed} />diff --git a/public/pages/ShowIdea/components/CommentInput.tsx b/public/pages/ShowIdea/components/CommentInput.tsxindex 35e41a12a..a119a184a 100644--- a/public/pages/ShowIdea/components/CommentInput.tsx+++ b/public/pages/ShowIdea/components/CommentInput.tsx@@ -1,11 +1,11 @@-import * as React from 'react';-import * as ReactDOM from 'react-dom';+import * as React from "react";+import * as ReactDOM from "react-dom";-import { Idea, CurrentUser } from '@fider/models';-import { Gravatar, UserName, Button, Textarea, DisplayError, SignInControl } from '@fider/components/common';-import { SignInModal } from '@fider/components';+import { Idea, CurrentUser } from "@fider/models";+import { Gravatar, UserName, Button, Textarea, DisplayError, SignInControl } from "@fider/components/common";+import { SignInModal } from "@fider/components";-import { page, actions, Failure } from '@fider/services';+import { page, actions, Failure } from "@fider/services";interface CommentInputProps {user?: CurrentUser;@@ -25,8 +25,8 @@ export class CommentInput extends React.Component<CommentInputProps, CommentInpusuper(props);this.state = {- content: '',- showSignIn: false,+ content: "",+ showSignIn: false};}@@ -47,36 +47,36 @@ export class CommentInput extends React.Component<CommentInputProps, CommentInpulocation.reload();} else {this.setState({- error: result.error,+ error: result.error});}}public render() {-return (<><SignInModal isOpen={this.state.showSignIn} />- <div className={`comment-input ${this.props.user && 'authenticated' }`}>+ <div className={`comment-input ${this.props.user && "authenticated"}`}>{this.props.user && <Gravatar user={this.props.user} />}<div className="ui form">{this.props.user && <UserName user={this.props.user} />}<DisplayError error={this.state.error} /><div className="field"><Textarea- onChange={(e) => { this.setState({ content: e.currentTarget.value }); }}+ onChange={e => {+ this.setState({ content: e.currentTarget.value });+ }}onFocus={() => this.onTextFocused()}- inputRef={(e) => this.input = e!}+ inputRef={e => (this.input = e!)}rows={1}placeholder="Write a comment..."/></div>- {- this.state.content &&+ {this.state.content && (<Button color="green" onClick={() => this.submit()}>Submit</Button>- }+ )}</div></div></>diff --git a/public/pages/ShowIdea/components/CommentList.tsx b/public/pages/ShowIdea/components/CommentList.tsxindex a044db951..29c0e96ff 100644--- a/public/pages/ShowIdea/components/CommentList.tsx+++ b/public/pages/ShowIdea/components/CommentList.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { Idea, Comment, CurrentUser } from '@fider/models';-import { Failure, actions, formatDate } from '@fider/services';-import { DisplayError, Textarea, Button, UserName, Gravatar, Moment, MultiLineText } from '@fider/components/common';+import * as React from "react";+import { Idea, Comment, CurrentUser } from "@fider/models";+import { Failure, actions, formatDate } from "@fider/services";+import { DisplayError, Textarea, Button, UserName, Gravatar, Moment, MultiLineText } from "@fider/components/common";interface CommentListProps {idea: Idea;@@ -21,7 +21,7 @@ export class CommentList extends React.Component<CommentListProps, CommentListStconstructor(props: CommentListProps) {super(props);this.state = {- editCommentNewContent: '',+ editCommentNewContent: ""};}@@ -29,7 +29,7 @@ export class CommentList extends React.Component<CommentListProps, CommentListStthis.setState({editingComment: comment,editCommentNewContent: comment.content,- error: undefined,+ error: undefined});if (this.props.onStartEdit) {@@ -40,8 +40,8 @@ export class CommentList extends React.Component<CommentListProps, CommentListStprivate async cancelEdit(): Promise<void> {this.setState({editingComment: undefined,- editCommentNewContent: '',- error: undefined,+ editCommentNewContent: "",+ error: undefined});if (this.props.onStopEdit) {@@ -51,7 +51,11 @@ export class CommentList extends React.Component<CommentListProps, CommentListStprivate async confirmEdit(): Promise<void> {if (this.state.editingComment) {- const response = await actions.updateComment(this.props.idea.number, this.state.editingComment.id, this.state.editCommentNewContent);+ const response = await actions.updateComment(+ this.props.idea.number,+ this.state.editingComment.id,+ this.state.editCommentNewContent+ );if (response.ok) {this.state.editingComment.content = this.state.editCommentNewContent;this.state.editingComment.editedOn = new Date().toISOString();@@ -71,7 +75,7 @@ export class CommentList extends React.Component<CommentListProps, CommentListSt}public render() {- return this.props.comments.map((c) => {+ return this.props.comments.map(c => {return (<div key={c.id} className="comment"><Gravatar user={c.user} />@@ -80,30 +84,49 @@ export class CommentList extends React.Component<CommentListProps, CommentListSt<div className="metadata">· <Moment date={c.createdOn} /></div>- { !!c.editedOn && !!c.editedBy && <div className="metadata">- · <span title={`This comment has been edited by ${c.editedBy!.name} on ${formatDate(c.editedOn)}`}>edited</span>- </div> }- { this.canEditComment(c) && <div className="metadata">- · <Button simple={true} size="small" onClick={() => this.startEdit(c)}>edit</Button>- </div> }+ {!!c.editedOn &&+ !!c.editedBy && (+ <div className="metadata">+ ·{" "}+ <span title={`This comment has been edited by ${c.editedBy!.name} on ${formatDate(c.editedOn)}`}>+ edited+ </span>+ </div>+ )}+ {this.canEditComment(c) && (+ <div className="metadata">+ ·{" "}+ <Button simple={true} size="small" onClick={() => this.startEdit(c)}>+ edit+ </Button>+ </div>+ )}<div className="text">- {- c === this.state.editingComment- ? <div className="ui form">- <DisplayError error={this.state.error} />- <div className="field">- <Textarea- rows={1}- defaultValue={c.content}- placeholder={c.content}- onChange={(e) => this.setState({ editCommentNewContent: e.currentTarget.value })}- />- </div>- <Button size="tiny" onClick={() => this.confirmEdit()} color="green">Save</Button>- <Button size="tiny" onClick={() => this.cancelEdit()}>Cancel</Button>+ {c === this.state.editingComment ? (+ <div className="ui form">+ <DisplayError error={this.state.error} />+ <div className="field">+ <Textarea+ rows={1}+ defaultValue={c.content}+ placeholder={c.content}+ onChange={e =>+ this.setState({+ editCommentNewContent: e.currentTarget.value+ })+ }+ /></div>- : <MultiLineText text={c.content} style="simple" />- }+ <Button size="tiny" onClick={() => this.confirmEdit()} color="green">+ Save+ </Button>+ <Button size="tiny" onClick={() => this.cancelEdit()}>+ Cancel+ </Button>+ </div>+ ) : (+ <MultiLineText text={c.content} style="simple" />+ )}</div></div></div>diff --git a/public/pages/ShowIdea/components/DiscussionPanel.tsx b/public/pages/ShowIdea/components/DiscussionPanel.tsxindex b0e5f4cc9..aa77a06c4 100644--- a/public/pages/ShowIdea/components/DiscussionPanel.tsx+++ b/public/pages/ShowIdea/components/DiscussionPanel.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { CurrentUser, Comment, Idea } from '@fider/models';-import { CommentList, CommentInput } from '../';-import { actions } from '@fider/services';+import * as React from "react";+import { CurrentUser, Comment, Idea } from "@fider/models";+import { CommentList, CommentInput } from "../";+import { actions } from "@fider/services";interface DiscussionPanelProps {user?: CurrentUser;@@ -14,11 +14,10 @@ interface DiscussionPanelState {}export class DiscussionPanel extends React.Component<DiscussionPanelProps, DiscussionPanelState> {-constructor(props: DiscussionPanelProps) {super(props);this.state = {- isEditing: false,+ isEditing: false};}@@ -34,10 +33,7 @@ export class DiscussionPanel extends React.Component<DiscussionPanelProps, DiscuonStartEdit={() => this.setState({ isEditing: true })}onStopEdit={() => this.setState({ isEditing: false })}/>- { !this.state.isEditing && <CommentInput- user={this.props.user}- idea={this.props.idea}- /> }+ {!this.state.isEditing && <CommentInput user={this.props.user} idea={this.props.idea} />}</div></div>);diff --git a/public/pages/ShowIdea/components/IdeaSearch.tsx b/public/pages/ShowIdea/components/IdeaSearch.tsxindex 9b457557f..2f4d0c194 100644--- a/public/pages/ShowIdea/components/IdeaSearch.tsx+++ b/public/pages/ShowIdea/components/IdeaSearch.tsx@@ -1,6 +1,6 @@-import * as React from 'react';-import { Idea, IdeaStatus } from '@fider/models';-import { actions } from '@fider/services';+import * as React from "react";+import { Idea, IdeaStatus } from "@fider/models";+import { actions } from "@fider/services";interface IdeaSearchProps {exclude?: number[];@@ -16,11 +16,12 @@ export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchStateconstructor(props: IdeaSearchProps) {super(props);- this.state = { };- actions.getAllIdeas().then((res) => {- const ideas = this.props.exclude && this.props.exclude.length > 0- ? res.data.filter((i) => this.props.exclude!.indexOf(i.number) === -1)- : res.data;+ this.state = {};+ actions.getAllIdeas().then(res => {+ const ideas =+ this.props.exclude && this.props.exclude.length > 0+ ? res.data.filter(i => this.props.exclude!.indexOf(i.number) === -1)+ : res.data;this.setState({ ideas });});}@@ -39,14 +40,15 @@ export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchStatepublic render() {const items = this.state.ideas && (<div className="menu">- {this.state.ideas.map((i) => {+ {this.state.ideas.map(i => {const status = IdeaStatus.Get(i.status);return (<div key={i.id} className="item" data-value={i.number} data-text={i.title}>- <span className="support"><i className="medium caret up icon" />{i.totalSupporters}</span>- <span className={`ui mini label ${status.color}`}>- {status.title}+ <span className="support">+ <i className="medium caret up icon" />+ {i.totalSupporters}</span>+ <span className={`ui mini label ${status.color}`}>{status.title}</span>{i.title}</div>);@@ -54,10 +56,10 @@ export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchState</div>);- const className = `ui selection ${items ? 'search' : 'loading'} fluid dropdown fdr-idea-search`;+ const className = `ui selection ${items ? "search" : "loading"} fluid dropdown fdr-idea-search`;return (- <div className={className} ref={(e) => this.element = e!}>+ <div className={className} ref={e => (this.element = e!)}><i className="dropdown icon" /><div className="default text">Search original idea</div>{items}diff --git a/public/pages/ShowIdea/components/ModerationPanel.tsx b/public/pages/ShowIdea/components/ModerationPanel.tsxindex b2122e9b7..f67b07c74 100644--- a/public/pages/ShowIdea/components/ModerationPanel.tsx+++ b/public/pages/ShowIdea/components/ModerationPanel.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { IdeaStatus, CurrentUser, Idea } from '@fider/models';-import { page, actions, Failure } from '@fider/services';-import { Form, DisplayError, Textarea, Modal, Button } from '@fider/components';+import * as React from "react";+import { IdeaStatus, CurrentUser, Idea } from "@fider/models";+import { page, actions, Failure } from "@fider/services";+import { Form, DisplayError, Textarea, Modal, Button } from "@fider/components";interface ModerationPanelProps {user?: CurrentUser;@@ -19,8 +19,8 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moderconstructor(props: ModerationPanelProps) {super(props);this.state = {- text: '',- showConfirmation: false,+ text: "",+ showConfirmation: false};}@@ -47,15 +47,21 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moderconst modal = (<Modal.Window isOpen={this.state.showConfirmation} center={false} size="large"><Modal.Content>- <Form ref={(f) => { this.form = f!; }}>+ <Form+ ref={f => {+ this.form = f!;+ }}+ ><div className="field"><Textarea- onChange={(e) => this.setState({ text: e.currentTarget.value })}+ onChange={e => this.setState({ text: e.currentTarget.value })}defaultValue={this.state.text}placeholder="Why are you deleting this idea? (optional)"/></div>- <span className="info">This operation <strong>cannot</strong> be undone.</span>+ <span className="info">+ This operation <strong>cannot</strong> be undone.+ </span></Form></Modal.Content>@@ -63,9 +69,7 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moder<Button color="red" onClick={async () => this.delete()}>Delete</Button>- <Button onClick={async () => this.close()}>- Cancel- </Button>+ <Button onClick={async () => this.close()}>Cancel</Button></Modal.Footer></Modal.Window>);@@ -73,12 +77,15 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moderreturn (<div>{modal}- <span className="subtitle">- Moderation- </span>+ <span className="subtitle">Moderation</span><div className="ui list"><div className="item">- <Button color="red" size="tiny" fluid={true} onClick={async () => this.setState({ showConfirmation: true })}>+ <Button+ color="red"+ size="tiny"+ fluid={true}+ onClick={async () => this.setState({ showConfirmation: true })}+ ><i className="delete icon" /> Delete</Button></div>diff --git a/public/pages/ShowIdea/components/NotificationsPanel.tsx b/public/pages/ShowIdea/components/NotificationsPanel.tsxindex c77447830..0891c0317 100644--- a/public/pages/ShowIdea/components/NotificationsPanel.tsx+++ b/public/pages/ShowIdea/components/NotificationsPanel.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { CurrentUser, Idea } from '@fider/models';-import { Button } from '@fider/components/common';-import { actions } from '@fider/services';+import * as React from "react";+import { CurrentUser, Idea } from "@fider/models";+import { Button } from "@fider/components/common";+import { actions } from "@fider/services";interface NotificationsPanelProps {user: CurrentUser | undefined;@@ -24,32 +24,32 @@ export class NotificationsPanel extends React.Component<NotificationsPanelProps,const response = await action(this.props.idea.number);if (response.ok) {- this.setState((state) => ({- subscribed : !state.subscribed+ this.setState(state => ({+ subscribed: !state.subscribed}));}- }+ };public render() {if (!this.props.user) {return null;}- const button = this.state.subscribed- ? (+ const button = this.state.subscribed ? (<Button size="small" fluid={true} onClick={this.subscribeOrUnsubscribe}><i className="volume off icon" /> Unsubscribe</Button>- )- : (+ ) : (<Button size="small" fluid={true} onClick={this.subscribeOrUnsubscribe}><i className="volume up icon" /> Subscribe</Button>);- const text = this.state.subscribed- ? <span className="info">You’re receiving notifications about activity on this idea.</span>- : <span className="info">You'll not receive any notification about this idea.</span>;+ const text = this.state.subscribed ? (+ <span className="info">You’re receiving notifications about activity on this idea.</span>+ ) : (+ <span className="info">You'll not receive any notification about this idea.</span>+ );return (<>diff --git a/public/pages/ShowIdea/components/ResponseForm.tsx b/public/pages/ShowIdea/components/ResponseForm.tsxindex 79c0c79e2..13eac38cc 100644--- a/public/pages/ShowIdea/components/ResponseForm.tsx+++ b/public/pages/ShowIdea/components/ResponseForm.tsx@@ -1,10 +1,10 @@-import * as React from 'react';+import * as React from "react";-import { Modal, Button, DisplayError, Textarea } from '@fider/components/common';-import { Comment, Idea, IdeaStatus, User } from '@fider/models';-import { IdeaSearch } from '../';+import { Modal, Button, DisplayError, Textarea } from "@fider/components/common";+import { Comment, Idea, IdeaStatus, User } from "@fider/models";+import { IdeaSearch } from "../";-import { actions, Failure } from '@fider/services';+import { actions, Failure } from "@fider/services";interface ResponseFormProps {idea: Idea;@@ -54,41 +54,48 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor<Modal.Window isOpen={this.state.showModal} center={false} size="large"><Modal.Content><div className="ui form fdr-response-form">- <DisplayError fields={['status']} error={this.state.error} />+ <DisplayError fields={["status"]} error={this.state.error} /><div className="two fields"><div className="field"><label>Status</label><selectclassName="ui dropdown"defaultValue={this.props.idea.status.toString()}- onChange={(e) => this.setState({ status: parseInt(e.currentTarget.value, 10) })}+ onChange={e =>+ this.setState({+ status: parseInt(e.currentTarget.value, 10)+ })+ }>- {IdeaStatus.All.map((s) => <option key={s.value} value={s.value.toString()}>{s.title}</option>)}+ {IdeaStatus.All.map(s => (+ <option key={s.value} value={s.value.toString()}>+ {s.title}+ </option>+ ))}</select></div></div>- {- this.state.status === IdeaStatus.Duplicate.value- ?+ {this.state.status === IdeaStatus.Duplicate.value ? (<>- <DisplayError fields={['originalNumber']} error={this.state.error} />+ <DisplayError fields={["originalNumber"]} error={this.state.error} /><IdeaSearchexclude={[this.props.idea.number]}- onChanged={(originalNumber) => this.setState({ originalNumber })}+ onChanged={originalNumber => this.setState({ originalNumber })}/><span className="info">Votes from this idea will be merged into original idea.</span></>- : <>- <DisplayError fields={['text']} error={this.state.error} />- <div className="field">- <Textarea- onChange={(e) => this.setState({ text: e.currentTarget.value })}- defaultValue={this.state.text}- placeholder="What's going on with this idea? Let your users know what are your plans..."- />- </div>- </>- }+ ) : (+ <>+ <DisplayError fields={["text"]} error={this.state.error} />+ <div className="field">+ <Textarea+ onChange={e => this.setState({ text: e.currentTarget.value })}+ defaultValue={this.state.text}+ placeholder="What's going on with this idea? Let your users know what are your plans..."+ />+ </div>+ </>+ )}</div></Modal.Content>@@ -96,12 +103,10 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor<Button color="green" onClick={() => this.submit()}>Submit</Button>- <Button onClick={async () => this.setState({ showModal: false })}>- Cancel- </Button>+ <Button onClick={async () => this.setState({ showModal: false })}>Cancel</Button></Modal.Footer></Modal.Window>- );+ );return (<>diff --git a/public/pages/ShowIdea/components/TagsPanel.tsx b/public/pages/ShowIdea/components/TagsPanel.tsxindex b4cd9d364..29c123f9b 100644--- a/public/pages/ShowIdea/components/TagsPanel.tsx+++ b/public/pages/ShowIdea/components/TagsPanel.tsx@@ -1,7 +1,7 @@-import * as React from 'react';-import { CurrentUser, Tag, Idea } from '@fider/models';-import { actions } from '@fider/services';-import { ShowTag } from '@fider/components';+import * as React from "react";+import { CurrentUser, Tag, Idea } from "@fider/models";+import { actions } from "@fider/services";+import { ShowTag } from "@fider/components";interface TagsPanelProps {user?: CurrentUser;@@ -16,13 +16,12 @@ interface TagsPanelState {}export class TagsPanel extends React.Component<TagsPanelProps, TagsPanelState> {-constructor(props: TagsPanelProps) {super(props);this.state = {canEdit: !!this.props.user && this.props.user.isCollaborator && this.props.tags.length > 0,isEditing: false,- assignedTags: this.props.tags.filter((t) => this.props.idea.tags.indexOf(t.slug) >= 0),+ assignedTags: this.props.tags.filter(t => this.props.idea.tags.indexOf(t.slug) >= 0)};}@@ -50,42 +49,42 @@ export class TagsPanel extends React.Component<TagsPanelProps, TagsPanelState> {if (this.state.canEdit) {this.setState({ isEditing: !this.state.isEditing });}- }+ };public render() {if (!this.state.canEdit && this.state.assignedTags.length === 0) {return null;}- const tagsList = this.state.assignedTags.length > 0- ? (+ const tagsList =+ this.state.assignedTags.length > 0 ? (<div className="ui list tag-list">- {- this.state.assignedTags.map((tag) => (+ {this.state.assignedTags.map(tag => (<div key={tag.id} className="item"><ShowTag tag={tag} /></div>- ))- }+ ))}</div>- ) : <span className="info">None yet</span>;+ ) : (+ <span className="info">None yet</span>+ );const editTagsList = this.props.tags.length > 0 && (<div className="ui list tag-list">- {- this.props.tags.map((tag) => (+ {this.props.tags.map(tag => (<div key={tag.id} className="item selectable" onClick={async () => this.assignOrUnassignTag(tag)}>- <i className={`icon ${this.state.assignedTags.indexOf(tag) >= 0 && 'check'}`} />- <ShowTag tag={tag} circular={true}/>+ <i className={`icon ${this.state.assignedTags.indexOf(tag) >= 0 && "check"}`} />+ <ShowTag tag={tag} circular={true} /><span>{tag.name}</span></div>- ))- }+ ))}</div>);- const subtitleClasses = `subtitle ${this.state.canEdit && 'active'}`;- const icon = this.state.canEdit && (this.state.isEditing ? <i className="check circle icon" /> : <i className="setting icon" />);+ const subtitleClasses = `subtitle ${this.state.canEdit && "active"}`;+ const icon =+ this.state.canEdit &&+ (this.state.isEditing ? <i className="check circle icon" /> : <i className="setting icon" />);return (<div>diff --git a/public/pages/ShowIdea/index.ts b/public/pages/ShowIdea/index.tsindex 9f4b729af..364df7dbf 100644--- a/public/pages/ShowIdea/index.ts+++ b/public/pages/ShowIdea/index.ts@@ -1,9 +1,9 @@-export * from './ShowIdea.page';-export * from './components/CommentInput';-export * from './components/ResponseForm';-export * from './components/CommentList';-export * from './components/IdeaSearch';-export * from './components/TagsPanel';-export * from './components/ModerationPanel';-export * from './components/NotificationsPanel';-export * from './components/DiscussionPanel';+export * from "./ShowIdea.page";+export * from "./components/CommentInput";+export * from "./components/ResponseForm";+export * from "./components/CommentList";+export * from "./components/IdeaSearch";+export * from "./components/TagsPanel";+export * from "./components/ModerationPanel";+export * from "./components/NotificationsPanel";+export * from "./components/DiscussionPanel";diff --git a/public/pages/SignUp/SignUp.page.tsx b/public/pages/SignUp/SignUp.page.tsxindex 98ca16d2e..1fe79d2b7 100644--- a/public/pages/SignUp/SignUp.page.tsx+++ b/public/pages/SignUp/SignUp.page.tsx@@ -1,11 +1,11 @@-import './SignUp.page.scss';+import "./SignUp.page.scss";-import * as React from 'react';-import { SignInControl, Modal, Button, DisplayError } from '@fider/components/common';-import { SystemSettings } from '@fider/models';-import { jwt, page, actions, Failure } from '@fider/services';+import * as React from "react";+import { SignInControl, Modal, Button, DisplayError } from "@fider/components/common";+import { SystemSettings } from "@fider/models";+import { jwt, page, actions, Failure } from "@fider/services";-const logo = require('@fider/assets/images/logo-small.png');+const logo = require("@fider/assets/images/logo-small.png");interface OAuthUser {token: string;@@ -18,174 +18,183 @@ interface SignUpPageProps {}interface SignUpPageState {- submitted: boolean;- tenantName: string;- error?: Failure;- name?: string;- email?: string;- subdomain: {- available: boolean,- message?: string,- value?: string- };+ submitted: boolean;+ tenantName: string;+ error?: Failure;+ name?: string;+ email?: string;+ subdomain: {+ available: boolean;+ message?: string;+ value?: string;+ };}export class SignUpPage extends React.Component<SignUpPageProps, SignUpPageState> {- private user?: OAuthUser;-- constructor(props: SignUpPageProps) {- super(props);- this.state = {- submitted: false,- tenantName: '',- subdomain: { available: false }- };-- page.setTitle(page.isSingleHostMode() ? 'Installation · Fider' : 'Sign up · Fider');-- const token = page.getQueryString('token');- if (token) {- const data = jwt.decode(token);- if (data) {- this.user = {- token,- name: data['oauth/name'],- email: data['oauth/email']- };- }+ private user?: OAuthUser;++ constructor(props: SignUpPageProps) {+ super(props);+ this.state = {+ submitted: false,+ tenantName: "",+ subdomain: { available: false }+ };++ page.setTitle(page.isSingleHostMode() ? "Installation · Fider" : "Sign up · Fider");++ const token = page.getQueryString("token");+ if (token) {+ const data = jwt.decode(token);+ if (data) {+ this.user = {+ token,+ name: data["oauth/name"],+ email: data["oauth/email"]+ };}}-- private async confirm() {- const result = await actions.createTenant({- token: this.user && this.user.token,- tenantName: this.state.tenantName,- subdomain: this.state.subdomain.value,- name: this.state.name,- email: this.state.email,- });-- if (result.ok) {- if (result.data.token) {- if (page.isSingleHostMode()) {- location.reload();- } else {- let baseUrl = `${location.protocol}//${this.state.subdomain.value}${this.props.system.domain}`;- if (location.port) {- baseUrl = `${baseUrl}:${location.port}`;- }-- location.href = `${baseUrl}?token=${result.data.token}`;- }+ }++ private async confirm() {+ const result = await actions.createTenant({+ token: this.user && this.user.token,+ tenantName: this.state.tenantName,+ subdomain: this.state.subdomain.value,+ name: this.state.name,+ email: this.state.email+ });++ if (result.ok) {+ if (result.data.token) {+ if (page.isSingleHostMode()) {+ location.reload();} else {- this.setState({ submitted: true });+ let baseUrl = `${location.protocol}//${this.state.subdomain.value}${this.props.system.domain}`;+ if (location.port) {+ baseUrl = `${baseUrl}:${location.port}`;+ }++ location.href = `${baseUrl}?token=${result.data.token}`;}- } else if (result.error) {- this.setState({ error: result.error, submitted: false });+ } else {+ this.setState({ submitted: true });}+ } else if (result.error) {+ this.setState({ error: result.error, submitted: false });}+ }- private async checkAvailability(subdomain: string) {- const result = await actions.checkAvailability(subdomain);-- this.setState({- subdomain: {- value: subdomain,- available: !result.data.message,- message: result.data.message,- }- });- }+ private async checkAvailability(subdomain: string) {+ const result = await actions.checkAvailability(subdomain);- public render() {- const modal = (- <Modal.Window canClose={false} isOpen={this.state.submitted}>- <Modal.Header>Thank you for registering!</Modal.Header>- <Modal.Content>- <p>We have just sent a confirmation link to <b>{this.state.email}</b>. <br /> Click the link to finish your registration.</p>- </Modal.Content>- </Modal.Window>- );-- return (- <div className="page ui container">- {modal}- <img className="logo" src={logo} />-- <h3 className="ui header">1. Who are you?</h3>- <DisplayError fields={['token']} error={this.state.error} />-- {- this.user ?- <p>- Hello, - <b>{this.user.name}</b> {this.user.email && `(${this.user.email})`}- </p> :- <>- <p>We need to identify you to setup your new Fider account.</p>- <SignInControl useEmail={false} />- <div className="ui form">- <DisplayError fields={['name', 'email']} error={this.state.error} />- <div className="fluid field">- <input id="name" onChange={(e) => this.setState({ name: e.currentTarget.value })} type="text" placeholder="your name" className="small" />- </div>- <div className="fluid field">- <input id="email" onChange={(e) => this.setState({ email: e.currentTarget.value })} type="text" placeholder="[email protected]" className="small" />- </div>+ this.setState({+ subdomain: {+ value: subdomain,+ available: !result.data.message,+ message: result.data.message+ }+ });+ }++ public render() {+ const modal = (+ <Modal.Window canClose={false} isOpen={this.state.submitted}>+ <Modal.Header>Thank you for registering!</Modal.Header>+ <Modal.Content>+ <p>+ We have just sent a confirmation link to <b>{this.state.email}</b>. <br /> Click the link to finish your+ registration.+ </p>+ </Modal.Content>+ </Modal.Window>+ );++ return (+ <div className="page ui container">+ {modal}+ <img className="logo" src={logo} />++ <h3 className="ui header">1. Who are you?</h3>+ <DisplayError fields={["token"]} error={this.state.error} />++ {this.user ? (+ <p>+ Hello, + <b>{this.user.name}</b> {this.user.email && `(${this.user.email})`}+ </p>+ ) : (+ <>+ <p>We need to identify you to setup your new Fider account.</p>+ <SignInControl useEmail={false} />+ <div className="ui form">+ <DisplayError fields={["name", "email"]} error={this.state.error} />+ <div className="fluid field">+ <input+ id="name"+ onChange={e => this.setState({ name: e.currentTarget.value })}+ type="text"+ placeholder="your name"+ className="small"+ /></div>- </>- }-- <div className="ui section divider" />-- <h3 className="ui header">2. What is this Feedback Forum for?</h3>-- <DisplayError fields={['tenantName', 'subdomain']} error={this.state.error} />- <div className="ui form">- <div className="fluid field">- <input- id="tenantName"- type="text"- placeholder="your company or product name"- maxLength={60}- onChange={(e) => this.setState({ tenantName: e.currentTarget.value })}- />- </div>- {- !page.isSingleHostMode() && <div className="fluid field">- <div className="ui right labeled input">- <input- id="subdomain"- type="text"- maxLength={40}- placeholder="subdomain"- onChange={(e) => this.checkAvailability(e.currentTarget.value)}- />- <div className="ui label">{this.props.system.domain}</div>- {- this.state.subdomain.available &&- <div className="ui left pointing green basic label">- Great!- </div>- }- {- this.state.subdomain.message &&- <div className="ui left pointing red basic label">- {this.state.subdomain.message}- </div>- }- </div>+ <div className="fluid field">+ <input+ id="email"+ onChange={e => this.setState({ email: e.currentTarget.value })}+ type="text"+ placeholder="[email protected]"+ className="small"+ /></div>- }+ </div>+ </>+ )}++ <div className="ui section divider" />++ <h3 className="ui header">2. What is this Feedback Forum for?</h3>++ <DisplayError fields={["tenantName", "subdomain"]} error={this.state.error} />+ <div className="ui form">+ <div className="fluid field">+ <input+ id="tenantName"+ type="text"+ placeholder="your company or product name"+ maxLength={60}+ onChange={e => this.setState({ tenantName: e.currentTarget.value })}+ /></div>- <div className="ui section divider" />+ {!page.isSingleHostMode() && (+ <div className="fluid field">+ <div className="ui right labeled input">+ <input+ id="subdomain"+ type="text"+ maxLength={40}+ placeholder="subdomain"+ onChange={e => this.checkAvailability(e.currentTarget.value)}+ />+ <div className="ui label">{this.props.system.domain}</div>+ {this.state.subdomain.available && <div className="ui left pointing green basic label">Great!</div>}+ {this.state.subdomain.message && (+ <div className="ui left pointing red basic label">{this.state.subdomain.message}</div>+ )}+ </div>+ </div>+ )}+ </div>+ <div className="ui section divider" />- <h3 className="ui header">3. Review and continue</h3>+ <h3 className="ui header">3. Review and continue</h3>- <p>Make sure information provided above is correct before proceeding.</p>+ <p>Make sure information provided above is correct before proceeding.</p>- <Button color="green" size="large" onClick={() => this.confirm()}>Confirm</Button>- </div>- );- }+ <Button color="green" size="large" onClick={() => this.confirm()}>+ Confirm+ </Button>+ </div>+ );+ }}diff --git a/public/pages/SignUp/index.ts b/public/pages/SignUp/index.tsindex dd5e3bcdd..1dd5ac86b 100644--- a/public/pages/SignUp/index.ts+++ b/public/pages/SignUp/index.ts@@ -1 +1 @@-export * from './SignUp.page';+export * from "./SignUp.page";diff --git a/public/pages/index.ts b/public/pages/index.tsindex fc1025716..f35ae87ac 100644--- a/public/pages/index.ts+++ b/public/pages/index.ts@@ -1,9 +1,9 @@-export * from './Home';-export * from './AdminHome';-export * from './SignUp';-export * from './ManageMembers';-export * from './ManageTags';-export * from './CompleteSignInProfile';-export * from './MySettings';-export * from './MyNotifications';-export * from './ShowIdea';+export * from "./Home";+export * from "./AdminHome";+export * from "./SignUp";+export * from "./ManageMembers";+export * from "./ManageTags";+export * from "./CompleteSignInProfile";+export * from "./MySettings";+export * from "./MyNotifications";+export * from "./ShowIdea";diff --git a/public/router.tsx b/public/router.tsxindex fb784664e..966c2d299 100644--- a/public/router.tsx+++ b/public/router.tsx@@ -1,4 +1,4 @@-import * as React from 'react';+import * as React from "react";import {HomePage,@@ -9,8 +9,8 @@ import {ManageTagsPage,ShowIdeaPage,MySettingsPage,- MyNotificationsPage,-} from '@fider/pages';+ MyNotificationsPage+} from "@fider/pages";interface PageConfiguration {id: string;@@ -20,28 +20,29 @@ interface PageConfiguration {}const route = (path: string, component: any, id: string, showHeader: boolean): PageConfiguration => {- path = path.replace('/', '\/')- .replace(':number', '\\d+')- .replace('*', '\/?.*');+ path = path+ .replace("/", "/")+ .replace(":number", "\\d+")+ .replace("*", "/?.*");const regex = new RegExp(`^${path}$`);return { regex, component, id, showHeader };};const pathRegex = [- route('', HomePage, 'p-home', true),- route('/ideas/:number*', ShowIdeaPage, 'p-show-idea', true),- route('/admin/members', ManageMembersPage, 'p-manage-members', true),- route('/admin/tags', ManageTagsPage, 'p-manage-tags', true),- route('/admin', AdminHomePage, 'p-admin-home', true),- route('/signup', SignUpPage, 'p-signup', false),- route('/signin/verify', CompleteSignInProfilePage, 'p-complete-signin-profile', true),- route('/notifications', MyNotificationsPage, 'p-my-notifications', true),- route('/settings', MySettingsPage, 'p-my-settings', true),+ route("", HomePage, "p-home", true),+ route("/ideas/:number*", ShowIdeaPage, "p-show-idea", true),+ route("/admin/members", ManageMembersPage, "p-manage-members", true),+ route("/admin/tags", ManageTagsPage, "p-manage-tags", true),+ route("/admin", AdminHomePage, "p-admin-home", true),+ route("/signup", SignUpPage, "p-signup", false),+ route("/signin/verify", CompleteSignInProfilePage, "p-complete-signin-profile", true),+ route("/notifications", MyNotificationsPage, "p-my-notifications", true),+ route("/settings", MySettingsPage, "p-my-settings", true)];export const resolveRootComponent = (path: string): PageConfiguration => {- if (path.length > 0 && path.charAt(path.length - 1) === '/') {+ if (path.length > 0 && path.charAt(path.length - 1) === "/") {path = path.substring(0, path.length - 1);}for (const entry of pathRegex) {diff --git a/public/services/actions/idea.ts b/public/services/actions/idea.tsindex 812a4ae3c..f4e86ea8b 100644--- a/public/services/actions/idea.ts+++ b/public/services/actions/idea.ts@@ -1,42 +1,44 @@-import { http, Result } from '@fider/services';-import { Idea } from '@fider/models';+import { http, Result } from "@fider/services";+import { Idea } from "@fider/models";export const getAllIdeas = async (): Promise<Result<Idea[]>> => {- return await http.get<Idea[]>('/api/ideas/search');+ return await http.get<Idea[]>("/api/ideas/search");};export const searchIdeas = async (query: string, filter: string, tags: string[]): Promise<Result<Idea[]>> => {- return await http.get<Idea[]>(`/api/ideas/search?q=${query}&f=${filter}&t=${tags.join(',')}`);+ return await http.get<Idea[]>(`/api/ideas/search?q=${query}&f=${filter}&t=${tags.join(",")}`);};export const deleteIdea = async (ideaNumber: number, text: string): Promise<Result> => {- return http.delete(`/api/ideas/${ideaNumber}`, {- text- }).then(http.event('idea', 'delete'));+ return http+ .delete(`/api/ideas/${ideaNumber}`, {+ text+ })+ .then(http.event("idea", "delete"));};export const addSupport = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/support`).then(http.event('idea', 'support'));+ return http.post(`/api/ideas/${ideaNumber}/support`).then(http.event("idea", "support"));};export const removeSupport = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/unsupport`).then(http.event('idea', 'unsupport'));+ return http.post(`/api/ideas/${ideaNumber}/unsupport`).then(http.event("idea", "unsupport"));};export const subscribe = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/subscribe`).then(http.event('idea', 'subscribe'));+ return http.post(`/api/ideas/${ideaNumber}/subscribe`).then(http.event("idea", "subscribe"));};export const unsubscribe = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/unsubscribe`).then(http.event('idea', 'unsubscribe'));+ return http.post(`/api/ideas/${ideaNumber}/unsubscribe`).then(http.event("idea", "unsubscribe"));};export const createComment = async (ideaNumber: number, content: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/comments`, { content }).then(http.event('comment', 'create'));+ return http.post(`/api/ideas/${ideaNumber}/comments`, { content }).then(http.event("comment", "create"));};export const updateComment = async (ideaNumber: number, commentId: number, content: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/comments/${commentId}`, { content }).then(http.event('comment', 'update'));+ return http.post(`/api/ideas/${ideaNumber}/comments/${commentId}`, { content }).then(http.event("comment", "update"));};interface SetResponseInput {@@ -46,17 +48,19 @@ interface SetResponseInput {}export const respond = async (ideaNumber: number, input: SetResponseInput): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/status`, {- status: input.status,- text: input.text,- originalNumber: input.originalNumber,- }).then(http.event('idea', 'respond'));+ return http+ .post(`/api/ideas/${ideaNumber}/status`, {+ status: input.status,+ text: input.text,+ originalNumber: input.originalNumber+ })+ .then(http.event("idea", "respond"));};export const createIdea = async (title: string, description: string): Promise<Result<Idea>> => {- return http.post<Idea>(`/api/ideas`, { title, description }).then(http.event('idea', 'create'));+ return http.post<Idea>(`/api/ideas`, { title, description }).then(http.event("idea", "create"));};export const updateIdea = async (ideaNumber: number, title: string, description: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}`, { title, description }).then(http.event('idea', 'update'));+ return http.post(`/api/ideas/${ideaNumber}`, { title, description }).then(http.event("idea", "update"));};diff --git a/public/services/actions/index.ts b/public/services/actions/index.tsindex 030346fe5..850ba750f 100644--- a/public/services/actions/index.ts+++ b/public/services/actions/index.ts@@ -1,6 +1,6 @@-export * from './user';-export * from './tag';-export * from './idea';-export * from './tenant';-export * from './notification';-export { Failure } from '@fider/services/http';+export * from "./user";+export * from "./tag";+export * from "./idea";+export * from "./tenant";+export * from "./notification";+export { Failure } from "@fider/services/http";diff --git a/public/services/actions/notification.ts b/public/services/actions/notification.tsindex d6171b5e7..c0fd68809 100644--- a/public/services/actions/notification.ts+++ b/public/services/actions/notification.ts@@ -1,15 +1,15 @@-import { http, Result } from '@fider/services';+import { http, Result } from "@fider/services";export const getTotalUnreadNotifications = async (): Promise<Result<number>> => {- return http.get<{ total: number}>('/api/notifications/unread/total').then((result) => {+ return http.get<{ total: number }>("/api/notifications/unread/total").then(result => {return {ok: result.ok,error: result.error,- data: result.data ? result.data.total : 0,+ data: result.data ? result.data.total : 0};});};export const markAllAsRead = async (): Promise<Result> => {- return await http.post('/api/notifications/read-all');+ return await http.post("/api/notifications/read-all");};diff --git a/public/services/actions/tag.ts b/public/services/actions/tag.tsindex 29a85650e..e9e5bb6b2 100644--- a/public/services/actions/tag.ts+++ b/public/services/actions/tag.ts@@ -1,22 +1,22 @@-import { http, Result } from '@fider/services/http';-import { Tag } from '@fider/models';+import { http, Result } from "@fider/services/http";+import { Tag } from "@fider/models";export const createTag = async (name: string, color: string, isPublic: boolean): Promise<Result<Tag>> => {- return http.post<Tag>(`/api/admin/tags`, { name, color, isPublic }).then(http.event('tag', 'create'));+ return http.post<Tag>(`/api/admin/tags`, { name, color, isPublic }).then(http.event("tag", "create"));};export const updateTag = async (slug: string, name: string, color: string, isPublic: boolean): Promise<Result<Tag>> => {- return http.post<Tag>(`/api/admin/tags/${slug}`, { name, color, isPublic }).then(http.event('tag', 'update'));+ return http.post<Tag>(`/api/admin/tags/${slug}`, { name, color, isPublic }).then(http.event("tag", "update"));};export const deleteTag = async (slug: string): Promise<Result> => {- return http.delete(`/api/admin/tags/${slug}`).then(http.event('tag', 'delete'));+ return http.delete(`/api/admin/tags/${slug}`).then(http.event("tag", "delete"));};export const assignTag = async (slug: string, ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/tags/${slug}`).then(http.event('tag', 'assign'));+ return http.post(`/api/ideas/${ideaNumber}/tags/${slug}`).then(http.event("tag", "assign"));};export const unassignTag = async (slug: string, ideaNumber: number): Promise<Result> => {- return http.delete(`/api/ideas/${ideaNumber}/tags/${slug}`).then(http.event('tag', 'unassign'));+ return http.delete(`/api/ideas/${ideaNumber}/tags/${slug}`).then(http.event("tag", "unassign"));};diff --git a/public/services/actions/tenant.ts b/public/services/actions/tenant.tsindex 1750176a2..09b36f599 100644--- a/public/services/actions/tenant.ts+++ b/public/services/actions/tenant.ts@@ -1,5 +1,5 @@-import { http, Result } from '@fider/services/http';-import { Tenant, UserRole } from '@fider/models';+import { http, Result } from "@fider/services/http";+import { Tenant, UserRole } from "@fider/models";export interface CheckAvailabilityResponse {message: string;@@ -18,12 +18,20 @@ export interface CreateTenantResponse {}export const createTenant = async (request: CreateTenantRequest): Promise<Result<CreateTenantResponse>> => {- return await http.post<CreateTenantResponse>('/api/tenants', request);+ return await http.post<CreateTenantResponse>("/api/tenants", request);};-export const updateTenantSettings = async (title: string, invitation: string, welcomeMessage: string, cname: string): Promise<Result> => {- return await http.post('/api/admin/settings', {- title, invitation, welcomeMessage, cname+export const updateTenantSettings = async (+ title: string,+ invitation: string,+ welcomeMessage: string,+ cname: string+): Promise<Result> => {+ return await http.post("/api/admin/settings", {+ title,+ invitation,+ welcomeMessage,+ cname});};@@ -32,20 +40,20 @@ export const checkAvailability = async (subdomain: string): Promise<Result<Check};export const signIn = async (email: string): Promise<Result> => {- return await http.post('/api/signin', {- email,+ return await http.post("/api/signin", {});};export const completeProfile = async (key: string, name: string): Promise<Result> => {- return await http.post('/api/signin/complete', {+ return await http.post("/api/signin/complete", {key,- name,+ name});};export const changeUserRole = async (userId: number, role: UserRole): Promise<Result> => {return await http.post(`/api/admin/users/${userId}/role`, {- role,+ role});};diff --git a/public/services/actions/user.ts b/public/services/actions/user.tsindex a3adb9af8..6847e4971 100644--- a/public/services/actions/user.ts+++ b/public/services/actions/user.ts@@ -1,15 +1,15 @@-import { http, Result } from '@fider/services/http';-import { UserSettings } from '@fider/models';+import { http, Result } from "@fider/services/http";+import { UserSettings } from "@fider/models";export const updateUserSettings = async (name: string, settings: UserSettings): Promise<Result> => {- return await http.post('/api/user/settings', {+ return await http.post("/api/user/settings", {name,- settings,+ settings});};export const changeUserEmail = async (email: string): Promise<Result> => {- return await http.post('/api/user/change-email', {- email,+ return await http.post("/api/user/change-email", {});};diff --git a/public/services/analytics.ts b/public/services/analytics.tsindex c7a023aa5..ac2b82c16 100644--- a/public/services/analytics.ts+++ b/public/services/analytics.ts@@ -1,7 +1,7 @@export const analytics = {event: (eventCategory: string, eventAction: string): void => {if (window.ga) {- window.ga('send', 'event', {+ window.ga("send", "event", {eventCategory,eventAction});@@ -9,7 +9,7 @@ export const analytics = {},error: (err: Error): void => {if (window.ga) {- window.ga('send', 'exception', {+ window.ga("send", "exception", {exDescription: err.stack,exFatal: false});diff --git a/public/services/device.ts b/public/services/device.tsindex 8b5e6fba2..4d312bd49 100644--- a/public/services/device.ts+++ b/public/services/device.ts@@ -1,3 +1,3 @@export const isTouch = (): boolean => {- return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;+ return "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;};diff --git a/public/services/http.ts b/public/services/http.tsindex 5f38acd65..1e15b1501 100644--- a/public/services/http.ts+++ b/public/services/http.ts@@ -1,9 +1,9 @@-import { analytics } from '@fider/services';+import { analytics } from "@fider/services";export interface Failure {messages: string[];failures: {- [key: string]: string[]+ [key: string]: string[];};}@@ -18,7 +18,7 @@ async function toResult<T>(response: Response): Promise<Result<T>> {if (response.status < 400) {return {ok: true,- data: body as T,+ data: body as T};} else {return {@@ -26,29 +26,31 @@ async function toResult<T>(response: Response): Promise<Result<T>> {data: body as T,error: {messages: body.messages,- failures: body.failures,+ failures: body.failures}};}}-async function request<T>(url: string, method: 'GET' | 'POST' | 'DELETE', body?: any): Promise<Result<T>> {- const headers = [- [ 'Accept', 'application/json' ],- [ 'Content-Type', 'application/json' ]- ];- const response = await fetch(url, { method, headers, body: JSON.stringify(body), credentials: 'same-origin' });+async function request<T>(url: string, method: "GET" | "POST" | "DELETE", body?: any): Promise<Result<T>> {+ const headers = [["Accept", "application/json"], ["Content-Type", "application/json"]];+ const response = await fetch(url, {+ method,+ headers,+ body: JSON.stringify(body),+ credentials: "same-origin"+ });return await toResult<T>(response);}export const http = {get: async <T = void>(url: string): Promise<Result<T>> => {- return await request<T>(url, 'GET');+ return await request<T>(url, "GET");},post: async <T = void>(url: string, body?: any): Promise<Result<T>> => {- return await request<T>(url, 'POST', body);+ return await request<T>(url, "POST", body);},delete: async <T = void>(url: string, body?: any): Promise<Result<T>> => {- return await request<T>(url, 'DELETE', body);+ return await request<T>(url, "DELETE", body);},event: (category: string, action: string) => <T>(result: Result<T>): Result<T> => {if (result && result.ok) {diff --git a/public/services/index.ts b/public/services/index.tsindex 39dfa1522..4fa482b0e 100644--- a/public/services/index.ts+++ b/public/services/index.ts@@ -1,9 +1,9 @@-export * from './http';-export * from './cache';-export * from './analytics';-export * from './jwt';-export * from './utils';-import * as device from './device';-import * as page from './page';-import * as actions from './actions';+export * from "./http";+export * from "./cache";+export * from "./analytics";+export * from "./jwt";+export * from "./utils";+import * as device from "./device";+import * as page from "./page";+import * as actions from "./actions";export { actions, page, device };diff --git a/public/services/jwt.ts b/public/services/jwt.tsindex 897382e63..d80b86851 100644--- a/public/services/jwt.ts+++ b/public/services/jwt.ts@@ -1,7 +1,7 @@export const jwt = {decode: (token: string): any => {if (token) {- const segments = token.split('.');+ const segments = token.split(".");try {return JSON.parse(window.atob(segments[1]));} catch {diff --git a/public/services/page.ts b/public/services/page.tsindex 3ddd4d10c..263a564d1 100644--- a/public/services/page.ts+++ b/public/services/page.ts@@ -1,7 +1,7 @@-import { AuthSettings} from '@fider/models';+import { AuthSettings } from "@fider/models";export const goHome = (): void => {- document.location.href = '/';+ document.location.href = "/";};export const refresh = (): void => {@@ -17,7 +17,7 @@ export const getBaseUrl = (): string => {};export const isSingleHostMode = (): boolean => {- return (window as any).props.system.mode === 'single';+ return (window as any).props.system.mode === "single";};export const authSettings = (): AuthSettings => {@@ -30,21 +30,21 @@ export interface ModalOptions {export const getQueryString = (name: string): string => {const url = window.location.href;- name = name.replace(/[\[\]]/g, '\\$&');- const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');+ name = name.replace(/[\[\]]/g, "\\$&");+ const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");const results = regex.exec(url);if (!results || !results[2]) {- return '';+ return "";}- return decodeURIComponent(results[2].replace(/\+/g, ' '));+ return decodeURIComponent(results[2].replace(/\+/g, " "));};export const getQueryStringArray = (name: string): string[] => {const qs = getQueryString(name);if (qs) {- return qs.split(',').filter((i) => i);+ return qs.split(",").filter(i => i);}return [];@@ -56,20 +56,20 @@ export interface QueryString {export const toQueryString = (object: QueryString): string => {if (!object) {- return '';+ return "";}- let qs = '';+ let qs = "";for (const key of Object.keys(object)) {- const symbol = qs ? '&' : '?';+ const symbol = qs ? "&" : "?";const value = object[key];if (value instanceof Array) {if (value.length > 0) {- qs += `${symbol}${key}=${value.join(',')}`;+ qs += `${symbol}${key}=${value.join(",")}`;}} else if (value) {- qs += `${symbol}${key}=${encodeURIComponent(value).replace(/%20/g, '+')}`;+ qs += `${symbol}${key}=${encodeURIComponent(value).replace(/%20/g, "+")}`;}}@@ -79,6 +79,6 @@ export const toQueryString = (object: QueryString): string => {export const replaceState = (path: string): void => {if (history.replaceState) {const newUrl = getBaseUrl() + path;- window.history.replaceState({ path: newUrl }, '', newUrl);+ window.history.replaceState({ path: newUrl }, "", newUrl);}};diff --git a/public/services/utils.ts b/public/services/utils.tsindex 26c7a9b88..82fb9c1e8 100644--- a/public/services/utils.ts+++ b/public/services/utils.ts@@ -1,9 +1,9 @@export const delay = (ms: number) => {- return new Promise((resolve) => setTimeout(resolve, ms));+ return new Promise(resolve => setTimeout(resolve, ms));};export const classSet = (input?: any): string => {- let classes = '';+ let classes = "";if (input) {for (const key in input) {if (key && !!input[key]) {@@ -12,14 +12,22 @@ export const classSet = (input?: any): string => {}return classes.trim();}- return '';+ return "";};const monthNames = [- 'January', 'February', 'March',- 'April', 'May', 'June', 'July',- 'August', 'September', 'October',- 'November', 'December'+ "January",+ "February",+ "March",+ "April",+ "May",+ "June",+ "July",+ "August",+ "September",+ "October",+ "November",+ "December"];const twoDigits = (value: number): string => {@@ -39,17 +47,17 @@ export const formatDate = (input: Date | string): string => {};const templates: { [key: string]: string } = {- seconds: 'less than a minute',- minute: 'about a minute',- minutes: '%d minutes',- hour: 'about an hour',- hours: 'about %d hours',- day: 'a day',- days: '%d days',- month: 'about a month',- months: '%d months',- year: 'about a year',- years: '%d years'+ seconds: "less than a minute",+ minute: "about a minute",+ minutes: "%d minutes",+ hour: "about an hour",+ hours: "about %d hours",+ day: "a day",+ days: "%d days",+ month: "about a month",+ months: "%d months",+ year: "about a year",+ years: "%d years"};const template = (t: string, n: number): string => {@@ -57,7 +65,6 @@ const template = (t: string, n: number): string => {};export const timeSince = (now: Date, date: Date): string => {-const seconds = (now.getTime() - date.getTime()) / 1000;const minutes = seconds / 60;const hours = minutes / 60;@@ -65,16 +72,16 @@ export const timeSince = (now: Date, date: Date): string => {const years = days / 365;return (- seconds < 45 && template('seconds', seconds) ||- seconds < 90 && template('minute', 1) ||- minutes < 45 && template('minutes', minutes) ||- minutes < 90 && template('hour', 1) ||- hours < 24 && template('hours', hours) ||- hours < 42 && template('day', 1) ||- days < 30 && template('days', days) ||- days < 45 && template('month', 1) ||- days < 365 && template('months', days / 30) ||- years < 1.5 && template('year', 1) ||- template('years', years)- ) + ' ago';+ ((seconds < 45 && template("seconds", seconds)) ||+ (seconds < 90 && template("minute", 1)) ||+ (minutes < 45 && template("minutes", minutes)) ||+ (minutes < 90 && template("hour", 1)) ||+ (hours < 24 && template("hours", hours)) ||+ (hours < 42 && template("day", 1)) ||+ (days < 30 && template("days", days)) ||+ (days < 45 && template("month", 1)) ||+ (days < 365 && template("months", days / 30)) ||+ (years < 1.5 && template("year", 1)) ||+ template("years", years)) + " ago"+ );};diff --git a/tslint.json b/tslint.jsonindex 7c607c4b7..94cd15a58 100644--- a/tslint.json+++ b/tslint.json@@ -1,34 +1,15 @@{- "extends": [ "tslint:recommended", "tslint-react"],- "rules": {- "object-literal-sort-keys": false,- "trailing-comma": [- false- ],- "no-bitwise": false,- "indent": [- true, "spaces", 2- ],- "interface-name": [- false- ],- "ordered-imports": [- false- ],- "no-var-requires": false,- "member-ordering": [- false- ],- "quotemark": [- true, "single", "jsx-double"- ],- "max-line-length": [- false- ],- "max-classes-per-file": [- false- ],- "jsx-no-lambda": false,- "jsx-no-multiline-js": false- }-}\ No newline at end of file+ "extends": ["tslint:recommended", "tslint-react", "tslint-plugin-prettier", "tslint-config-prettier"],+ "rules": {+ "interface-name": [false],+ "jsx-no-lambda": false,+ "jsx-no-multiline-js": false,+ "max-classes-per-file": [false],+ "member-ordering": [false],+ "no-bitwise": false,+ "no-var-requires": false,+ "object-literal-sort-keys": false,+ "ordered-imports": [false],+ "prettier": [true]+ }+}