Browse Source

Don't put confirmation sentence in alert heading

JC Brand 2 months ago
parent
commit
70ca4098fd

+ 4 - 1
src/plugins/chatview/tests/chatbox.js

@@ -939,7 +939,10 @@ describe("Chatboxes", function () {
                 key: "Enter",
             });
             await u.waitUntil(() => _converse.api.confirm.calls.count() === 1);
-            expect(_converse.api.confirm).toHaveBeenCalledWith('Are you sure you want to clear the messages from this conversation?');
+            expect(_converse.api.confirm).toHaveBeenCalledWith(
+                'Confirm',
+                'Are you sure you want to clear the messages from this conversation?'
+            );
             await u.waitUntil(() => view.model.messages.length === 0);
             await u.waitUntil(() => !view.querySelectorAll('.chat-msg__body').length);
         }));

+ 5 - 3
src/plugins/chatview/tests/corrections.js

@@ -280,7 +280,9 @@ describe("A Chat Message", function () {
 
         await u.waitUntil(() => _converse.api.confirm.calls.count());
         expect(_converse.api.confirm).toHaveBeenCalledWith(
-            'You have an unsent message which will be lost if you continue. Are you sure?');
+            'Confirm',
+            'You have an unsent message which will be lost if you continue. Are you sure?'
+        );
         expect(view.model.messages.at(0).get('correcting')).toBe(true);
         await u.waitUntil(() => textarea.value === 'But soft, what light through yonder window breaks?');
 
@@ -290,9 +292,9 @@ describe("A Chat Message", function () {
         await u.waitUntil(() => _converse.api.confirm.calls.count() === 2);
         expect(view.model.messages.at(0).get('correcting')).toBe(false);
         expect(_converse.api.confirm.calls.argsFor(0)).toEqual(
-            ['You have an unsent message which will be lost if you continue. Are you sure?']);
+            ['Confirm', 'You have an unsent message which will be lost if you continue. Are you sure?']);
         expect(_converse.api.confirm.calls.argsFor(1)).toEqual(
-            ['You have an unsent message which will be lost if you continue. Are you sure?']);
+            ['Confirm', 'You have an unsent message which will be lost if you continue. Are you sure?']);
     }));
 
 

+ 4 - 1
src/plugins/chatview/utils.js

@@ -8,7 +8,10 @@ export function clearHistory (jid) {
 }
 
 export async function clearMessages (chat) {
-    const result = await api.confirm(__('Are you sure you want to clear the messages from this conversation?'));
+    const result = await api.confirm(
+        __('Confirm'),
+        __('Are you sure you want to clear the messages from this conversation?')
+    );
     if (result) {
         await chat.clearMessages();
     }

+ 5 - 1
src/plugins/modal/templates/prompt.js

@@ -30,12 +30,16 @@ function tplField(f) {
  * @param {import('../confirm').default} el
  */
 export default (el) => {
+
+    const first_msg = el.model.get('messages')?.[0];
+    const subsequent_msgs = el.model.get('messages')?.slice(1) || [];
     return html`<form
         class="converse-form converse-form--modal confirm"
         action="#"
         @submit=${(ev) => el.onConfimation(ev)}
     >
-        <div class="mb-3">${el.model.get('messages')?.map(/** @param {string} msg */ (msg) => html`<p>${msg}</p>`)}</div>
+        <div class="mb-3"><strong>${first_msg}</strong></div>
+        <div class="mb-3">${subsequent_msgs?.map(/** @param {string} msg */ (msg) => html`<p>${msg}</p>`)}</div>
         ${el.model.get('fields')?.map(/** @param {import('../types').Field} f */ (f) => tplField(f))}
         <div class="d-flex justify-content-end">
             <button type="submit" class="btn btn-primary me-2">${__('Confirm')}</button>

+ 4 - 1
src/plugins/muc-views/tests/commands.js

@@ -356,7 +356,10 @@ describe("Groupchats", function () {
                 key: "Enter",
             });
             await u.waitUntil(() => _converse.api.confirm.calls.count() === 1);
-            expect(_converse.api.confirm).toHaveBeenCalledWith('Are you sure you want to clear the messages from this conversation?');
+            expect(_converse.api.confirm).toHaveBeenCalledWith(
+                'Confirm',
+                'Are you sure you want to clear the messages from this conversation?'
+            );
         }));
 
         it("takes /owner to make a user an owner", mock.initConverse([], {}, async function (_converse) {

+ 1 - 0
src/plugins/omemo/profile.js

@@ -62,6 +62,7 @@ export class Profile extends CustomElement {
         ev.preventDefault();
 
         const result = await api.confirm(
+            __("Confirm"),
             __(
                 "Are you sure you want to generate new OMEMO keys? " +
                     "This will remove your old keys and all previously " +

+ 3 - 2
src/plugins/roomslist/tests/roomslist.js

@@ -297,8 +297,9 @@ describe("A groupchat shown in the groupchats list", function () {
         const close_el = rooms_list.querySelector(".close-room");
         close_el.click();
         expect(_converse.api.confirm).toHaveBeenCalledWith(
-            'Are you sure you want to leave the groupchat Lounge?');
-
+            'Confirm',
+            'Are you sure you want to leave the groupchat Lounge?'
+        );
         await u.waitUntil(() => rooms_list.querySelectorAll(".open-room").length === 0);
         expect(_converse.chatboxes.length).toBe(1);
     }));

+ 4 - 1
src/plugins/roomslist/view.js

@@ -68,7 +68,10 @@ export class RoomsList extends CustomElement {
         const target = /** @type {HTMLElement} */ (ev.currentTarget);
         const name = target.getAttribute('data-room-name');
         const jid = target.getAttribute('data-room-jid');
-        const result = await api.confirm(__('Are you sure you want to leave the groupchat %1$s?', name));
+        const result = await api.confirm(
+            __('Confirm'),
+            __('Are you sure you want to leave the groupchat %1$s?', name)
+        );
         if (result) {
             const room = await api.rooms.get(jid);
             room.close();

+ 1 - 0
src/shared/chat/message-actions.js

@@ -105,6 +105,7 @@ class MessageActions extends CustomElement {
         const unsent_text = u.ancestor(this, '.chatbox')?.querySelector('.chat-textarea')?.value;
         if (unsent_text && (!currently_correcting || currently_correcting.getMessageText() !== unsent_text)) {
             const result = await api.confirm(
+                __('Confirm'),
                 __('You have an unsent message which will be lost if you continue. Are you sure?')
             );
             if (!result) return;