This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new beb7e7d41 fix(settings): reveal the clear action after a signing 
secret has been saved (#5934)
beb7e7d41 is described below

commit beb7e7d412ac71751c37c89921f05b88ae523ea0
Author: 烤化の初雪 <[email protected]>
AuthorDate: Fri Nov 27 12:18:32 2026 +0800

    fix(settings): reveal the clear action after a signing secret has been 
saved (#5934)
---
 web/src/pages/settings/GeneralSettingsTab.tsx       |  9 +++++++++
 .../settings/__tests__/GeneralSettingsTab.test.tsx  | 21 +++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/web/src/pages/settings/GeneralSettingsTab.tsx 
b/web/src/pages/settings/GeneralSettingsTab.tsx
index 8db27bed8..05b4924a4 100644
--- a/web/src/pages/settings/GeneralSettingsTab.tsx
+++ b/web/src/pages/settings/GeneralSettingsTab.tsx
@@ -218,6 +218,15 @@ export const GeneralSettingsTab = () => {
     setSavingNotification(true);
     try {
       if (await mergeAndSave(values)) {
+        if ((values.dingtalkSigningSecret ?? '').trim()) {
+          // The server stores the secret and never echoes it, so the form's 
own state falls out of
+          // date: reveal the clear action for it (mergeAndSave reconciles 
from a read taken before
+          // the write) and empty the field so the next save does not resubmit 
the same secret.
+          setSettings((current) =>
+            current ? { ...current, dingtalkSigningSecretConfigured: true } : 
current,
+          );
+          notifyForm.setFieldValue('dingtalkSigningSecret', '');
+        }
         message.success(t('settings.saveSuccess'));
       }
     } finally {
diff --git a/web/src/pages/settings/__tests__/GeneralSettingsTab.test.tsx 
b/web/src/pages/settings/__tests__/GeneralSettingsTab.test.tsx
index 7abb795cd..3a339ccaa 100644
--- a/web/src/pages/settings/__tests__/GeneralSettingsTab.test.tsx
+++ b/web/src/pages/settings/__tests__/GeneralSettingsTab.test.tsx
@@ -309,6 +309,27 @@ describe('GeneralSettingsTab', () => {
     expect(saveGeneralSettings).not.toHaveBeenCalled();
   });
 
+  it('reveals the clear action once a signing secret has been saved', async () 
=> {
+    vi.mocked(saveGeneralSettings).mockResolvedValue();
+    const user = userEvent.setup();
+    renderTab();
+
+    // The fixture has no configured secret, and the save is reconciled from a 
read taken before the
+    // write, so the marker has to come from the submission itself.
+    expect(screen.queryByRole('button', { name: '清除钉钉签名密钥' 
})).not.toBeInTheDocument();
+    const secretInput = await screen.findByLabelText('钉钉机器人 Signing Secret');
+    await user.type(secretInput, 'SEC-abc');
+    fireEvent.submit(secretInput.closest('form')!);
+
+    await waitFor(() =>
+      expect(saveGeneralSettings).toHaveBeenCalledWith(
+        expect.objectContaining({ dingtalkSigningSecret: 'SEC-abc' }),
+      ),
+    );
+    expect(await screen.findByRole('button', { name: '清除钉钉签名密钥' 
})).toBeInTheDocument();
+    expect(secretInput).toHaveValue('');
+  });
+
   it('can explicitly clear a configured DingTalk signing secret', async () => {
     vi.mocked(getGeneralSettings).mockResolvedValue({
       theme: 'system',

Reply via email to