From 986f7216582379b283976bdac46d532901321e61 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 18 Oct 2024 22:58:09 -0300 Subject: [PATCH] mock --- .../functions/syncWorkspace/syncCloudData.ts | 2 +- .../core-apps/cloudAnnouncements.module.ts | 94 +++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/apps/meteor/app/cloud/server/functions/syncWorkspace/syncCloudData.ts b/apps/meteor/app/cloud/server/functions/syncWorkspace/syncCloudData.ts index 446c1d4e92038..1be149bf9dd73 100644 --- a/apps/meteor/app/cloud/server/functions/syncWorkspace/syncCloudData.ts +++ b/apps/meteor/app/cloud/server/functions/syncWorkspace/syncCloudData.ts @@ -52,7 +52,7 @@ const fetchWorkspaceSyncPayload = async ({ assertWorkspaceSyncPayload(payload); const cloudSyncAnnouncement = { - viewId: 'license', + viewId: 'subscription-announcement', appId: 'cloud-announcements-core', blocks: [ { diff --git a/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts b/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts index 68599162cdef5..096b79ed7f790 100644 --- a/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts +++ b/apps/meteor/server/modules/core-apps/cloudAnnouncements.module.ts @@ -243,6 +243,100 @@ export class CloudAnnouncementsModule implements IUiKitCoreApp { ...userInteraction, }; + if ( + userInteraction.type === 'blockAction' && + userInteraction.container?.type === 'view' && + userInteraction.actionId === 'callout-action' && + userInteraction.container?.id === 'subscription-announcement' + ) { + return { + type: 'modal.open', + triggerId: userInteraction.triggerId, + appId: this.appId, + view: { + showIcon: false, + id: userInteraction.container.id, + title: { + type: 'plain_text', + text: 'Hello from Cloud', + }, + blocks: [ + { + type: 'image', + title: { + type: 'plain_text', + text: 'I Need a Marg', + emoji: true, + }, + imageUrl: 'https://picsum.photos/200/300', + altText: 'marg', + }, + { + type: 'context', + elements: [ + { + type: 'mrkdwn', + text: '*This* is :smile: markdown', + }, + ], + }, + ], + appId: this.appId, + // export type ButtonElement = Actionable<{ + // type: 'button'; + // text: PlainText; + // url?: string; + // value?: string; + // style?: 'primary' | 'secondary' | 'danger' | 'warning' | 'success'; + // secondary?: boolean; + // }>; + + close: { + appId: this.appId, + blockId: userInteraction.container.id, + type: 'button', + text: { + type: 'plain_text', + text: 'Close', + emoji: true, + }, + actionId: 'close-modal', + url: 'https://rocket.chat', + }, + submit: { + appId: this.appId, + blockId: userInteraction.container.id, + type: 'button', + text: { + type: 'plain_text', + text: 'Submit', + emoji: true, + }, + actionId: 'submit-modal', + url: 'https://rocket.chat', + }, + }, + }; + } + + if ( + userInteraction.type === 'blockAction' && + userInteraction.container?.type === 'view' && + (userInteraction.actionId === 'submit-modal' || userInteraction.actionId === 'close-modal') + ) { + if (userInteraction.actionId === 'submit-modal') { + await syncWorkspace(); + } + + return { + type: 'modal.close', + triggerId: userInteraction.triggerId, + appId: this.appId, + }; + } + + console.log(userInteraction); + const response = await fetch(`${this.getCloudUrl()}/api/v3/comms/workspace/interaction`, { method: 'POST', headers: {