PLT-7379: Timestamp on deleted, ephemeral, or pending post is a permalink (#7295)

* Removed permalink from system messages, general cleanup

* Removed permalink from deleted messages

* Removed permalink from pending messages

* Fixed post_info tests

* Changed permalink logic to remove permalinks from ephemeral messages, but leave them in place for system messages.

* Fixed check style
Этот коммит содержится в:
Jonathan
2017-08-30 08:06:29 -04:00
коммит произвёл Saturnino Abril
родитель 213a072b38
Коммит 4c1f467442
4 изменённых файлов: 35 добавлений и 17 удалений

Просмотреть файл

@@ -9,7 +9,7 @@ import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
export function isSystemMessage(post) {
return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0);
return Boolean(post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0));
}
export function isFromWebhook(post) {
@@ -53,11 +53,11 @@ export function getProfilePicSrcForPost(post, user) {
}
export function canDeletePost(post) {
var isOwner = isPostOwner(post);
var isSystemAdmin = UserStore.isSystemAdminForCurrentUser();
var isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam() || isSystemAdmin;
var isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel() || isTeamAdmin;
var isAdmin = isChannelAdmin || isTeamAdmin || isSystemAdmin;
const isOwner = isPostOwner(post);
const isSystemAdmin = UserStore.isSystemAdminForCurrentUser();
const isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam() || isSystemAdmin;
const isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel() || isTeamAdmin;
const isAdmin = isChannelAdmin || isTeamAdmin || isSystemAdmin;
if (global.window.mm_license.IsLicensed === 'true') {
return (global.window.mm_config.RestrictPostDelete === Constants.PERMISSIONS_DELETE_POST_ALL && (isOwner || isChannelAdmin)) ||
@@ -69,15 +69,14 @@ export function canDeletePost(post) {
}
export function canEditPost(post, editDisableAction) {
var isOwner = isPostOwner(post);
var canEdit = isOwner && !isSystemMessage(post);
const isOwner = isPostOwner(post);
let canEdit = isOwner && !isSystemMessage(post);
if (canEdit && global.window.mm_license.IsLicensed === 'true') {
if (global.window.mm_config.AllowEditPost === Constants.ALLOW_EDIT_POST_NEVER) {
canEdit = false;
} else if (global.window.mm_config.AllowEditPost === Constants.ALLOW_EDIT_POST_TIME_LIMIT) {
var timeLeft = (post.create_at + (global.window.mm_config.PostEditTimeLimit * 1000)) - Utils.getTimestamp();
const timeLeft = (post.create_at + (global.window.mm_config.PostEditTimeLimit * 1000)) - Utils.getTimestamp();
if (timeLeft > 0) {
editDisableAction.fireAfter(timeLeft + 1000);
} else {