From 0ca385deaf00d905081c66d0e0164558531e0e70 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 3 Apr 2020 13:46:25 -0400 Subject: Adding a text body preview and icon for posts with a body. Fixes #617 --- ui/src/components/post-listing.tsx | 20 ++++++++++++++++++++ ui/src/components/symbols.tsx | 3 +++ ui/src/utils.ts | 8 ++++++++ 3 files changed, 31 insertions(+) (limited to 'ui/src') diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index ff863dcb..101d1807 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -20,6 +20,7 @@ import { MomentTime } from './moment-time'; import { PostForm } from './post-form'; import { IFramelyCard } from './iframely-card'; import { + md, mdToHtml, canMod, isMod, @@ -30,6 +31,7 @@ import { showAvatars, pictshareImage, setupTippy, + previewLines, } from '../utils'; import { i18n } from '../i18next'; @@ -459,6 +461,24 @@ export class PostListing extends Component { + {post.body && ( + <> +
  • +
  • + {/* Using a link with tippy doesn't work on touch devices unfortunately */} + + + + + +
  • + + )}
  • {this.state.upvotes !== this.state.score && ( <> diff --git a/ui/src/components/symbols.tsx b/ui/src/components/symbols.tsx index 16deec3e..dae734a8 100644 --- a/ui/src/components/symbols.tsx +++ b/ui/src/components/symbols.tsx @@ -15,6 +15,9 @@ export class Symbols extends Component { xmlnsXlink="http://www.w3.org/1999/xlink" > + + + diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 8ecef19b..d659509c 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -823,3 +823,11 @@ function hsl(num: number) { function randomHsl() { return `hsla(${Math.random() * 360}, 100%, 50%, 1)`; } + +export function previewLines(text: string, lines: number = 3): string { + // Use lines * 2 because markdown requires 2 lines + return text + .split('\n') + .slice(0, lines * 2) + .join('\n'); +} -- cgit v1.2.3 From cb49a7e79044a76cabf8660e330294b2f370491c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 3 Apr 2020 14:44:30 -0400 Subject: Version v0.6.45 --- ui/src/version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/src') diff --git a/ui/src/version.ts b/ui/src/version.ts index fdf2c347..f0847f75 100644 --- a/ui/src/version.ts +++ b/ui/src/version.ts @@ -1 +1 @@ -export const version: string = 'v0.6.44'; +export const version: string = 'v0.6.45'; -- cgit v1.2.3 From 221e35ec38fb9323bf0b0ca1d19dac7884fb79fa Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 5 Apr 2020 10:11:16 -0400 Subject: Try to fix post creation bug. --- ui/src/components/post.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/src') diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index f51ba6ff..de0f0e32 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -460,7 +460,7 @@ export class Post extends Component { } else if (res.op == UserOperation.Search) { let data = res.data as SearchResponse; this.state.crossPosts = data.posts.filter( - p => p.id != this.state.post.id + p => p.id != Number(this.props.match.params.id) ); this.setState(this.state); } else if (res.op == UserOperation.TransferSite) { -- cgit v1.2.3 From ed264aba3c12243352f68c2de6a5f21f23778bd0 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Apr 2020 16:11:11 -0400 Subject: Updating code url references to https://github.com/LemmyNet/lemmy --- ui/src/components/sponsors.tsx | 3 ++- ui/src/utils.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/sponsors.tsx b/ui/src/components/sponsors.tsx index 347cb718..643153e6 100644 --- a/ui/src/components/sponsors.tsx +++ b/ui/src/components/sponsors.tsx @@ -2,6 +2,7 @@ import { Component } from 'inferno'; import { WebSocketService } from '../services'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; +import { repoUrl } from '../utils'; let general = [ 'Nathan J. Goode', @@ -44,7 +45,7 @@ export class Sponsors extends Component {
    {i18n.t('donate_to_lemmy')}

    - ## + ##

    diff --git a/ui/src/utils.ts b/ui/src/utils.ts index d659509c..ceb05764 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -44,7 +44,7 @@ import emojiShortName from 'emoji-short-name'; import Toastify from 'toastify-js'; import tippy from 'tippy.js'; -export const repoUrl = 'https://github.com/dessalines/lemmy'; +export const repoUrl = 'https://github.com/LemmyNet/lemmy'; export const helpGuideUrl = '/docs/about_guide.html'; export const markdownHelpUrl = `${helpGuideUrl}#markdown-guide`; export const sortingHelpUrl = `${helpGuideUrl}#sorting`; -- cgit v1.2.3 From bb287cbd076940bd09f6afb61b642370d020f91e Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 10 Apr 2020 16:55:57 -0400 Subject: Adding an admin settings page. - Fixes #620 - Adding a UserListing component. Fixes #627 --- ui/src/components/admin-settings.tsx | 241 +++++++++++++++++++++++++++++ ui/src/components/comment-node.tsx | 27 ++-- ui/src/components/main.tsx | 24 +-- ui/src/components/navbar.tsx | 26 ++++ ui/src/components/post-listing.tsx | 23 +-- ui/src/components/private-message-form.tsx | 25 +-- ui/src/components/private-message.tsx | 1 + ui/src/components/search.tsx | 23 +-- ui/src/components/sidebar.tsx | 21 +-- ui/src/components/site-form.tsx | 7 + ui/src/components/symbols.tsx | 3 + ui/src/components/user-listing.tsx | 36 +++++ ui/src/index.tsx | 116 +++++++------- ui/src/interfaces.ts | 22 ++- ui/src/services/WebSocketService.ts | 13 ++ 15 files changed, 453 insertions(+), 155 deletions(-) create mode 100644 ui/src/components/admin-settings.tsx create mode 100644 ui/src/components/user-listing.tsx (limited to 'ui/src') diff --git a/ui/src/components/admin-settings.tsx b/ui/src/components/admin-settings.tsx new file mode 100644 index 00000000..56af7114 --- /dev/null +++ b/ui/src/components/admin-settings.tsx @@ -0,0 +1,241 @@ +import { Component, linkEvent } from 'inferno'; +import { Subscription } from 'rxjs'; +import { retryWhen, delay, take } from 'rxjs/operators'; +import { + UserOperation, + SiteResponse, + GetSiteResponse, + SiteConfigForm, + GetSiteConfigResponse, + WebSocketJsonResponse, +} from '../interfaces'; +import { WebSocketService } from '../services'; +import { wsJsonToRes, capitalizeFirstLetter, toast, randomStr } from '../utils'; +import autosize from 'autosize'; +import { SiteForm } from './site-form'; +import { UserListing } from './user-listing'; +import { i18n } from '../i18next'; + +interface AdminSettingsState { + siteRes: GetSiteResponse; + siteConfigRes: GetSiteConfigResponse; + siteConfigForm: SiteConfigForm; + loading: boolean; + siteConfigLoading: boolean; +} + +export class AdminSettings extends Component { + private siteConfigTextAreaId = `site-config-${randomStr()}`; + private subscription: Subscription; + private emptyState: AdminSettingsState = { + siteRes: { + site: { + id: null, + name: null, + creator_id: null, + creator_name: null, + published: null, + number_of_users: null, + number_of_posts: null, + number_of_comments: null, + number_of_communities: null, + enable_downvotes: null, + open_registration: null, + enable_nsfw: null, + }, + admins: [], + banned: [], + online: null, + }, + siteConfigForm: { + config_hjson: null, + auth: null, + }, + siteConfigRes: { + config_hjson: null, + }, + loading: true, + siteConfigLoading: null, + }; + + constructor(props: any, context: any) { + super(props, context); + + this.state = this.emptyState; + + this.subscription = WebSocketService.Instance.subject + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) + .subscribe( + msg => this.parseMessage(msg), + err => console.error(err), + () => console.log('complete') + ); + + WebSocketService.Instance.getSite(); + WebSocketService.Instance.getSiteConfig(); + } + + componentWillUnmount() { + this.subscription.unsubscribe(); + } + + render() { + return ( +
    + {this.state.loading ? ( +
    + + + +
    + ) : ( +
    +
    + + {this.admins()} + {this.bannedUsers()} +
    +
    {this.adminSettings()}
    +
    + )} +
    + ); + } + + admins() { + return ( + <> +
    {capitalizeFirstLetter(i18n.t('admins'))}
    +
      + {this.state.siteRes.admins.map(admin => ( +
    • + +
    • + ))} +
    + + ); + } + + bannedUsers() { + return ( + <> +
    {i18n.t('banned_users')}
    +
      + {this.state.siteRes.banned.map(banned => ( +
    • + +
    • + ))} +
    + + ); + } + + adminSettings() { + return ( +
    +
    {i18n.t('admin_settings')}
    +
    +
    + +
    +