Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kansioituun viestiin voi vastata #6434

Merged
merged 1 commit into from
Feb 26, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ export class FolderMessagesPage {
await select.selectOption({ label: folderName })
await modal.findByDataQa('modal-okBtn').click()
}

async openFirstThreadReplyEditor() {
await this.messages.first().click()
await this.page.findByDataQa('message-reply-editor-btn').click()
}
}

export class SentMessagePage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ describe('Service Worker Messaging', () => {
await folderMessagesPage.messages.assertCount(0)
await messagesPage.openFolder('Kansio 2')
await folderMessagesPage.messages.assertCount(1)

await folderMessagesPage.openFirstThreadReplyEditor()
})

it('should prefill the receiver and title fields when sending a new message', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { UserContext } from '../../state/user'
import {
AccountView,
groupMessageBoxes,
isFolderView,
isStandardView,
municipalMessageBoxes,
personalMessageBoxes,
Expand Down Expand Up @@ -669,18 +670,39 @@ export const MessageContextProvider = React.memo(
[setSingleThread]
)

const appendMessageToThreadInFolder = useCallback(
(message: Message) =>
setMessagesInFolder((prevState: Result<MessageThread[]>) =>
prevState.map((threads) =>
threads.map((thread) =>
thread.id === message.threadId
? { ...thread, messages: [...thread.messages, message] }
: thread
)
)
),
[setMessagesInFolder]
)

const onReplySent = useCallback(
({ message, threadId }: ThreadReply) => {
if (selectedAccount?.view === 'thread') {
appendMessageToSingleThread(message)
} else if (selectedAccount && isFolderView(selectedAccount.view)) {
appendMessageToThreadInFolder(message)
} else {
setReceivedMessages(
appendMessageAndMoveThreadToTopOfList(threadId, message)
)
}
setSelectedThread(threadId)
},
[appendMessageToSingleThread, selectedAccount, setSelectedThread]
[
appendMessageToSingleThread,
appendMessageToThreadInFolder,
selectedAccount,
setSelectedThread
]
)

const [replyContents, setReplyContents] = useState<RepliesByThread>({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { useTranslation } from '../../state/i18n'

import { MessageContext } from './MessageContext'
import { replyToThreadMutation } from './queries'
import { isStandardView, View } from './types-view'
import { isFolderView, isStandardView, View } from './types-view'

const archiveThreadResult = wrapResult(archiveThread)

Expand Down Expand Up @@ -289,8 +289,8 @@ export function SingleThreadView({
</React.Fragment>
))}
{canReply &&
isStandardView(view) &&
['received', 'thread'].includes(view) &&
(isFolderView(view) ||
(isStandardView(view) && ['received', 'thread'].includes(view))) &&
(replyEditorVisible ? (
<MessageContainer>
<MessageReplyEditor
Expand Down
6 changes: 6 additions & 0 deletions service/src/main/resources/dev-data/dev-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ INSERT INTO care_area (id, name, created, updated, area_code, sub_cost_center, s
('a01b0e03-b86e-4cbc-a744-6a35473b9628', 'Alue A', '2019-04-16 05:26:06.303078+00', '2020-04-02 11:40:46.780692+00', 249, '01', 'alue-a'),
('801a6cc7-e8a5-4279-b192-4e8192d82c18', 'Alue B', '2019-04-16 05:26:06.303078+00', '2020-04-02 11:40:46.780692+00', 249, '01', 'alue-b');

INSERT INTO message_thread_folder (owner_id, name)
SELECT ma.id, ca.name
FROM message_account ma
FULL JOIN care_area ca ON true
WHERE ma.type = 'SERVICE_WORKER';

INSERT INTO daycare (id, name, type, daily_preschool_time, daily_preparatory_time, care_area_id, phone, url, created, updated, backup_location, language_emphasis_id, opening_date, closing_date, email, schedule, additional_info, unit_manager_name, unit_manager_phone, unit_manager_email, cost_center, upload_to_varda, capacity, decision_daycare_name, decision_preschool_name, decision_handler, decision_handler_address, street_address, postal_code, post_office, mailing_po_box, location, mailing_street_address, mailing_postal_code, mailing_post_office, invoiced_by_municipality, provider_type, language, upload_to_koski, oph_unit_oid, oph_organizer_oid, operation_times, shift_care_operation_times, shift_care_open_on_holidays, ghost_unit, daycare_apply_period, preschool_apply_period, club_apply_period) VALUES
('2dcf0fc0-788e-11e9-bd12-db78e886e666', 'Päiväkoti ja esikoulu A', '{PREPARATORY_EDUCATION,PRESCHOOL,CENTRE}', ('09:00'::time, '13:00'::time), ('09:00'::time, '14:00'::time), 'a01b0e03-b86e-4cbc-a744-6a35473b9628', 'UNIT_PHONE', 'https://www.espoo.fi/fi/toimipisteet/15853', '2019-05-17 10:26:06.066821+00', '2021-09-06 08:34:27.596059+00', null, null, '2004-01-01', null, 'UNIT_EMAIL@espoo.fi', null, '', 'UNIT_MANAGER_NAME_A', 'UNIT_MANAGER_PHONE_A', 'UNIT_MANAGER_EMAIL_A@espoo.fi', '31606', true, 175, 'Päiväkoti ja esiopetus A', '', 'DECISION_HANDLER', 'DECISION_HANDLER_ADDRESS', 'Osoite 1', '02920', 'Espoo', 'PL 3536', '(24.7514109,60.2766848)', null, '02070', 'ESPOON KAUPUNKI', true, 'MUNICIPAL', 'fi', false, null, null, '{"(06:00,18:00)","(06:00,18:00)","(06:00,18:00)","(06:00,18:00)","(06:00,18:00)", null, null}', null, false, false, '[2020-03-01,)', '[2021-08-01,)', null),
('2dd6e5f6-788e-11e9-bd72-9f1cfe2d8405', 'Päiväkoti ja esikoulu B', '{CENTRE,PREPARATORY_EDUCATION,PRESCHOOL}', ('09:00'::time, '13:00'::time), ('09:00'::time, '14:00'::time), '801a6cc7-e8a5-4279-b192-4e8192d82c18', 'UNIT_PHONE', 'https://www.espoo.fi/fi/toimipisteet/15586', '2019-05-17 10:26:06.066821+00', '2021-09-06 08:34:27.596059+00', null, null, '1984-01-01', null, 'UNIT_EMAIL@espoo.fi', null, '', 'UNIT_MANAGER_NAME_B', 'UNIT_MANAGER_PHONE_B', 'UNIT_MANAGER_EMAIL_B@espoo.fi', '31548', true, 56, 'Päiväkoti ja esiopetus B', 'Päiväkoti ja esiopetus B', 'DECISION_HANDLER', 'DECISION_HANDLER_ADDRESS', 'Osoite 2', '02320', 'Espoo', 'PL 32317', '(24.6390243,60.1503933)', '', '02070', 'ESPOON KAUPUNKI', true, 'MUNICIPAL', 'fi', true, null, null, '{"(06:00,18:00)","(06:00,18:00)","(06:00,18:00)","(06:00,18:00)","(06:00,18:00)", null, null}', null, false, false, '[2020-03-01,)', '[2020-03-01,)', null),
Expand Down