Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

enhancement: group tags by visibility + order by name (#389)

Guilherme Oenningfb1ec5120a14
diff --git a/app/storage/postgres/tag.go b/app/storage/postgres/tag.go
index 639a707d2..5dbcc6f8e 100644
--- a/app/storage/postgres/tag.go
+++ b/app/storage/postgres/tag.go
@@ -151,6 +151,7 @@ func (s *TagStorage) GetAssigned(idea *models.Idea) ([]*models.Tag, error) {
ON it.tag_id = t.id
AND it.tenant_id = t.tenant_id
WHERE it.idea_id = $1 AND t.tenant_id = $2
+ ORDER BY t.name
`, idea.ID, s.tenant.ID)
if err != nil {
@@ -170,6 +171,7 @@ func (s *TagStorage) GetAll() ([]*models.Tag, error) {
SELECT t.id, t.name, t.slug, t.color, t.is_public
FROM tags t
WHERE t.tenant_id = $1 %s
+ ORDER BY t.name
`, condition)
tags, err := s.getTags(query, s.tenant.ID)
if err != nil {
diff --git a/app/storage/postgres/tag_test.go b/app/storage/postgres/tag_test.go
index 75a3cca0b..9d381ba69 100644
--- a/app/storage/postgres/tag_test.go
+++ b/app/storage/postgres/tag_test.go
@@ -133,16 +133,16 @@ func TestTagStorage_GetAll(t *testing.T) {
Expect(allTags).HasLen(2)
Expect(allTags[0].ID).NotEquals(0)
- Expect(allTags[0].Name).Equals("Feature Request")
- Expect(allTags[0].Slug).Equals("feature-request")
- Expect(allTags[0].Color).Equals("FF0000")
- Expect(allTags[0].IsPublic).IsTrue()
+ Expect(allTags[0].Name).Equals("Bug")
+ Expect(allTags[0].Slug).Equals("bug")
+ Expect(allTags[0].Color).Equals("0F0F0F")
+ Expect(allTags[0].IsPublic).IsFalse()
Expect(allTags[1].ID).NotEquals(0)
- Expect(allTags[1].Name).Equals("Bug")
- Expect(allTags[1].Slug).Equals("bug")
- Expect(allTags[1].Color).Equals("0F0F0F")
- Expect(allTags[1].IsPublic).IsFalse()
+ Expect(allTags[1].Name).Equals("Feature Request")
+ Expect(allTags[1].Slug).Equals("feature-request")
+ Expect(allTags[1].Color).Equals("FF0000")
+ Expect(allTags[1].IsPublic).IsTrue()
tags.SetCurrentUser(aryaStark)
diff --git a/public/assets/styles/main.scss b/public/assets/styles/main.scss
index b7814b2a1..e84f9a8c3 100644
--- a/public/assets/styles/main.scss
+++ b/public/assets/styles/main.scss
@@ -198,7 +198,7 @@ h1, h2, h3, h4, h5 {
}
.subtitle {
- font-size: $font-size-tiny;
+ font-size: $font-size-mini;
margin-bottom: 5px;
font-weight: 600;
letter-spacing: .3px;
diff --git a/public/assets/styles/variables.scss b/public/assets/styles/variables.scss
index 64b465861..726ff440c 100644
--- a/public/assets/styles/variables.scss
+++ b/public/assets/styles/variables.scss
@@ -1,7 +1,7 @@
$font-size-micro: 9px;
-$font-size-mini: 10px;
-$font-size-tiny: 11px;
-$font-size-small: 12px;
+$font-size-mini: 11px;
+$font-size-tiny: 12px;
+$font-size-small: 13px;
$font-size: 14px;
$font-size-large: 16px;
$font-size-big: 18px;
diff --git a/public/components/ShowTag.scss b/public/components/ShowTag.scss
index 7db28fd3c..ba8a12bc1 100644
--- a/public/components/ShowTag.scss
+++ b/public/components/ShowTag.scss
@@ -4,15 +4,16 @@
display: inline-block;
line-height: 1;
vertical-align: baseline;
- margin: 0 3px;
+ margin: 0 3px 3px 0;
padding: 9px 12px;
color: $text-color;
font-weight: 700;
border: 0;
border-radius: 5px;
- &:first-child {
- margin-left: 0;
+ &:last-child {
+ margin-top: 0;
+ margin-bottom: 0;
}
&.m-circular {
diff --git a/public/components/common/Header.scss b/public/components/common/Header.scss
index d16bd2483..89b8f9b80 100644
--- a/public/components/common/Header.scss
+++ b/public/components/common/Header.scss
@@ -91,10 +91,11 @@
background-color: $menu-color;
box-shadow: 0 1px 3px 0 rgba(0,0,0,.08);
border: 1px solid rgba(34,36,38,.15);
- width: 160px;
+ min-width: 160px;
border-radius: 0px 0px 5px 5px;
.c-menu-user-heading {
+ white-space: nowrap;
font-size: $font-size-mini;
padding: 10px;
display: block;
diff --git a/public/components/common/Heading.scss b/public/components/common/Heading.scss
index 84ad6679b..13ba29066 100644
--- a/public/components/common/Heading.scss
+++ b/public/components/common/Heading.scss
@@ -4,9 +4,9 @@
margin-bottom: 10px;
.c-heading-content {
- padding-left: 10px;
display: table-cell;
vertical-align: middle;
+
.c-heading-subtitle {
font-weight: 400;
margin-top: 5px;
@@ -14,6 +14,10 @@
font-size: $font-size;
}
}
+
+ .c-heading-icon + .c-heading-content {
+ padding-left: 10px;
+ }
.c-heading-icon {
font-size: 30px;
@@ -26,4 +30,10 @@
padding-bottom: 5px;
margin-bottom: 10px;
}
+
+ &.m-small {
+ .c-heading-subtitle {
+ font-size: $font-size-small;
+ }
+ }
}
\ No newline at end of file
diff --git a/public/components/common/Heading.tsx b/public/components/common/Heading.tsx
index 90a3a22ca..0162edb4f 100644
--- a/public/components/common/Heading.tsx
+++ b/public/components/common/Heading.tsx
@@ -6,17 +6,19 @@ import { classSet } from "@fider/services";
interface HeadingLogo {
title: string;
dividing?: boolean;
- level?: 1 | 2 | 3 | 4 | 5;
+ size?: "normal" | "small";
icon?: string;
subtitle?: string;
}
export const Heading = (props: HeadingLogo) => {
- const level = props.level || 2;
+ const size = props.size || "normal";
+ const level = size === "normal" ? 2 : 3;
const Tag = `h${level}`;
const className = classSet({
"c-heading": true,
- "m-dividing": props.dividing || false
+ "m-dividing": props.dividing || false,
+ [`m-${size}`]: true
});
const iconClassName = classSet({
@@ -28,7 +30,7 @@ export const Heading = (props: HeadingLogo) => {
return (
<Tag className={className}>
- <i className={iconClassName} />
+ {props.icon && <i className={iconClassName} />}
<div className="c-heading-content">
{props.title}
<div className="c-heading-subtitle">{props.subtitle}</div>
diff --git a/public/pages/Administration/pages/ManageTags.page.tsx b/public/pages/Administration/pages/ManageTags.page.tsx
index eff9dcb3a..6d8a42859 100644
--- a/public/pages/Administration/pages/ManageTags.page.tsx
+++ b/public/pages/Administration/pages/ManageTags.page.tsx
@@ -1,7 +1,7 @@
import "./ManageTags.page.scss";
import * as React from "react";
-import { ShowTag, Button, Gravatar, UserName, Segment, List, ListItem } from "@fider/components";
+import { ShowTag, Button, Gravatar, UserName, Segment, List, ListItem, Heading } from "@fider/components";
import { AdminBasePage, TagForm, TagFormState } from "../components";
import { Tag, CurrentUser, UserRole } from "@fider/models";
@@ -19,6 +19,15 @@ interface ManageTagsPageState {
editing?: number;
}
+const tagSorter = (t1: Tag, t2: Tag) => {
+ if (t1.name < t2.name) {
+ return -1;
+ } else if (t1.name > t2.name) {
+ return 1;
+ }
+ return 0;
+};
+
export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTagsPageState> {
public id = "p-admin-tags";
public name = "tags";
@@ -39,7 +48,7 @@ export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTag
if (result.ok) {
this.setState({
isAdding: false,
- allTags: this.state.allTags.concat(result.data)
+ allTags: this.state.allTags.concat(result.data).sort(tagSorter)
});
} else {
return result.error;
@@ -54,7 +63,8 @@ export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTag
tag.color = result.data.color;
tag.isPublic = result.data.isPublic;
this.setState({
- editing: undefined
+ editing: undefined,
+ allTags: this.state.allTags.sort(tagSorter)
});
} else {
return result.error;
@@ -72,8 +82,8 @@ export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTag
}
}
- private getTagList() {
- return this.state.allTags.map(t => {
+ private getTagList(filter: (tag: Tag) => boolean) {
+ return this.state.allTags.filter(filter).map(t => {
if (this.state.editing === t.id) {
return (
<ListItem key={t.id}>
@@ -144,7 +154,8 @@ export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTag
}
public content() {
- const list = this.getTagList();
+ const publicTaglist = this.getTagList(t => t.isPublic);
+ const privateTagList = this.getTagList(t => !t.isPublic);
const form =
this.props.user.isAdministrator &&
@@ -171,7 +182,25 @@ export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTag
<>
{form}
<Segment>
- <List divided={true}>{list.length ? list : <div className="content">There aren’t any tags yet.</div>}</List>
+ <List divided={true}>
+ <ListItem>
+ <Heading size="small" title="Public Tags" subtitle="These tags are visible to all visitors." />
+ </ListItem>
+ {publicTaglist.length === 0 ? <ListItem>There aren’t any public tags yet.</ListItem> : publicTaglist}
+ </List>
+ </Segment>
+
+ <Segment>
+ <List divided={true}>
+ <ListItem>
+ <Heading
+ size="small"
+ title="Private Tags"
+ subtitle="These tags are only visible for members of this site."
+ />
+ </ListItem>
+ {privateTagList.length === 0 ? <ListItem>There aren’t any private tags yet.</ListItem> : privateTagList}
+ </List>
</Segment>
</>
);
diff --git a/public/pages/Home/Home.page.scss b/public/pages/Home/Home.page.scss
index 915ba8cf3..96cb05aeb 100644
--- a/public/pages/Home/Home.page.scss
+++ b/public/pages/Home/Home.page.scss
@@ -28,7 +28,7 @@
font-weight: normal;
}
.c-tag {
- margin-right: 5px;
+ margin: 0 5px 0 0;
}
i.check {
color: transparent;
diff --git a/public/pages/Home/components/IdeasContainer.tsx b/public/pages/Home/components/IdeasContainer.tsx
index 59e553af6..0e1c082b8 100644
--- a/public/pages/Home/components/IdeasContainer.tsx
+++ b/public/pages/Home/components/IdeasContainer.tsx
@@ -88,7 +88,7 @@ export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasCo
title="Similar ideas"
subtitle="Consider voting on existing ideas before posting a new one."
icon="lightbulb"
- level={3}
+ size="small"
dividing={true}
/>
{this.state.loading ? (
diff --git a/public/pages/UI/UIToolkit.page.tsx b/public/pages/UI/UIToolkit.page.tsx
index bbdae3588..2a2f9bab1 100644
--- a/public/pages/UI/UIToolkit.page.tsx
+++ b/public/pages/UI/UIToolkit.page.tsx
@@ -91,7 +91,13 @@ export class UIToolkitPage extends React.Component<{}, UIToolkitPageState> {
<Heading title="Page Heading" icon="settings" subtitle="This is a page heading" />
- <Heading title="Section Heading" icon="lightbulb" subtitle="This is a page heading" level={3} dividing={true} />
+ <Heading
+ title="Section Heading"
+ icon="lightbulb"
+ subtitle="This is a page heading"
+ size="small"
+ dividing={true}
+ />
<h1>Buttons</h1>
<List>