Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/comment-widget/src/base-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ export class BaseForm extends LitElement {
}

private get privateCommentDescription() {
if (this.commentName) {
return msg(
'Private replies are not publicly visible. Signed-in recipients can view them; anonymous recipients are notified by email when notifications are enabled.'
);
}
return this.currentUser
? msg(
'Currently logged in. After selecting the private option, comments will only be visible to yourself and the site administrator.'
Expand Down
1 change: 1 addition & 0 deletions packages/comment-widget/src/generated/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
's75206bde78be40fc': `No se pudo guardar el borrador con imágenes. Mantén esta página abierta.`,
's7584ded3d749c75e': `Cargar más`,
's78f95c3c2b1b0512': `Enlace al comentario`,
's79b7935eff98042c': `Las respuestas privadas no son visibles públicamente. Los destinatarios que hayan iniciado sesión pueden verlas; los destinatarios anónimos reciben una notificación por correo electrónico si las notificaciones están habilitadas.`,
's82665b2ffabc9c0a': `Sitio web`,
's838e512973be01d4': `Actualmente conectado. Después de seleccionar la opción privada, los comentarios solo serán visibles para usted y el administrador del sitio.`,
's84b033b2f7360187': `Por favor, inicie sesión o complete la información primero`,
Expand Down
1 change: 1 addition & 0 deletions packages/comment-widget/src/generated/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
's75206bde78be40fc': `无法保存图片草稿,请保持此页面打开。`,
's7584ded3d749c75e': `加载更多`,
's78f95c3c2b1b0512': `评论链接`,
's79b7935eff98042c': `私密回复不会公开显示。已登录的被回复者可以查看;若启用了邮件通知,匿名被回复者会收到邮件通知。`,
's82665b2ffabc9c0a': `网站`,
's838e512973be01d4': `当前已登录,选择私密选项后,评论将仅对您和网站管理员可见。`,
's84b033b2f7360187': `请先登录或者完善信息`,
Expand Down
1 change: 1 addition & 0 deletions packages/comment-widget/src/generated/locales/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
's75206bde78be40fc': `無法儲存圖片草稿,請保持此頁面開啟。`,
's7584ded3d749c75e': `載入更多`,
's78f95c3c2b1b0512': `留言連結`,
's79b7935eff98042c': `私密回覆不會公開顯示。已登入的被回覆者可以查看;若已啟用電子郵件通知,匿名被回覆者會收到電子郵件通知。`,
's82665b2ffabc9c0a': `網站`,
's838e512973be01d4': `目前已登入,選擇私密選項後,評論將僅對您和網站管理員可見。`,
's84b033b2f7360187': `請先登入或者完善資訊`,
Expand Down
4 changes: 2 additions & 2 deletions packages/comment-widget/src/reply-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class ReplyForm extends LitElement {
return html` <base-form
.submitting=${this.submitting}
.captcha=${this.captcha}
.hidePrivateCheckbox=${true}
.commentName=${this.comment?.metadata.name || ''}
.quoteReplyName=${this.quoteReply?.metadata.name || ''}
${ref(this.baseFormRef)}
Expand All @@ -79,13 +78,14 @@ export class ReplyForm extends LitElement {

onSubmit(e: SubmissionEvent) {
const data = e.detail;
const { content } = data || {};
const { content, hidden } = data || {};

const replyRequest: ReplyRequest = {
raw: content,
content: content,
// TODO: support user input
allowNotification: true,
hidden: hidden || false,
};

if (this.quoteReply) {
Expand Down
55 changes: 55 additions & 0 deletions packages/comment-widget/tests/reply-form.browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,58 @@ test('Reply form regression checks', async () => {
list.remove();
}
});

test('Reply form submits the selected private state', async () => {
const requests = [];
mockApi(async (_input, options = {}) => {
requests.push(JSON.parse(options.body));
return new Response(JSON.stringify({ spec: { approved: true } }), {
headers: { 'Content-Type': 'application/json' },
});
});
await import('../src/index.ts');

const form = document.createElement('reply-form');
form.comment = { metadata: { name: 'comment-1' } };
form.currentUser = { metadata: { name: 'replier' }, spec: {} };
document.body.append(form);
await form.updateComplete;
const base = form.baseFormRef.value;
base.currentUser = form.currentUser;
base.configMapData = { basic: { enablePrivateComment: true } };
await base.updateComplete;
await until(() => base.editorRef.value?.editor);

const privateOption = base.shadowRoot.querySelector('#hidden');
assert(privateOption, 'Private replies must be selectable when enabled');
assert(
base.shadowRoot.querySelector('base-tooltip').content.includes('replies'),
'Reply help must describe private replies'
);
privateOption.click();
base.editorRef.value.editor.commands.setContent('<p>Private reply</p>');
base.shadowRoot.querySelector('form').requestSubmit();
await until(() => requests.length === 1 && !form.submitting);
assert(requests[0].hidden === true, 'Private reply must send hidden=true');

form.quoteReply = { metadata: { name: 'reply-1' } };
await form.updateComplete;
await base.updateComplete;
await until(() => base.editorRef.value?.editor);
base.editorRef.value.editor.commands.setContent('<p>Public reply</p>');
base.shadowRoot.querySelector('form').requestSubmit();
await until(() => requests.length === 2 && !form.submitting);
assert(requests[1].hidden === false, 'Public reply must send hidden=false');
assert(
requests[1].quoteReply === 'reply-1',
'Quoted reply must keep its target'
);

base.configMapData = { basic: { enablePrivateComment: false } };
await base.updateComplete;
assert(
!base.shadowRoot.querySelector('#hidden'),
'Private replies must respect the existing setting'
);
form.remove();
});
4 changes: 4 additions & 0 deletions packages/comment-widget/xliff/es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@
<source>Could not save. The comment may have been deleted, or the current Halo version does not support editing. Your draft has been kept.</source>
<target>No se pudo guardar. Es posible que el comentario se haya eliminado o que la versión actual de Halo no admita la edición. Tu borrador se ha conservado.</target>
</trans-unit>
<trans-unit id="s79b7935eff98042c">
<source>Private replies are not publicly visible. Signed-in recipients can view them; anonymous recipients are notified by email when notifications are enabled.</source>
<target>Las respuestas privadas no son visibles públicamente. Los destinatarios que hayan iniciado sesión pueden verlas; los destinatarios anónimos reciben una notificación por correo electrónico si las notificaciones están habilitadas.</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions packages/comment-widget/xliff/zh-CN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@
<source>Could not save. The comment may have been deleted, or the current Halo version does not support editing. Your draft has been kept.</source>
<target>保存失败。该评论可能已被删除,或当前 Halo 版本不支持编辑。你的草稿已保留。</target>
</trans-unit>
<trans-unit id="s79b7935eff98042c">
<source>Private replies are not publicly visible. Signed-in recipients can view them; anonymous recipients are notified by email when notifications are enabled.</source>
<target>私密回复不会公开显示。已登录的被回复者可以查看;若启用了邮件通知,匿名被回复者会收到邮件通知。</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions packages/comment-widget/xliff/zh-TW.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@
<source>Could not save. The comment may have been deleted, or the current Halo version does not support editing. Your draft has been kept.</source>
<target>儲存失敗。該評論可能已被刪除,或目前 Halo 版本不支援編輯。你的草稿已保留。</target>
</trans-unit>
<trans-unit id="s79b7935eff98042c">
<source>Private replies are not publicly visible. Signed-in recipients can view them; anonymous recipients are notified by email when notifications are enabled.</source>
<target>私密回覆不會公開顯示。已登入的被回覆者可以查看;若已啟用電子郵件通知,匿名被回覆者會收到電子郵件通知。</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 4 additions & 4 deletions src/main/resources/extensions/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ spec:
name: showCommenterDevice
value: false
- $formkit: checkbox
label: 支持私密评论
label: 支持私密评论和回复
id: enablePrivateComment
key: enablePrivateComment
name: enablePrivateComment
help: 开启之后,评论者可选是否私密评论,私密评论仅评论者(已登录)和网站管理员(包含评论查看权限)可见,
help: 开启后可选择私密评论或回复。私密评论仅已登录的评论者和有评论查看权限的管理员可见;私密回复不会公开显示,回复者本人、已登录的被回复者和有评论查看权限的管理员可见,匿名被回复者需启用邮件通知才能收到回复。
value: false
- $formkit: checkbox
if: "$get(enablePrivateComment).value === true"
label: 显示私密评论状态
label: 显示私密评论和回复状态
name: showPrivateCommentBadge
id: showPrivateCommentBadge
key: showPrivateCommentBadge
value: true
help: 开启后,私密评论会显示一个私密状态标识
help: 开启后,私密评论和回复会显示私密状态标识
- group: security
label: 安全设置
formSchema:
Expand Down
Loading