Skip to content

Commit

Permalink
UX: show date of last edit on wiki topics
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogStriP committed Sep 12, 2017
1 parent 07bfe3d commit 85ef369
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/discourse/lib/transform-post.js.es6
Expand Up @@ -35,6 +35,7 @@ export function transformBasicPost(post) {
primary_group_flair_bg_color: post.primary_group_flair_bg_color,
primary_group_flair_color: post.primary_group_flair_color,
wiki: post.wiki,
lastWikiEdit: post.last_wiki_edit,
firstPost: post.post_number === 1,
post_number: post.post_number,
cooked: post.cooked,
Expand Down
23 changes: 13 additions & 10 deletions app/assets/javascripts/discourse/widgets/post.js.es6
Expand Up @@ -171,19 +171,22 @@ createWidget('post-meta-data', {
}, iconNode('eye-slash')));
}

const lastWikiEdit = attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
const createdAt = new Date(attrs.created_at);
if (createdAt) {
result.push(h('div.post-info',
h('a.post-date', {
attributes: {
href: attrs.shareUrl,
'data-share-url': attrs.shareUrl,
'data-post-number': attrs.post_number,
}
}, dateNode(createdAt))
));
const date = lastWikiEdit ? dateNode(lastWikiEdit) : dateNode(createdAt);
const attributes = {
class: "post-date",
href: attrs.shareUrl,
'data-share-url': attrs.shareUrl,
'data-post-number': attrs.post_number
};

if (lastWikiEdit) {
attributes["class"] += " last-wiki-edit";
}

result.push(h('div.post-info', h('a', { attributes }, date)));

if (attrs.via_email) {
result.push(this.attach('post-email-indicator', attrs));
}
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/common/base/topic-post.scss
Expand Up @@ -247,7 +247,8 @@ aside.quote {
}
}

.wiki {
.wiki,
.last-wiki-edit {
color: green !important;
}

Expand Down
11 changes: 10 additions & 1 deletion app/serializers/post_serializer.rb
Expand Up @@ -68,7 +68,8 @@ class PostSerializer < BasicPostSerializer
:via_email,
:is_auto_generated,
:action_code,
:action_code_who
:action_code_who,
:last_wiki_edit

def initialize(object, opts)
super(object, opts)
Expand Down Expand Up @@ -353,6 +354,14 @@ def include_action_code_who?
include_action_code? && action_code_who.present?
end

def last_wiki_edit
object.revisions.last.updated_at
end

def include_last_wiki_edit?
object.wiki && object.post_number == 1
end

private

def post_actions
Expand Down

1 comment on commit 85ef369

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/installing-discourse-with-dokku-on-subfolder/69558/8

Please sign in to comment.