Open platform to collect and prioritize feedback
refactor: migrate OAuthForm and UIToolkit to React Hooks (#738)
Guilherme Oenningf01211b9ff9c
diff --git a/public/components/common/Toggle.tsx b/public/components/common/Toggle.tsxindex c2eb99bb0..5ef76f047 100644--- a/public/components/common/Toggle.tsx+++ b/public/components/common/Toggle.tsx@@ -7,7 +7,7 @@ interface ToggleProps {label?: string;active: boolean;disabled?: boolean;- onToggle?: (active: boolean) => Promise<any>;+ onToggle?: (active: boolean) => void;}interface ToggleState {diff --git a/public/pages/Administration/components/OAuthForm.tsx b/public/pages/Administration/components/OAuthForm.tsxindex e268e0c92..2be4d89c9 100644--- a/public/pages/Administration/components/OAuthForm.tsx+++ b/public/pages/Administration/components/OAuthForm.tsx@@ -1,300 +1,238 @@-import React from "react";+import React, { useState } from "react";import { OAuthConfig, OAuthConfigStatus, ImageUpload } from "@fider/models";-import { Failure, Fider, actions } from "@fider/services";+import { Failure, actions } from "@fider/services";import { Form, Button, Input, Heading, SocialSignInButton, Field, ImageUploader, Toggle } from "@fider/components";+import { useFider } from "@fider/hooks";interface OAuthFormProps {config?: OAuthConfig;onCancel: () => void;}-export interface OAuthFormState {- provider: string;- displayName: string;- enabled: boolean;- clientID: string;- clientSecret: string;- clientSecretEnabled: boolean;- authorizeURL: string;- tokenURL: string;- profileURL: string;- scope: string;- jsonUserIDPath: string;- jsonUserNamePath: string;- jsonUserEmailPath: string;- logoBlobKey?: string;- logo?: ImageUpload;- logoURL?: string;- error?: Failure;-}--export class OAuthForm extends React.Component<OAuthFormProps, OAuthFormState> {- constructor(props: OAuthFormProps) {- super(props);- this.state = {- provider: this.props.config ? this.props.config.provider : "",- enabled: this.props.config ? this.props.config.status === OAuthConfigStatus.Enabled : false,- displayName: this.props.config ? this.props.config.displayName : "",- clientID: this.props.config ? this.props.config.clientID : "",- clientSecret: this.props.config ? this.props.config.clientSecret : "",- clientSecretEnabled: !this.props.config,- authorizeURL: this.props.config ? this.props.config.authorizeURL : "",- tokenURL: this.props.config ? this.props.config.tokenURL : "",- profileURL: this.props.config ? this.props.config.profileURL : "",- scope: this.props.config ? this.props.config.scope : "",- jsonUserIDPath: this.props.config ? this.props.config.jsonUserIDPath : "",- jsonUserNamePath: this.props.config ? this.props.config.jsonUserNamePath : "",- jsonUserEmailPath: this.props.config ? this.props.config.jsonUserEmailPath : "",- logoBlobKey: this.props.config ? this.props.config.logoBlobKey : ""- };- }+export const OAuthForm: React.FC<OAuthFormProps> = props => {+ const fider = useFider();+ const [provider] = useState((props.config && props.config.provider) || "");+ const [displayName, setDisplayName] = useState((props.config && props.config.displayName) || "");+ const [enabled, setEnabled] = useState((props.config && props.config.status === OAuthConfigStatus.Enabled) || false);+ const [clientID, setClientID] = useState((props.config && props.config.clientID) || "");+ const [clientSecret, setClientSecret] = useState((props.config && props.config.clientSecret) || "");+ const [clientSecretEnabled, setClientSecretEnabled] = useState(!props.config);+ const [authorizeURL, setAuthorizeURL] = useState((props.config && props.config.authorizeURL) || "");+ const [tokenURL, setTokenURL] = useState((props.config && props.config.tokenURL) || "");+ const [profileURL, setProfileURL] = useState((props.config && props.config.profileURL) || "");+ const [scope, setScope] = useState((props.config && props.config.scope) || "");+ const [jsonUserIDPath, setJSONUserIDPath] = useState((props.config && props.config.jsonUserIDPath) || "");+ const [jsonUserNamePath, setJSONUserNamePath] = useState((props.config && props.config.jsonUserNamePath) || "");+ const [jsonUserEmailPath, setJSONUserEmailPath] = useState((props.config && props.config.jsonUserEmailPath) || "");+ const [logo, setLogo] = useState<ImageUpload | undefined>();+ const [logoURL, setLogoURL] = useState<string | undefined>();+ const [logoBlobKey, setLogoBlobKey] = useState((props.config && props.config.logoBlobKey) || "");+ const [error, setError] = useState<Failure | undefined>();- private handleSave = async () => {+ const handleSave = async () => {const result = await actions.saveOAuthConfig({- provider: this.state.provider,- status: this.state.enabled ? OAuthConfigStatus.Enabled : OAuthConfigStatus.Disabled,- displayName: this.state.displayName,- clientID: this.state.clientID,- clientSecret: this.state.clientSecretEnabled ? this.state.clientSecret : "",- authorizeURL: this.state.authorizeURL,- tokenURL: this.state.tokenURL,- profileURL: this.state.profileURL,- scope: this.state.scope,- jsonUserIDPath: this.state.jsonUserIDPath,- jsonUserNamePath: this.state.jsonUserNamePath,- jsonUserEmailPath: this.state.jsonUserEmailPath,- logo: this.state.logo+ provider,+ status: enabled ? OAuthConfigStatus.Enabled : OAuthConfigStatus.Disabled,+ displayName,+ clientID,+ clientSecret: clientSecretEnabled ? clientSecret : "",+ authorizeURL,+ tokenURL,+ profileURL,+ scope,+ jsonUserIDPath,+ jsonUserNamePath,+ jsonUserEmailPath,+ logo});if (result.ok) {location.reload();} else {- this.setState({ error: result.error });+ setError(result.error);}};- private handleCancel = async () => {- this.props.onCancel();- };-- private setDisplayName = (displayName: string) => {- this.setState({ displayName });- };-- private setLogo = (logo: ImageUpload, instanceID: string, previewURL: string) => {- this.setState({ logo, logoURL: previewURL, logoBlobKey: "" });- };-- private setStatus = async (enabled: boolean) => {- this.setState({ enabled });+ const handleLogoChange = (newLogo: ImageUpload, instanceID: string, previewURL: string) => {+ setLogo(newLogo);+ setLogoURL(previewURL);+ setLogoBlobKey("");};- private setClientID = (clientID: string) => {- this.setState({ clientID });+ const handleCancel = async () => {+ props.onCancel();};- private setClientSecret = (clientSecret: string) => {- this.setState({ clientSecret });+ const enableClientSecret = () => {+ setClientSecret("");+ setClientSecretEnabled(true);};- private setAuthorizeURL = (authorizeURL: string) => {- this.setState({ authorizeURL });- };-- private setTokenURL = (tokenURL: string) => {- this.setState({ tokenURL });- };-- private setProfileURL = (profileURL: string) => {- this.setState({ profileURL });- };+ const title = props.config ? `OAuth Provider: ${props.config.displayName}` : "New OAuth Provider";+ return (+ <>+ <Heading title={title} size="small" />+ <Form error={error}>+ <div className="row">+ <div className="col-sm-9">+ <Input+ field="displayName"+ label="Display Name"+ maxLength={50}+ value={displayName}+ disabled={!fider.session.user.isAdministrator}+ onChange={setDisplayName}+ />- private setScope = (scope: string) => {- this.setState({ scope });- };+ <ImageUploader+ label="Logo"+ field="logo"+ bkey={logoBlobKey}+ previewMaxWidth={80}+ disabled={!fider.session.user.isAdministrator}+ onChange={handleLogoChange}+ >+ <p className="info">+ We accept JPG, GIF and PNG images, smaller than 50KB and with an aspect ratio of 1:1 with minimum+ dimensions of 24x24 pixels.+ </p>+ </ImageUploader>+ </div>+ <div className="col-sm-3">+ <Field label="Button Preview">+ <SocialSignInButton option={{ displayName, provider, logoBlobKey, logoURL }} />+ </Field>+ </div>+ </div>- private setJSONUserIDPath = (jsonUserIDPath: string) => {- this.setState({ jsonUserIDPath });- };+ <Input+ field="clientID"+ label="Client ID"+ maxLength={100}+ value={clientID}+ disabled={!fider.session.user.isAdministrator}+ onChange={setClientID}+ />- private setJSONUserNamePath = (jsonUserNamePath: string) => {- this.setState({ jsonUserNamePath });- };+ <Input+ field="clientSecret"+ label="Client Secret"+ maxLength={500}+ value={clientSecret}+ disabled={!clientSecretEnabled}+ onChange={setClientSecret}+ afterLabel={+ !clientSecretEnabled ? (+ <>+ <span className="info">omitted for security reasons.</span>+ <span className="info clickable" onClick={enableClientSecret}>+ change+ </span>+ </>+ ) : (+ undefined+ )+ }+ />+ <Input+ field="authorizeURL"+ label="Authorize URL"+ maxLength={300}+ value={authorizeURL}+ disabled={!fider.session.user.isAdministrator}+ onChange={setAuthorizeURL}+ />+ <Input+ field="tokenURL"+ label="Token URL"+ maxLength={300}+ value={tokenURL}+ disabled={!fider.session.user.isAdministrator}+ onChange={setTokenURL}+ />- private setJSONUserEmailPath = (jsonUserEmailPath: string) => {- this.setState({ jsonUserEmailPath });- };+ <Input+ field="scope"+ label="Scope"+ maxLength={100}+ value={scope}+ disabled={!fider.session.user.isAdministrator}+ onChange={setScope}+ >+ <p className="info">+ It is recommended to only request the minimum scopes we need to fetch the user <strong>id</strong>,{" "}+ <strong>name</strong> and <strong>email</strong>. Multiple scopes must be separated by space.+ </p>+ </Input>- private enableClientSecret = () => {- this.setState({ clientSecretEnabled: true, clientSecret: "" });- };+ <h3>User Profile</h3>+ <p className="info">+ This section is used to configure how Fider will fetch user after the authentication process.+ </p>- public render() {- const title = this.props.config ? `OAuth Provider: ${this.props.config.displayName}` : "New OAuth Provider";- return (- <>- <Heading title={title} size="small" />- <Form error={this.state.error}>- <div className="row">- <div className="col-sm-9">- <Input- field="displayName"- label="Display Name"- maxLength={50}- value={this.state.displayName}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setDisplayName}- />+ <Input+ field="profileURL"+ label="Profile API URL"+ maxLength={300}+ value={profileURL}+ disabled={!fider.session.user.isAdministrator}+ onChange={setProfileURL}+ >+ <p className="info">+ The URL to fetch the authenticated user info. If empty, Fider will try to parse the user info from the+ Access Token.+ </p>+ </Input>- <ImageUploader- label="Logo"- field="logo"- bkey={this.state.logoBlobKey}- previewMaxWidth={80}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setLogo}- >- <p className="info">- We accept JPG, GIF and PNG images, smaller than 50KB and with an aspect ratio of 1:1 with minimum- dimensions of 24x24 pixels.- </p>- </ImageUploader>- </div>- <div className="col-sm-3">- <Field label="Button Preview">- <SocialSignInButton option={this.state} />- </Field>- </div>- </div>+ <h4>JSON Path</h4>+ <div className="row"><Input- field="clientID"- label="Client ID"+ field="jsonUserIDPath"+ label="ID"+ className="col-sm-4"maxLength={100}- value={this.state.clientID}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setClientID}- />-- <Input- field="clientSecret"- label="Client Secret"- maxLength={500}- value={this.state.clientSecret}- disabled={!this.state.clientSecretEnabled}- onChange={this.setClientSecret}- afterLabel={- !this.state.clientSecretEnabled ? (- <>- <span className="info">omitted for security reasons.</span>- <span className="info clickable" onClick={this.enableClientSecret}>- change- </span>- </>- ) : (- undefined- )- }- />- <Input- field="authorizeURL"- label="Authorize URL"- maxLength={300}- value={this.state.authorizeURL}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setAuthorizeURL}- />- <Input- field="tokenURL"- label="Token URL"- maxLength={300}- value={this.state.tokenURL}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setTokenURL}- />-+ value={jsonUserIDPath}+ disabled={!fider.session.user.isAdministrator}+ onChange={setJSONUserIDPath}+ >+ <p className="info">+ Path to extract User ID from the JSON. This ID <strong>must</strong> be unique within the provider or+ unexpected side effects might happen. For example below, the path would be <strong>id</strong>.+ </p>+ </Input><Input- field="scope"- label="Scope"+ field="jsonUserNamePath"+ label="Name"+ className="col-sm-4"maxLength={100}- value={this.state.scope}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setScope}+ value={jsonUserNamePath}+ disabled={!fider.session.user.isAdministrator}+ onChange={setJSONUserNamePath}><p className="info">- It is recommended to only request the minimum scopes we need to fetch the user <strong>id</strong>,{" "}- <strong>name</strong> and <strong>email</strong>. Multiple scopes must be separated by space.+ Path to extract user Display Name from the JSON. This is optional, but <strong>highly</strong>{" "}+ recommended. For the example below, the path would be <strong>profile.name</strong>.</p></Input>-- <h3>User Profile</h3>- <p className="info">- This section is used to configure how Fider will fetch user after the authentication process.- </p>-<Input- field="profileURL"- label="Profile API URL"- maxLength={300}- value={this.state.profileURL}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setProfileURL}+ field="jsonUserEmailPath"+ label="Email"+ className="col-sm-4"+ maxLength={100}+ value={jsonUserEmailPath}+ disabled={!fider.session.user.isAdministrator}+ onChange={setJSONUserEmailPath}><p className="info">- The URL to fetch the authenticated user info. If empty, Fider will try to parse the user info from the- Access Token.+ Path to extract user Email from the JSON. This is optional, but <strong>highly</strong> recommended. For+ the example below, the path would be <strong>profile.emails[0]</strong>.</p></Input>-- <h4>JSON Path</h4>-- <div className="row">- <Input- field="jsonUserIDPath"- label="ID"- className="col-sm-4"- maxLength={100}- value={this.state.jsonUserIDPath}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setJSONUserIDPath}- >- <p className="info">- Path to extract User ID from the JSON. This ID <strong>must</strong> be unique within the provider or- unexpected side effects might happen. For example below, the path would be <strong>id</strong>.- </p>- </Input>- <Input- field="jsonUserNamePath"- label="Name"- className="col-sm-4"- maxLength={100}- value={this.state.jsonUserNamePath}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setJSONUserNamePath}- >- <p className="info">- Path to extract user Display Name from the JSON. This is optional, but <strong>highly</strong>{" "}- recommended. For the example below, the path would be <strong>profile.name</strong>.- </p>- </Input>- <Input- field="jsonUserEmailPath"- label="Email"- className="col-sm-4"- maxLength={100}- value={this.state.jsonUserEmailPath}- disabled={!Fider.session.user.isAdministrator}- onChange={this.setJSONUserEmailPath}- >- <p className="info">- Path to extract user Email from the JSON. This is optional, but <strong>highly</strong> recommended. For- the example below, the path would be <strong>profile.emails[0]</strong>.- </p>- </Input>- </div>- <pre>- <h5>Example Response</h5>- {`-{+ </div>+ <pre>+ <h5>Example Response</h5>+ {`+ {id: "35235"title: "Sr. Account Manager",profile: {@@ -305,36 +243,35 @@ export class OAuthForm extends React.Component<OAuthFormProps, OAuthFormState> {]}}- `}- </pre>+ `}+ </pre>- <div className="row">- <div className="col-sm-4">- <Field label="Status">- <Toggle active={this.state.enabled} onToggle={this.setStatus} />- <span>{this.state.enabled ? "Enabled" : "Disabled"}</span>- {this.state.enabled && (- <p className="info">- This provider will be available for everyone to use during the sign in process. It is recommended- that you keep it disable and test it before enabling it. The Test button is available after saving- this configuration.- </p>- )}- {!this.state.enabled && <p className="info">Users won't be able to sign in with this Provider.</p>}- </Field>- </div>+ <div className="row">+ <div className="col-sm-4">+ <Field label="Status">+ <Toggle active={enabled} onToggle={setEnabled} />+ <span>{enabled ? "Enabled" : "Disabled"}</span>+ {enabled && (+ <p className="info">+ This provider will be available for everyone to use during the sign in process. It is recommended that+ you keep it disable and test it before enabling it. The Test button is available after saving this+ configuration.+ </p>+ )}+ {!enabled && <p className="info">Users won't be able to sign in with this Provider.</p>}+ </Field></div>+ </div>- <div className="c-form-field">- <Button color="positive" onClick={this.handleSave}>- Save- </Button>- <Button color="cancel" onClick={this.handleCancel}>- Cancel- </Button>- </div>- </Form>- </>- );- }-}+ <div className="c-form-field">+ <Button color="positive" onClick={handleSave}>+ Save+ </Button>+ <Button color="cancel" onClick={handleCancel}>+ Cancel+ </Button>+ </div>+ </Form>+ </>+ );+};diff --git a/public/pages/UI/UIToolkit.page.tsx b/public/pages/UI/UIToolkit.page.tsxindex 62363df8d..599ee1ace 100644--- a/public/pages/UI/UIToolkit.page.tsx+++ b/public/pages/UI/UIToolkit.page.tsx@@ -1,6 +1,6 @@import "./UIToolkit.page.scss";-import React from "react";+import React, { useState } from "react";import { PostStatus, UserStatus } from "@fider/models";import {Heading,@@ -54,465 +54,456 @@ const hardTag: Tag = { id: 3, slug: "hard", name: "hard", color: "fbca04", isPubconst visibilityPublic = { label: "Public", value: "public" };const visibilityPrivate = { label: "Private", value: "private" };-interface UIToolkitPageState {- error?: Failure;-}+const UIToolkitPage = () => {+ const [error, setError] = useState<Failure | undefined>(undefined);-export default class UIToolkitPage extends React.Component<{}, UIToolkitPageState> {- constructor(props: {}) {- super(props);- this.state = {};- }-- private notifyError = async () => {+ const notifyError = async () => {notify.error("Something went wrong...");};- private notifySuccess = async () => {+ const notifySuccess = async () => {notify.success("Congratulations! It worked!");};- private notifyStatusChange = (opt?: SelectOption) => {+ const notifyStatusChange = (opt?: SelectOption) => {if (opt) {notify.success(opt.value);}};- private showLoading = async (e: ButtonClickEvent) => {+ const showLoading = async (e: ButtonClickEvent) => {return e.preventEnable();};- private forceError = async () => {- this.setState({- error: {- errors: [- { field: "title", message: "Title is mandatory" },- { field: "description", message: "Error #1" },- { field: "description", message: "Error #2" },- { field: "status", message: "Status is mandatory" }- ]- }+ const forceError = async () => {+ setError({+ errors: [+ { field: "title", message: "Title is mandatory" },+ { field: "description", message: "Error #1" },+ { field: "description", message: "Error #2" },+ { field: "status", message: "Status is mandatory" }+ ]});};- private renderText = (item?: DropDownItem) => {+ const renderText = (item?: DropDownItem) => {if (item) {return `${item.label} (value: ${item.value})`;}return <span>No country is selected</span>;};- private renderControl = (item?: DropDownItem) => {+ const renderControl = (item?: DropDownItem) => {if (item) {return item.render;}return <span>...</span>;};- public render() {- return (- <div id="p-ui-toolkit" className="page container">- <div className="color-scale">- <div className="color gray-darkest" />- <div className="color gray-darker" />- <div className="color gray-dark" />- <div className="color gray-default" />- <div className="color gray-light" />- <div className="color gray-lighter" />- <div className="color gray-lightest" />- </div>- <div className="color-scale">- <div className="color green-darkest" />- <div className="color green-darker" />- <div className="color green-dark" />- <div className="color green-default" />- <div className="color green-light" />- <div className="color green-lighter" />- <div className="color green-lightest" />- </div>- <div className="color-scale">- <div className="color red-darkest" />- <div className="color red-darker" />- <div className="color red-dark" />- <div className="color red-default" />- <div className="color red-light" />- <div className="color red-lighter" />- <div className="color red-lightest" />- </div>- <div className="color-scale">- <div className="color blue-darkest" />- <div className="color blue-darker" />- <div className="color blue-dark" />- <div className="color blue-default" />- <div className="color blue-light" />- <div className="color blue-lighter" />- <div className="color blue-lightest" />- </div>- <div className="color-scale">- <div className="color yellow-darkest" />- <div className="color yellow-darker" />- <div className="color yellow-dark" />- <div className="color yellow-default" />- <div className="color yellow-light" />- <div className="color yellow-lighter" />- <div className="color yellow-lightest" />- </div>-- <h1>Heading 1</h1>- <h2>Heading 2</h2>- <h3>Heading 3</h3>- <h4>Heading 4</h4>- <h5>Heading 5</h5>- <h6>Heading 6</h6>- <p>General Text Paragraph</p>- <p className="info">Info Text</p>+ return (+ <div id="p-ui-toolkit" className="page container">+ <div className="color-scale">+ <div className="color gray-darkest" />+ <div className="color gray-darker" />+ <div className="color gray-dark" />+ <div className="color gray-default" />+ <div className="color gray-light" />+ <div className="color gray-lighter" />+ <div className="color gray-lightest" />+ </div>+ <div className="color-scale">+ <div className="color green-darkest" />+ <div className="color green-darker" />+ <div className="color green-dark" />+ <div className="color green-default" />+ <div className="color green-light" />+ <div className="color green-lighter" />+ <div className="color green-lightest" />+ </div>+ <div className="color-scale">+ <div className="color red-darkest" />+ <div className="color red-darker" />+ <div className="color red-dark" />+ <div className="color red-default" />+ <div className="color red-light" />+ <div className="color red-lighter" />+ <div className="color red-lightest" />+ </div>+ <div className="color-scale">+ <div className="color blue-darkest" />+ <div className="color blue-darker" />+ <div className="color blue-dark" />+ <div className="color blue-default" />+ <div className="color blue-light" />+ <div className="color blue-lighter" />+ <div className="color blue-lightest" />+ </div>+ <div className="color-scale">+ <div className="color yellow-darkest" />+ <div className="color yellow-darker" />+ <div className="color yellow-dark" />+ <div className="color yellow-default" />+ <div className="color yellow-light" />+ <div className="color yellow-lighter" />+ <div className="color yellow-lightest" />+ </div>+ <h1>Heading 1</h1>+ <h2>Heading 2</h2>+ <h3>Heading 3</h3>+ <h4>Heading 4</h4>+ <h5>Heading 5</h5>+ <h6>Heading 6</h6>+ <p>General Text Paragraph</p>+ <p className="info">Info Text</p>++ <Segment>+ <h2>The title</h2>+ <p>The content goes here</p>+ </Segment>++ <Segments>+ <Segment>+ <p>First Segment</p>+ </Segment>+ <Segment>+ <p>Second Segment</p>+ </Segment><Segment>- <h2>The title</h2>- <p>The content goes here</p>+ <p>Third Segment</p></Segment>+ </Segments>++ <List>+ <ListItem>+ <Avatar user={jonSnow} /> <UserName user={jonSnow} />+ </ListItem>+ <ListItem>+ <Avatar user={aryaStark} /> <UserName user={aryaStark} />+ </ListItem>+ </List>++ <Heading title="Page Heading" icon={FaCogs} subtitle="This is a page heading" />++ <Heading+ title="Section Heading"+ icon={FaRegLightbulb}+ subtitle="This is a page heading"+ size="small"+ dividing={true}+ />++ <h1>Buttons</h1>+ <List>+ <ListItem>+ <Button size="large">+ <FaRegLightbulb /> Large Icon+ </Button>+ <Button size="large">Large Default</Button>+ <Button color="positive" size="large">+ Large Positive+ </Button>+ <Button color="danger" size="large">+ Large Danger+ </Button>+ <Button color="cancel" size="large">+ Large Cancel+ </Button>+ </ListItem>++ <ListItem>+ <Button size="normal">+ <FaRegLightbulb /> Normal Icon+ </Button>+ <Button size="normal">Normal Default</Button>+ <Button color="positive" size="normal">+ Normal Positive+ </Button>+ <Button color="danger" size="normal">+ Normal Danger+ </Button>+ <Button color="cancel" size="normal">+ Normal Cancel+ </Button>+ </ListItem>++ <ListItem>+ <Button size="small">+ <FaRegLightbulb /> Small Icon+ </Button>+ <Button size="small">Small Default</Button>+ <Button color="positive" size="small">+ Small Positive+ </Button>+ <Button color="danger" size="small">+ Small Danger+ </Button>+ <Button color="cancel" size="small">+ Small Cancel+ </Button>+ </ListItem>++ <ListItem>+ <Button size="tiny">+ <FaRegLightbulb /> Tiny Icon+ </Button>+ <Button size="tiny">Tiny Default</Button>+ <Button color="positive" size="tiny">+ Tiny Positive+ </Button>+ <Button color="danger" size="tiny">+ Tiny Danger+ </Button>+ <Button color="cancel" size="tiny">+ Tiny Cancel+ </Button>+ </ListItem>++ <ListItem>+ <Button size="mini">+ <FaRegLightbulb /> Mini Icon+ </Button>+ <Button size="mini">Mini Default</Button>+ <Button color="positive" size="mini">+ Mini Positive+ </Button>+ <Button color="danger" size="mini">+ Mini Danger+ </Button>+ <Button color="cancel" size="mini">+ Mini Cancel+ </Button>+ </ListItem>++ <ListItem>+ <Button href="#">+ <FaRegLightbulb /> Link+ </Button>+ <Button href="#">Link</Button>+ <Button href="#" color="positive">+ Link+ </Button>+ <Button href="#" color="danger">+ Link+ </Button>+ </ListItem>++ <ListItem>+ <Button disabled={true}>+ <FaRegLightbulb /> Default+ </Button>+ <Button disabled={true}>Default</Button>+ <Button disabled={true} color="positive">+ Positive+ </Button>+ <Button disabled={true} color="danger">+ Danger+ </Button>+ </ListItem>++ <ListItem>+ <Button onClick={showLoading}>+ <FaRegLightbulb /> Loading+ </Button>+ <Button onClick={showLoading}>Loading</Button>+ <Button color="positive" onClick={showLoading}>+ Loading+ </Button>+ <Button color="danger" onClick={showLoading}>+ Loading+ </Button>+ </ListItem>+ </List>++ <h1>Toggle</h1>+ <List>+ <ListItem>+ <Toggle active={true} label="Active" />+ </ListItem>+ <ListItem>+ <Toggle active={false} label="Inactive" />+ </ListItem>+ <ListItem>+ <Toggle active={true} disabled={true} label="Disabled" />+ </ListItem>+ </List>++ <h1>Statuses</h1>+ <List>+ <ListItem>+ <ShowPostStatus status={PostStatus.Open} />+ </ListItem>+ <ListItem>+ <ShowPostStatus status={PostStatus.Planned} />+ </ListItem>+ <ListItem>+ <ShowPostStatus status={PostStatus.Started} />+ </ListItem>+ <ListItem>+ <ShowPostStatus status={PostStatus.Duplicate} />+ </ListItem>+ <ListItem>+ <ShowPostStatus status={PostStatus.Completed} />+ </ListItem>+ <ListItem>+ <ShowPostStatus status={PostStatus.Declined} />+ </ListItem>+ </List>++ <h1>Tags</h1>+ <List>+ <ListItem>+ <ShowTag tag={easyTag} size="normal" />+ <ShowTag tag={hardTag} size="normal" />+ <ShowTag tag={easyTag} circular={true} size="normal" />+ <ShowTag tag={hardTag} circular={true} size="normal" />+ </ListItem>+ <ListItem>+ <ShowTag tag={easyTag} size="small" />+ <ShowTag tag={hardTag} size="small" />+ <ShowTag tag={easyTag} circular={true} size="small" />+ <ShowTag tag={hardTag} circular={true} size="small" />+ </ListItem>+ <ListItem>+ <ShowTag tag={easyTag} size="tiny" />+ <ShowTag tag={hardTag} size="tiny" />+ <ShowTag tag={easyTag} circular={true} size="tiny" />+ <ShowTag tag={hardTag} circular={true} size="tiny" />+ </ListItem>+ <ListItem>+ <ShowTag tag={easyTag} size="mini" />+ <ShowTag tag={hardTag} size="mini" />+ <ShowTag tag={easyTag} circular={true} size="mini" />+ <ShowTag tag={hardTag} circular={true} size="mini" />+ </ListItem>+ </List>++ <h1>Notification</h1>+ <List>+ <ListItem>+ <Button onClick={notifySuccess}>Success</Button>+ <Button onClick={notifyError}>Error</Button>+ </ListItem>+ </List>++ <h1>Moment</h1>+ <List>+ <ListItem>+ <Moment date="2017-06-03T16:55:06.815042Z" />+ </ListItem>+ <ListItem>+ <Moment date={new Date(2014, 10, 3, 12, 53, 12, 0)} />+ </ListItem>+ <ListItem>+ <Moment date={new Date()} />+ </ListItem>+ </List>++ <h1>Loader</h1>+ <Loader />++ <h1>Message Box</h1>+ <Message showIcon={true} type="error">+ Something went wrong.+ </Message>+ <Message showIcon={true} type="success">+ Your order has been confirmed.+ </Message>++ <h1>Hints</h1>+ <Hint permanentCloseKey="ui-toolkip-example">Did you know that you can close this permanently?</Hint>+ <Hint>You can't close this one :)</Hint>++ <h1>Form</h1>+ <Form error={error}>+ <Input label="Title" field="title">+ <p className="info">This is the explanation for the field above.</p>+ </Input>+ <Input label="Disabled!" field="unamed" disabled={true} value={"you can't change this!"} />+ <Input label="Name" field="name" placeholder={"Your name goes here..."} />+ <Input label="Subdomain" field="subdomain" suffix="fider.io" />+ <Input label="Email" field="email" suffix={<Button color="positive">Sign in</Button>} />+ <TextArea label="Description" field="description" minRows={5}>+ <p className="info">This textarea resizes as you type.</p>+ </TextArea>+ <Input field="age" placeholder="This field doesn't have a label" />++ <div className="row">+ <div className="col-md-3">+ <Input label="Title1" field="title1" />+ </div>+ <div className="col-md-3">+ <Input label="Title2" field="title2" />+ </div>+ <div className="col-md-3">+ <Input label="Title3" field="title3" />+ </div>+ <div className="col-md-3">+ <RadioButton+ label="Visibility"+ field="visibility"+ defaultOption={visibilityPublic}+ options={[visibilityPrivate, visibilityPublic]}+ />+ </div>+ </div>- <Segments>- <Segment>- <p>First Segment</p>- </Segment>- <Segment>- <p>Second Segment</p>- </Segment>- <Segment>- <p>Third Segment</p>- </Segment>- </Segments>-- <List>- <ListItem>- <Avatar user={jonSnow} /> <UserName user={jonSnow} />- </ListItem>- <ListItem>- <Avatar user={aryaStark} /> <UserName user={aryaStark} />- </ListItem>- </List>-- <Heading title="Page Heading" icon={FaCogs} subtitle="This is a page heading" />-- <Heading- title="Section Heading"- icon={FaRegLightbulb}- subtitle="This is a page heading"- size="small"- dividing={true}+ <Select+ label="Status"+ field="status"+ options={[+ { value: "open", label: "Open" },+ { value: "started", label: "Started" },+ { value: "planned", label: "Planned" }+ ]}+ onChange={notifyStatusChange}/>- <h1>Buttons</h1>- <List>- <ListItem>- <Button size="large">- <FaRegLightbulb /> Large Icon- </Button>- <Button size="large">Large Default</Button>- <Button color="positive" size="large">- Large Positive- </Button>- <Button color="danger" size="large">- Large Danger- </Button>- <Button color="cancel" size="large">- Large Cancel- </Button>- </ListItem>-- <ListItem>- <Button size="normal">- <FaRegLightbulb /> Normal Icon- </Button>- <Button size="normal">Normal Default</Button>- <Button color="positive" size="normal">- Normal Positive- </Button>- <Button color="danger" size="normal">- Normal Danger- </Button>- <Button color="cancel" size="normal">- Normal Cancel- </Button>- </ListItem>-- <ListItem>- <Button size="small">- <FaRegLightbulb /> Small Icon- </Button>- <Button size="small">Small Default</Button>- <Button color="positive" size="small">- Small Positive- </Button>- <Button color="danger" size="small">- Small Danger- </Button>- <Button color="cancel" size="small">- Small Cancel- </Button>- </ListItem>-- <ListItem>- <Button size="tiny">- <FaRegLightbulb /> Tiny Icon- </Button>- <Button size="tiny">Tiny Default</Button>- <Button color="positive" size="tiny">- Tiny Positive- </Button>- <Button color="danger" size="tiny">- Tiny Danger- </Button>- <Button color="cancel" size="tiny">- Tiny Cancel- </Button>- </ListItem>-- <ListItem>- <Button size="mini">- <FaRegLightbulb /> Mini Icon- </Button>- <Button size="mini">Mini Default</Button>- <Button color="positive" size="mini">- Mini Positive- </Button>- <Button color="danger" size="mini">- Mini Danger- </Button>- <Button color="cancel" size="mini">- Mini Cancel- </Button>- </ListItem>-- <ListItem>- <Button href="#">- <FaRegLightbulb /> Link- </Button>- <Button href="#">Link</Button>- <Button href="#" color="positive">- Link- </Button>- <Button href="#" color="danger">- Link- </Button>- </ListItem>-- <ListItem>- <Button disabled={true}>- <FaRegLightbulb /> Default- </Button>- <Button disabled={true}>Default</Button>- <Button disabled={true} color="positive">- Positive- </Button>- <Button disabled={true} color="danger">- Danger- </Button>- </ListItem>-- <ListItem>- <Button onClick={this.showLoading}>- <FaRegLightbulb /> Loading- </Button>- <Button onClick={this.showLoading}>Loading</Button>- <Button color="positive" onClick={this.showLoading}>- Loading- </Button>- <Button color="danger" onClick={this.showLoading}>- Loading- </Button>- </ListItem>- </List>-- <h1>Toggle</h1>- <List>- <ListItem>- <Toggle active={true} label="Active" />- </ListItem>- <ListItem>- <Toggle active={false} label="Inactive" />- </ListItem>- <ListItem>- <Toggle active={true} disabled={true} label="Disabled" />- </ListItem>- </List>-- <h1>Statuses</h1>- <List>- <ListItem>- <ShowPostStatus status={PostStatus.Open} />- </ListItem>- <ListItem>- <ShowPostStatus status={PostStatus.Planned} />- </ListItem>- <ListItem>- <ShowPostStatus status={PostStatus.Started} />- </ListItem>- <ListItem>- <ShowPostStatus status={PostStatus.Duplicate} />- </ListItem>- <ListItem>- <ShowPostStatus status={PostStatus.Completed} />- </ListItem>- <ListItem>- <ShowPostStatus status={PostStatus.Declined} />- </ListItem>- </List>-- <h1>Tags</h1>- <List>- <ListItem>- <ShowTag tag={easyTag} size="normal" />- <ShowTag tag={hardTag} size="normal" />- <ShowTag tag={easyTag} circular={true} size="normal" />- <ShowTag tag={hardTag} circular={true} size="normal" />- </ListItem>- <ListItem>- <ShowTag tag={easyTag} size="small" />- <ShowTag tag={hardTag} size="small" />- <ShowTag tag={easyTag} circular={true} size="small" />- <ShowTag tag={hardTag} circular={true} size="small" />- </ListItem>- <ListItem>- <ShowTag tag={easyTag} size="tiny" />- <ShowTag tag={hardTag} size="tiny" />- <ShowTag tag={easyTag} circular={true} size="tiny" />- <ShowTag tag={hardTag} circular={true} size="tiny" />- </ListItem>- <ListItem>- <ShowTag tag={easyTag} size="mini" />- <ShowTag tag={hardTag} size="mini" />- <ShowTag tag={easyTag} circular={true} size="mini" />- <ShowTag tag={hardTag} circular={true} size="mini" />- </ListItem>- </List>-- <h1>Notification</h1>- <List>- <ListItem>- <Button onClick={this.notifySuccess}>Success</Button>- <Button onClick={this.notifyError}>Error</Button>- </ListItem>- </List>-- <h1>Moment</h1>- <List>- <ListItem>- <Moment date="2017-06-03T16:55:06.815042Z" />- </ListItem>- <ListItem>- <Moment date={new Date(2014, 10, 3, 12, 53, 12, 0)} />- </ListItem>- <ListItem>- <Moment date={new Date()} />- </ListItem>- </List>-- <h1>Loader</h1>- <Loader />-- <h1>Message Box</h1>- <Message showIcon={true} type="error">- Something went wrong.- </Message>- <Message showIcon={true} type="success">- Your order has been confirmed.- </Message>-- <h1>Hints</h1>- <Hint permanentCloseKey="ui-toolkip-example">Did you know that you can close this permanently?</Hint>- <Hint>You can't close this one :)</Hint>-- <h1>Form</h1>- <Form error={this.state.error}>- <Input label="Title" field="title">- <p className="info">This is the explanation for the field above.</p>- </Input>- <Input label="Disabled!" field="unamed" disabled={true} value={"you can't change this!"} />- <Input label="Name" field="name" placeholder={"Your name goes here..."} />- <Input label="Subdomain" field="subdomain" suffix="fider.io" />- <Input label="Email" field="email" suffix={<Button color="positive">Sign in</Button>} />- <TextArea label="Description" field="description" minRows={5}>- <p className="info">This textarea resizes as you type.</p>- </TextArea>- <Input field="age" placeholder="This field doesn't have a label" />-- <div className="row">- <div className="col-md-3">- <Input label="Title1" field="title1" />- </div>- <div className="col-md-3">- <Input label="Title2" field="title2" />- </div>- <div className="col-md-3">- <Input label="Title3" field="title3" />- </div>- <div className="col-md-3">- <RadioButton- label="Visibility"- field="visibility"- defaultOption={visibilityPublic}- options={[visibilityPrivate, visibilityPublic]}- />- </div>- </div>-- <Select- label="Status"- field="status"- options={[- { value: "open", label: "Open" },- { value: "started", label: "Started" },- { value: "planned", label: "Planned" }+ <Field label="Number">+ <DropDown+ items={[{ label: "One", value: "1" }, { label: "Two", value: "2" }, { label: "Three", value: "3" }]}+ defaultValue={"1"}+ placeholder="Select a number"+ />+ </Field>++ <Field label="Country (custom render text)">+ <DropDown+ items={[+ { label: "Brazil", value: "br" },+ { label: "United States", value: "us" },+ { label: "Ireland", value: "ie" }]}- onChange={this.notifyStatusChange}+ defaultValue={"1"}+ renderText={renderText}+ placeholder="Select a number"/>+ </Field>++ <Field label="Color (custom render control)">+ <DropDown+ items={[+ { label: "Green", value: "green", render: <span style={{ color: "green" }}>Green</span> },+ { label: "Red", value: "red", render: <span style={{ color: "red" }}>Red</span> },+ { label: "Blue", value: "blue", render: <span style={{ color: "blue" }}>Blue</span> }+ ]}+ placeholder="Select a color"+ inline={true}+ style="simple"+ header="What color do you like the most?"+ renderControl={renderControl}+ />+ </Field>- <Field label="Number">- <DropDown- items={[{ label: "One", value: "1" }, { label: "Two", value: "2" }, { label: "Three", value: "3" }]}- defaultValue={"1"}- placeholder="Select a number"- />- </Field>-- <Field label="Country (custom render text)">- <DropDown- items={[- { label: "Brazil", value: "br" },- { label: "United States", value: "us" },- { label: "Ireland", value: "ie" }- ]}- defaultValue={"1"}- renderText={this.renderText}- placeholder="Select a number"- />- </Field>-- <Field label="Color (custom render control)">- <DropDown- items={[- { label: "Green", value: "green", render: <span style={{ color: "green" }}>Green</span> },- { label: "Red", value: "red", render: <span style={{ color: "red" }}>Red</span> },- { label: "Blue", value: "blue", render: <span style={{ color: "blue" }}>Blue</span> }- ]}- placeholder="Select a color"- inline={true}- style="simple"- header="What color do you like the most?"- renderControl={this.renderControl}- />- </Field>+ <Button onClick={forceError}>Save</Button>+ </Form>- <Button onClick={this.forceError}>Save</Button>- </Form>+ <Segment>+ <h1>Search</h1>+ <Input field="search" placeholder="Search..." icon={FaSearch} />+ </Segment>+ </div>+ );+};- <Segment>- <h1>Search</h1>- <Input field="search" placeholder="Search..." icon={FaSearch} />- </Segment>- </div>- );- }-}+export default UIToolkitPage;