diff --git a/frontend/apps/remark42/app/__stubs__/static-config.ts b/frontend/apps/remark42/app/__stubs__/static-config.ts index 2145a475..d96b9f5d 100644 --- a/frontend/apps/remark42/app/__stubs__/static-config.ts +++ b/frontend/apps/remark42/app/__stubs__/static-config.ts @@ -8,6 +8,7 @@ beforeEach(() => { critical_score: -15, low_score: -5, edit_duration: 300, + admin_edit: false, max_comment_size: 3000, max_image_size: 5000, positive_score: false, diff --git a/frontend/apps/remark42/app/common/static-store.ts b/frontend/apps/remark42/app/common/static-store.ts index bced7b79..66d024c5 100644 --- a/frontend/apps/remark42/app/common/static-store.ts +++ b/frontend/apps/remark42/app/common/static-store.ts @@ -15,6 +15,7 @@ export const StaticStore: StaticStoreType = { config: { version: '', edit_duration: 5000, + admin_edit: false, max_comment_size: 5000, admins: [], admin_email: '', diff --git a/frontend/apps/remark42/app/common/types.ts b/frontend/apps/remark42/app/common/types.ts index fd18f8eb..1bacffbd 100644 --- a/frontend/apps/remark42/app/common/types.ts +++ b/frontend/apps/remark42/app/common/types.ts @@ -109,6 +109,7 @@ export interface Config { version: string; auth_providers: Provider[]; edit_duration: number; + admin_edit: boolean; max_comment_size: number; admins: string[]; admin_email: string; diff --git a/frontend/apps/remark42/app/components/comment/comment-actions.tsx b/frontend/apps/remark42/app/components/comment/comment-actions.tsx index d3fca73e..966eea14 100644 --- a/frontend/apps/remark42/app/components/comment/comment-actions.tsx +++ b/frontend/apps/remark42/app/components/comment/comment-actions.tsx @@ -73,13 +73,15 @@ export function CommentActions({ - - - + {Number.isFinite(editDeadline) && ( + + + + )} )}
{ // set comment edit timer if (this.isCurrentUser()) { - const editDuration = StaticStore.config.edit_duration; - const timeDiff = StaticStore.serverClientTimeDiff || 0; - const editDeadline = new Date(props.data.time).getTime() + timeDiff + editDuration * 1000; + if (this.isAdmin() && StaticStore.config.admin_edit) { + newState.editDeadline = Infinity; + } else { + const editDuration = StaticStore.config.edit_duration; + const timeDiff = StaticStore.serverClientTimeDiff || 0; + const editDeadline = new Date(props.data.time).getTime() + timeDiff + editDuration * 1000; - newState.editDeadline = editDeadline > Date.now() ? editDeadline : undefined; + newState.editDeadline = editDeadline > Date.now() ? editDeadline : undefined; + } } return newState; @@ -488,7 +492,10 @@ export class Comment extends Component { copied={state.isCopied} editing={isEditing} replying={isReplying} - editable={props.repliesCount === 0 && state.editDeadline !== undefined} + editable={ + state.editDeadline !== undefined && + (props.repliesCount === 0 || (isAdmin && StaticStore.config.admin_edit)) + } editDeadline={state.editDeadline} readOnly={props.post_info?.read_only} onToggleReplying={this.toggleReplying} diff --git a/frontend/packages/api/clients/public.ts b/frontend/packages/api/clients/public.ts index 00501412..5c6ab432 100644 --- a/frontend/packages/api/clients/public.ts +++ b/frontend/packages/api/clients/public.ts @@ -6,6 +6,7 @@ export interface Config { version: string auth_providers: Provider[] edit_duration: number + admin_edit: boolean max_comment_size: number admins: string[] admin_email: string @@ -103,7 +104,7 @@ export function createPublicClient({ siteId: site, baseUrl }: ClientParams) { async function getComments(url: string): Promise async function getComments(params: GetUserCommentsParams): Promise async function getComments( - params: string | GetUserCommentsParams + params: string | GetUserCommentsParams, ): Promise { if (typeof params === 'string') { return fetcher.get('/comments', { url: params })