Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

enhancement: redesign of site settings UI (#341)

Guilherme Oenningd01941005e87
diff --git a/public/assets/styles/semantic.scss b/public/assets/styles/semantic.scss
index 8401cccb2..292811cb5 100644
--- a/public/assets/styles/semantic.scss
+++ b/public/assets/styles/semantic.scss
@@ -1,3 +1,17 @@
+@import 'variables.scss';
+
+.ui.vertical.menu {
+ .active.item {
+ color: $admin-color;
+ border-left: 2px solid $admin-color;
+ font-weight: 700;
+ background-color: $menu-color;
+ &:hover {
+ color: $admin-color;
+ }
+ }
+}
+
.ui.list {
.item {
.showover {
diff --git a/public/components/common/Button.tsx b/public/components/common/Button.tsx
index cff945aa3..62421bec3 100644
--- a/public/components/common/Button.tsx
+++ b/public/components/common/Button.tsx
@@ -32,7 +32,7 @@ export class Button extends React.Component<ButtonProps, ButtonState> {
private unmounted: boolean = false;
public static defaultProps: Partial<ButtonProps> = {
- size: "normal",
+ size: "small",
fluid: false
};
diff --git a/public/components/common/Header.tsx b/public/components/common/Header.tsx
index 58a165715..07df4662f 100644
--- a/public/components/common/Header.tsx
+++ b/public/components/common/Header.tsx
@@ -64,13 +64,7 @@ export class Header extends React.Component<HeaderProps, HeaderState> {
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
+ Site Settings
</a>,
<div key={5} className="divider" />
]}
diff --git a/public/pages/AdminHome/AdminHome.page.tsx b/public/pages/AdminHome/AdminHome.page.tsx
deleted file mode 100644
index b7107dedb..000000000
--- a/public/pages/AdminHome/AdminHome.page.tsx
+++ /dev/null
@@ -1,168 +0,0 @@
-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";
-
-interface AdminHomePageProps {
- user: CurrentUser;
- tenant: Tenant;
- system: SystemSettings;
-}
-
-interface AdminHomePageState {
- title: string;
- welcomeMessage: string;
- invitation: string;
- cname: string;
- error?: Failure;
-}
-
-export class AdminHomePage extends React.Component<AdminHomePageProps, AdminHomePageState> {
- constructor(props: AdminHomePageProps) {
- super(props);
-
- this.state = {
- title: this.props.tenant.name,
- cname: this.props.tenant.cname,
- welcomeMessage: this.props.tenant.welcomeMessage,
- invitation: this.props.tenant.invitation
- };
-
- page.setTitle(`Administration · ${document.title}`);
- }
-
- private async confirm(e: ButtonClickEvent) {
- const result = await actions.updateTenantSettings(
- this.state.title,
- this.state.invitation,
- this.state.welcomeMessage,
- this.state.cname
- );
- if (result.ok) {
- e.preventEnable();
- location.href = `/`;
- } else if (result.error) {
- this.setState({ error: result.error });
- }
- }
-
- public render() {
- return (
- <div className="page ui container">
- <h2 className="ui header">
- <i className="circular settings icon" />
- <div className="content">
- General Settings
- <div className="sub header">Manage your site settings</div>
- </div>
- </h2>
-
- <div className="ui grid">
- <div className="eight wide computer sixteen wide mobile column">
- <div className="ui form">
- <DisplayError fields={["title"]} error={this.state.error} />
- <div className="field">
- <label htmlFor="title">Title</label>
- <input
- id="title"
- type="text"
- maxLength={60}
- disabled={!this.props.user.isAdministrator}
- value={this.state.title}
- 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} />
- <div className="field">
- <label htmlFor="welcome-message">Welcome Message</label>
- <Textarea
- id="welcome-message"
- disabled={!this.props.user.isAdministrator}
- 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>
- </div>
- </div>
- <DisplayError fields={["invitation"]} error={this.state.error} />
- <div className="field">
- <label htmlFor="invitation">Invitation</label>
- <input
- id="invitation"
- type="text"
- maxLength={60}
- disabled={!this.props.user.isAdministrator}
- value={this.state.invitation}
- 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>
- </div>
- ]}
- {this.props.user.isAdministrator && (
- <div className="field">
- <Button color="green" size="large" onClick={async e => await this.confirm(e)}>
- Confirm
- </Button>
- </div>
- )}
- </div>
- </div>
- </div>
- </div>
- );
- }
-}
diff --git a/public/pages/AdminHome/index.ts b/public/pages/AdminHome/index.ts
deleted file mode 100644
index db6776489..000000000
--- a/public/pages/AdminHome/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./AdminHome.page";
diff --git a/public/pages/Administration/components/AdminBasePage.tsx b/public/pages/Administration/components/AdminBasePage.tsx
new file mode 100644
index 000000000..38fd9bcab
--- /dev/null
+++ b/public/pages/Administration/components/AdminBasePage.tsx
@@ -0,0 +1,31 @@
+import * as React from "react";
+import { SideMenu } from "./";
+
+export abstract class AdminBasePage<P, S> extends React.Component<P, S> {
+ public abstract name: string;
+ public abstract icon: string;
+ public abstract title: string;
+ public abstract subtitle: string;
+ public abstract content(): JSX.Element;
+
+ public render() {
+ return (
+ <div className="page ui container">
+ <h2 className="ui header">
+ <i className={`circular ${this.icon} icon`} />
+ <div className="content">
+ {this.title}
+ <div className="sub header">{this.subtitle}</div>
+ </div>
+ </h2>
+
+ <div className="ui grid">
+ <div className="three wide computer sixteen wide mobile column">
+ <SideMenu activeItem={this.name} />
+ </div>
+ <div className="thirteen wide computer sixteen wide mobile column">{this.content()}</div>
+ </div>
+ </div>
+ );
+ }
+}
diff --git a/public/pages/Administration/components/SideMenu.tsx b/public/pages/Administration/components/SideMenu.tsx
new file mode 100644
index 000000000..7ae9def30
--- /dev/null
+++ b/public/pages/Administration/components/SideMenu.tsx
@@ -0,0 +1,45 @@
+import * as React from "react";
+import { classSet } from "@fider/services";
+
+interface SiteMenuProps {
+ activeItem: string;
+}
+
+interface SideMenuItemProps {
+ name: string;
+ title: string;
+ isActive: boolean;
+ href: string;
+}
+
+const SideMenuItem = (props: SideMenuItemProps) => {
+ const className = classSet({
+ item: true,
+ active: props.isActive
+ });
+
+ if (props.isActive) {
+ return (
+ <span key={props.name} className={className}>
+ {props.title}
+ </span>
+ );
+ }
+
+ return (
+ <a key={props.name} className={className} href={props.href}>
+ {props.title}
+ </a>
+ );
+};
+
+export const SideMenu = (props: SiteMenuProps) => {
+ const activeItem = props.activeItem || "general";
+ return (
+ <div className="ui vertical menu fluid">
+ <SideMenuItem name="general" title="General" href="/admin" isActive={activeItem === "general"} />
+ <SideMenuItem name="members" title="Members" href="/admin/members" isActive={activeItem === "members"} />
+ <SideMenuItem name="tags" title="Tags" href="/admin/tags" isActive={activeItem === "tags"} />
+ </div>
+ );
+};
diff --git a/public/pages/ManageTags/components/TagForm.scss b/public/pages/Administration/components/TagForm.scss
similarity index 100%
rename from public/pages/ManageTags/components/TagForm.scss
rename to public/pages/Administration/components/TagForm.scss
diff --git a/public/pages/ManageTags/components/TagForm.tsx b/public/pages/Administration/components/TagForm.tsx
similarity index 100%
rename from public/pages/ManageTags/components/TagForm.tsx
rename to public/pages/Administration/components/TagForm.tsx
diff --git a/public/pages/Administration/components/index.tsx b/public/pages/Administration/components/index.tsx
new file mode 100644
index 000000000..892f51982
--- /dev/null
+++ b/public/pages/Administration/components/index.tsx
@@ -0,0 +1,3 @@
+export * from "./AdminBasePage";
+export * from "./SideMenu";
+export * from "./TagForm";
diff --git a/public/pages/Administration/index.ts b/public/pages/Administration/index.ts
new file mode 100644
index 000000000..d20f97aa4
--- /dev/null
+++ b/public/pages/Administration/index.ts
@@ -0,0 +1,3 @@
+export * from "./pages/GeneralSettings.page";
+export * from "./pages/ManageTags.page";
+export * from "./pages/ManageMembers.page";
diff --git a/public/pages/Administration/pages/GeneralSettings.page.tsx b/public/pages/Administration/pages/GeneralSettings.page.tsx
new file mode 100644
index 000000000..e26da1934
--- /dev/null
+++ b/public/pages/Administration/pages/GeneralSettings.page.tsx
@@ -0,0 +1,160 @@
+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 { AdminBasePage } from "../components";
+
+interface GeneralSettingsPageProps {
+ user: CurrentUser;
+ tenant: Tenant;
+ system: SystemSettings;
+}
+
+interface GeneralSettingsPageState {
+ title: string;
+ welcomeMessage: string;
+ invitation: string;
+ cname: string;
+ error?: Failure;
+}
+
+export class GeneralSettingsPage extends AdminBasePage<GeneralSettingsPageProps, GeneralSettingsPageState> {
+ public name = "general";
+ public icon = "settings";
+ public title = "General";
+ public subtitle = "Manage your site settings";
+
+ constructor(props: GeneralSettingsPageProps) {
+ super(props);
+
+ this.state = {
+ title: this.props.tenant.name,
+ cname: this.props.tenant.cname,
+ welcomeMessage: this.props.tenant.welcomeMessage,
+ invitation: this.props.tenant.invitation
+ };
+
+ page.setTitle(`General · Site Settings · ${document.title}`);
+ }
+
+ private async confirm(e: ButtonClickEvent) {
+ const result = await actions.updateTenantSettings(
+ this.state.title,
+ this.state.invitation,
+ this.state.welcomeMessage,
+ this.state.cname
+ );
+ if (result.ok) {
+ e.preventEnable();
+ location.href = `/`;
+ } else if (result.error) {
+ this.setState({ error: result.error });
+ }
+ }
+
+ public content() {
+ return (
+ <div className="ui form">
+ <DisplayError fields={["title"]} error={this.state.error} />
+ <div className="field">
+ <label htmlFor="title">Title</label>
+ <input
+ id="title"
+ type="text"
+ maxLength={60}
+ disabled={!this.props.user.isAdministrator}
+ value={this.state.title}
+ 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} />
+ <div className="field">
+ <label htmlFor="welcome-message">Welcome Message</label>
+ <Textarea
+ id="welcome-message"
+ disabled={!this.props.user.isAdministrator}
+ 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>
+ </div>
+ </div>
+ <DisplayError fields={["invitation"]} error={this.state.error} />
+ <div className="field">
+ <label htmlFor="invitation">Invitation</label>
+ <input
+ id="invitation"
+ type="text"
+ maxLength={60}
+ disabled={!this.props.user.isAdministrator}
+ value={this.state.invitation}
+ 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>
+ </div>
+ ]}
+ {this.props.user.isAdministrator && (
+ <div className="field">
+ <Button color="green" onClick={async e => await this.confirm(e)}>
+ Confirm
+ </Button>
+ </div>
+ )}
+ </div>
+ );
+ }
+}
diff --git a/public/pages/Administration/pages/ManageMembers.page.tsx b/public/pages/Administration/pages/ManageMembers.page.tsx
new file mode 100644
index 000000000..9e9512b16
--- /dev/null
+++ b/public/pages/Administration/pages/ManageMembers.page.tsx
@@ -0,0 +1,174 @@
+import * as React from "react";
+import { Button, Gravatar, UserName } from "@fider/components/common";
+import { User, CurrentUser, UserRole } from "@fider/models";
+import { page, actions } from "@fider/services";
+import { AdminBasePage } from "../components";
+
+interface ManageMembersPageState {
+ administrators: User[];
+ collaborators: User[];
+ visitors: User[];
+ filteredNewAdministrators: User[];
+ filteredNewCollaborators: User[];
+ newAdministratorFilter: string;
+ newCollaboratorFilter: string;
+}
+
+interface ManageMembersPageProps {
+ user: CurrentUser;
+ users: User[];
+}
+
+export class ManageMembersPage extends AdminBasePage<ManageMembersPageProps, ManageMembersPageState> {
+ public name = "members";
+ public icon = "users";
+ public title = "Members";
+ public subtitle = "Manage your site administrators and collaborators";
+
+ constructor(props: ManageMembersPageProps) {
+ super(props);
+ this.state = this.groupUsers();
+
+ page.setTitle(`Manage Members · Site Settings · ${document.title}`);
+ }
+
+ 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;
+ }, {});
+
+ 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;
+ }
+
+ 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>
+ </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);
+ }
+
+ if (property === "administrator") {
+ this.setState({
+ newAdministratorFilter: text,
+ filteredNewAdministrators: filtered
+ });
+ } else if (property === "collaborator") {
+ this.setState({
+ newCollaboratorFilter: text,
+ filteredNewCollaborators: filtered
+ });
+ }
+ }
+
+ public content() {
+ return (
+ <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>
+ </div>
+ </div>
+ );
+ }
+}
diff --git a/public/pages/ManageTags/ManageTags.page.scss b/public/pages/Administration/pages/ManageTags.page.scss
similarity index 90%
rename from public/pages/ManageTags/ManageTags.page.scss
rename to public/pages/Administration/pages/ManageTags.page.scss
index 60b835d1c..d5d7fd474 100644
--- a/public/pages/ManageTags/ManageTags.page.scss
+++ b/public/pages/Administration/pages/ManageTags.page.scss
@@ -1,4 +1,4 @@
-#p-manage-tags {
+#p-admin-tags {
.ui.list {
.item {
.content {
diff --git a/public/pages/ManageTags/ManageTags.page.tsx b/public/pages/Administration/pages/ManageTags.page.tsx
similarity index 72%
rename from public/pages/ManageTags/ManageTags.page.tsx
rename to public/pages/Administration/pages/ManageTags.page.tsx
index 6662d89b6..02dd3dc6d 100644
--- a/public/pages/ManageTags/ManageTags.page.tsx
+++ b/public/pages/Administration/pages/ManageTags.page.tsx
@@ -1,10 +1,9 @@
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 { ShowTag, Button, Gravatar, UserName } from "@fider/components";
+import { AdminBasePage, TagForm, TagFormState } from "../components";
-import { TagForm, TagFormState } from "./";
-import { actions, Failure } from "@fider/services";
+import { Tag, CurrentUser, UserRole } from "@fider/models";
+import { page, actions, Failure } from "@fider/services";
interface ManageTagsPageProps {
user: CurrentUser;
@@ -18,13 +17,20 @@ interface ManageTagsPageState {
editing?: number;
}
-export class ManageTagsPage extends React.Component<ManageTagsPageProps, ManageTagsPageState> {
+export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTagsPageState> {
+ public name = "tags";
+ public icon = "tags";
+ public title = "Tags";
+ public subtitle = "Manage your site tags";
+
constructor(props: ManageTagsPageProps) {
super(props);
this.state = {
isAdding: false,
allTags: this.props.tags
};
+
+ page.setTitle(`Manage Tags · Site Settings · ${document.title}`);
}
private async saveNewTag(data: TagFormState): Promise<Failure | undefined> {
@@ -65,8 +71,8 @@ export class ManageTagsPage extends React.Component<ManageTagsPageProps, ManageT
}
}
- public render() {
- const items = this.state.allTags.map(t => {
+ private getTagList() {
+ return this.state.allTags.map(t => {
if (this.state.editing === t.id) {
return (
<div key={t.id} className="item">
@@ -134,46 +140,41 @@ export class ManageTagsPage extends React.Component<ManageTagsPageProps, ManageT
</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>
+ public content() {
+ const list = this.getTagList();
- {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>
- ))}
+ const form =
+ 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>
+ ));
+ return (
+ <>
+ {form}
<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>}
+ {list.length ? list : <div className="content">There aren’t any tags yet.</div>}
</div>
</div>
- </div>
+ </>
);
}
}
diff --git a/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx b/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx
index 100fb5dae..1b6f8fb2e 100644
--- a/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx
+++ b/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx
@@ -49,7 +49,7 @@ export class CompleteSignInProfilePage extends React.Component<HomePageProps, Co
placeholder="Your display name"
className="small"
/>
- <Button onClick={() => this.submit()} size="small" color="green" disabled={this.state.name === ""}>
+ <Button onClick={() => this.submit()} color="green" disabled={this.state.name === ""}>
Submit
</Button>
</div>
diff --git a/public/pages/Home/Home.page.scss b/public/pages/Home/Home.page.scss
index 52ad610f9..5a5b60492 100644
--- a/public/pages/Home/Home.page.scss
+++ b/public/pages/Home/Home.page.scss
@@ -79,7 +79,7 @@
font-size: 18px;
background-color: $bg-color;
padding: 0px 0px 10px 0px;
- font-weight: bold;
+ font-weight: 700;
margin: 0px 0px 10px 0px;
border-radius: 0;
}
diff --git a/public/pages/ManageMembers/ManageMembers.page.tsx b/public/pages/ManageMembers/ManageMembers.page.tsx
deleted file mode 100644
index f7240c7d3..000000000
--- a/public/pages/ManageMembers/ManageMembers.page.tsx
+++ /dev/null
@@ -1,178 +0,0 @@
-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[];
- collaborators: User[];
- visitors: User[];
- filteredNewAdministrators: User[];
- filteredNewCollaborators: User[];
- newAdministratorFilter: string;
- newCollaboratorFilter: string;
-}
-
-interface ManageMembersPageProps {
- user: CurrentUser;
- users: User[];
-}
-
-export class ManageMembersPage extends React.Component<ManageMembersPageProps, ManageMembersPageState> {
- 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 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: ""
- };
- }
-
- 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>
- </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);
- }
-
- if (property === "administrator") {
- this.setState({
- newAdministratorFilter: text,
- filteredNewAdministrators: filtered
- });
- } else if (property === "collaborator") {
- this.setState({
- newCollaboratorFilter: text,
- filteredNewCollaborators: filtered
- });
- }
- }
-
- 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="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>
- </div>
- </div>
- </div>
- );
- }
-}
diff --git a/public/pages/ManageMembers/index.ts b/public/pages/ManageMembers/index.ts
deleted file mode 100644
index 5fb42f75f..000000000
--- a/public/pages/ManageMembers/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./ManageMembers.page";
diff --git a/public/pages/ManageTags/index.ts b/public/pages/ManageTags/index.ts
deleted file mode 100644
index 2b25a9ba0..000000000
--- a/public/pages/ManageTags/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./ManageTags.page";
-export * from "./components/TagForm";
diff --git a/public/pages/MySettings/MySettings.page.tsx b/public/pages/MySettings/MySettings.page.tsx
index f1d9fe934..18d8952ae 100644
--- a/public/pages/MySettings/MySettings.page.tsx
+++ b/public/pages/MySettings/MySettings.page.tsx
@@ -169,7 +169,7 @@ export class MySettingsPage extends React.Component<MySettingsPageProps, MySetti
/>
<div className="field">
- <Button color="green" size="large" onClick={async () => await this.confirm()}>
+ <Button color="green" onClick={async () => await this.confirm()}>
Confirm
</Button>
</div>
diff --git a/public/pages/ShowIdea/ShowIdea.page.tsx b/public/pages/ShowIdea/ShowIdea.page.tsx
index d6a9fc52b..a9463cb6e 100644
--- a/public/pages/ShowIdea/ShowIdea.page.tsx
+++ b/public/pages/ShowIdea/ShowIdea.page.tsx
@@ -125,16 +125,12 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag
this.state.editMode ? (
<div key={1} className="ui list">
<div className="item">
- <Button color="green" size="small" fluid={true} onClick={async () => this.saveChanges()}>
+ <Button color="green" fluid={true} onClick={async () => this.saveChanges()}>
<i className="save icon" /> Save
</Button>
</div>
<div className="item">
- <Button
- fluid={true}
- size="small"
- onClick={async () => this.setState({ error: undefined, editMode: false })}
- >
+ <Button fluid={true} onClick={async () => this.setState({ error: undefined, editMode: false })}>
<i className="cancel icon" /> Cancel
</Button>
</div>
@@ -142,7 +138,7 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag
) : (
<div key={1} className="ui list">
<div className="item">
- <Button fluid={true} size="small" onClick={async () => this.setState({ editMode: true })}>
+ <Button fluid={true} onClick={async () => this.setState({ editMode: true })}>
<i className="edit icon" /> Edit
</Button>
</div>
diff --git a/public/pages/ShowIdea/components/CommentList.tsx b/public/pages/ShowIdea/components/CommentList.tsx
index 29c0e96ff..705191961 100644
--- a/public/pages/ShowIdea/components/CommentList.tsx
+++ b/public/pages/ShowIdea/components/CommentList.tsx
@@ -96,7 +96,7 @@ export class CommentList extends React.Component<CommentListProps, CommentListSt
{this.canEditComment(c) && (
<div className="metadata">
·{" "}
- <Button simple={true} size="small" onClick={() => this.startEdit(c)}>
+ <Button simple={true} onClick={() => this.startEdit(c)}>
edit
</Button>
</div>
diff --git a/public/pages/ShowIdea/components/NotificationsPanel.tsx b/public/pages/ShowIdea/components/NotificationsPanel.tsx
index 0891c0317..c0ab53a54 100644
--- a/public/pages/ShowIdea/components/NotificationsPanel.tsx
+++ b/public/pages/ShowIdea/components/NotificationsPanel.tsx
@@ -36,11 +36,11 @@ export class NotificationsPanel extends React.Component<NotificationsPanelProps,
}
const button = this.state.subscribed ? (
- <Button size="small" fluid={true} onClick={this.subscribeOrUnsubscribe}>
+ <Button fluid={true} onClick={this.subscribeOrUnsubscribe}>
<i className="volume off icon" /> Unsubscribe
</Button>
) : (
- <Button size="small" fluid={true} onClick={this.subscribeOrUnsubscribe}>
+ <Button fluid={true} onClick={this.subscribeOrUnsubscribe}>
<i className="volume up icon" /> Subscribe
</Button>
);
diff --git a/public/pages/ShowIdea/components/ResponseForm.tsx b/public/pages/ShowIdea/components/ResponseForm.tsx
index 13eac38cc..38a0f3be3 100644
--- a/public/pages/ShowIdea/components/ResponseForm.tsx
+++ b/public/pages/ShowIdea/components/ResponseForm.tsx
@@ -45,7 +45,7 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor
public render() {
const button = (
- <Button className="respond" size="small" fluid={true} onClick={async () => this.setState({ showModal: true })}>
+ <Button className="respond" fluid={true} onClick={async () => this.setState({ showModal: true })}>
<i className="announcement icon" /> Respond
</Button>
);
diff --git a/public/pages/index.ts b/public/pages/index.ts
index f35ae87ac..37603a26d 100644
--- a/public/pages/index.ts
+++ b/public/pages/index.ts
@@ -1,8 +1,6 @@
export * from "./Home";
-export * from "./AdminHome";
+export * from "./Administration";
export * from "./SignUp";
-export * from "./ManageMembers";
-export * from "./ManageTags";
export * from "./CompleteSignInProfile";
export * from "./MySettings";
export * from "./MyNotifications";
diff --git a/public/router.tsx b/public/router.tsx
index 966c2d299..6fb16403c 100644
--- a/public/router.tsx
+++ b/public/router.tsx
@@ -5,7 +5,7 @@ import {
SignUpPage,
ManageMembersPage,
CompleteSignInProfilePage,
- AdminHomePage,
+ GeneralSettingsPage,
ManageTagsPage,
ShowIdeaPage,
MySettingsPage,
@@ -32,9 +32,9 @@ const route = (path: string, component: any, id: string, showHeader: boolean): P
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("/admin/members", ManageMembersPage, "p-admin-members", true),
+ route("/admin/tags", ManageTagsPage, "p-admin-tags", true),
+ route("/admin", GeneralSettingsPage, "p-admin-general", true),
route("/signup", SignUpPage, "p-signup", false),
route("/signin/verify", CompleteSignInProfilePage, "p-complete-signin-profile", true),
route("/notifications", MyNotificationsPage, "p-my-notifications", true),