Skip to content

Commit 048e075

Browse files
ccanosalstojanovicme-andre
authored
Update whiteboards from develop (#5596)
* Change mutation to contact leads (#5591) * Non-first user is able to edit a Realtime Whiteboard (#5594) --------- Co-authored-by: Aleksandar Stojanovic <[email protected]> Co-authored-by: Andrew Pazniak <[email protected]>
1 parent 96db841 commit 048e075

File tree

6 files changed

+38
-93
lines changed

6 files changed

+38
-93
lines changed

src/core/apollo/generated/apollo-hooks.ts

-15
Original file line numberDiff line numberDiff line change
@@ -11140,21 +11140,6 @@ export const CommunityUserPrivilegesWithParentCommunityDocument = gql`
1114011140
}
1114111141
}
1114211142
}
11143-
adminUsers: usersInRole(role: ADMIN) {
11144-
id
11145-
profile {
11146-
id
11147-
displayName
11148-
avatar: visual(type: AVATAR) {
11149-
...VisualUri
11150-
}
11151-
location {
11152-
id
11153-
country
11154-
city
11155-
}
11156-
}
11157-
}
1115811143
}
1115911144
}
1116011145
}

src/core/apollo/generated/graphql-schema.ts

-13
Original file line numberDiff line numberDiff line change
@@ -17597,19 +17597,6 @@ export type CommunityUserPrivilegesWithParentCommunityQuery = {
1759717597
};
1759817598
}>
1759917599
| undefined;
17600-
adminUsers?:
17601-
| Array<{
17602-
__typename?: 'User';
17603-
id: string;
17604-
profile: {
17605-
__typename?: 'Profile';
17606-
id: string;
17607-
displayName: string;
17608-
avatar?: { __typename?: 'Visual'; id: string; uri: string; name: string } | undefined;
17609-
location?: { __typename?: 'Location'; id: string; country: string; city: string } | undefined;
17610-
};
17611-
}>
17612-
| undefined;
1761317600
}
1761417601
| undefined;
1761517602
};

src/domain/common/whiteboard/excalidraw/collab/Collab.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
SYNC_FULL_SCENE_INTERVAL_MS,
99
WS_SCENE_EVENT_TYPES,
1010
} from './excalidrawAppConstants';
11-
import { ImportedDataState } from '@alkemio/excalidraw/types/data/types';
1211
import { ExcalidrawElement } from '@alkemio/excalidraw/types/element/types';
1312
import { getSceneVersion, newElementWith, restoreElements } from '@alkemio/excalidraw';
1413
import { isImageElement, UserIdleState } from './utils';
@@ -129,7 +128,7 @@ class Collab {
129128
}
130129
};
131130

132-
startCollaboration = async (existingRoomLinkData: { roomId: string }): Promise<ImportedDataState | null> =>
131+
startCollaboration = async (existingRoomLinkData: { roomId: string }): Promise<void> =>
133132
new Promise(async (resolve, reject) => {
134133
const { roomId } = existingRoomLinkData;
135134

@@ -158,6 +157,7 @@ class Collab {
158157
init: true,
159158
});
160159
}
160+
resolve();
161161
break;
162162
}
163163
case WS_SCENE_EVENT_TYPES.SCENE_UPDATE: {
@@ -206,12 +206,12 @@ class Collab {
206206
}
207207
},
208208
'first-in-room': async () => {
209-
const sceneData = await this.initializeRoom({
209+
await this.initializeRoom({
210210
fetchScene: true,
211211
roomLinkData: existingRoomLinkData,
212212
});
213213

214-
resolve(sceneData);
214+
resolve();
215215
},
216216
}
217217
);
@@ -251,8 +251,6 @@ class Collab {
251251
} else {
252252
this.portal.socketInitialized = true;
253253
}
254-
255-
return null;
256254
};
257255

258256
private reconcileElements = (

src/domain/community/application/applicationButton/OpportunityApplicationButton.tsx

+30-35
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
import { Button as MuiButton, CircularProgress } from '@mui/material';
2-
import React, { forwardRef, Ref } from 'react';
2+
import React, { forwardRef, Ref, useState } from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { Link as RouterLink } from 'react-router-dom';
55
import { buildLoginUrl } from '../../../../main/routing/urlBuilders';
66
import { AddOutlined } from '@mui/icons-material';
7-
import RootThemeProvider from '../../../../core/ui/themes/RootThemeProvider';
8-
import useDirectMessageDialog from '../../../communication/messaging/DirectMessaging/useDirectMessageDialog';
7+
import { DirectMessageDialog } from '../../../communication/messaging/DirectMessaging/DirectMessageDialog';
98

109
export interface OpportunityApplicationButtonProps {
1110
isAuthenticated?: boolean;
1211
isMember: boolean;
1312
isParentMember?: boolean;
1413
parentUrl?: string;
14+
sendMessageToCommunityLeads: (message: string) => Promise<void>;
1515
leadUsers: {
1616
id: string;
1717
displayName?: string;
1818
city?: string;
1919
country?: string;
2020
avatarUri?: string;
2121
}[];
22-
adminUsers: {
23-
id: string;
24-
displayName?: string;
25-
city?: string;
26-
country?: string;
27-
avatarUri?: string;
28-
}[];
2922
loading: boolean;
3023
component?: typeof MuiButton;
3124
extended?: boolean;
@@ -41,23 +34,21 @@ export const OpportunityApplicationButton = forwardRef<
4134
isMember = false,
4235
isParentMember = false,
4336
parentUrl,
37+
sendMessageToCommunityLeads,
4438
leadUsers,
45-
adminUsers,
4639
loading = false,
4740
component: Button = MuiButton,
4841
extended = false,
4942
},
5043
ref
5144
) => {
5245
const { t } = useTranslation();
53-
const { sendMessage, directMessageDialog } = useDirectMessageDialog({
54-
dialogTitle: t('send-message-dialog.direct-message-title'),
55-
});
56-
57-
const contactUsers = leadUsers.length > 0 ? leadUsers : adminUsers;
58-
59-
const handleSendMessageToParentLeads = () => {
60-
sendMessage('user', ...contactUsers);
46+
const [isContactLeadUsersDialogOpen, setIsContactLeadUsersDialogOpen] = useState(false);
47+
const openContactLeadsDialog = () => {
48+
setIsContactLeadUsersDialogOpen(true);
49+
};
50+
const closeContactLeadsDialog = () => {
51+
setIsContactLeadUsersDialogOpen(false);
6152
};
6253

6354
const renderApplicationButton = () => {
@@ -99,29 +90,33 @@ export const OpportunityApplicationButton = forwardRef<
9990
);
10091
}
10192

102-
if (contactUsers.length === 0) {
93+
if (leadUsers.length === 0) {
10394
return null;
10495
}
10596

10697
return (
107-
<Button
108-
ref={ref as Ref<HTMLButtonElement>}
109-
startIcon={extended ? <AddOutlined /> : undefined}
110-
onClick={handleSendMessageToParentLeads}
111-
variant="contained"
112-
sx={extended ? { textTransform: 'none' } : undefined}
113-
>
114-
{t(`components.application-button.contactOpportunityLeads.${extended ? 'full' : 'short'}` as const)}
115-
</Button>
98+
<>
99+
<Button
100+
ref={ref as Ref<HTMLButtonElement>}
101+
startIcon={extended ? <AddOutlined /> : undefined}
102+
onClick={openContactLeadsDialog}
103+
variant="contained"
104+
sx={extended ? { textTransform: 'none' } : undefined}
105+
>
106+
{t(`components.application-button.contactOpportunityLeads.${extended ? 'full' : 'short'}` as const)}
107+
</Button>
108+
<DirectMessageDialog
109+
title={t('send-message-dialog.community-message-title', { contact: t('community.leads') })}
110+
open={isContactLeadUsersDialogOpen}
111+
onClose={closeContactLeadsDialog}
112+
onSendMessage={sendMessageToCommunityLeads}
113+
messageReceivers={leadUsers}
114+
/>
115+
</>
116116
);
117117
};
118118

119-
return (
120-
<>
121-
{renderApplicationButton()}
122-
<RootThemeProvider>{directMessageDialog}</RootThemeProvider>
123-
</>
124-
);
119+
return <>{renderApplicationButton()}</>;
125120
}
126121
);
127122

src/domain/community/application/containers/OpportunityApplicationButtonContainer.tsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CommunityMembershipStatus } from '../../../../core/apollo/generated/gra
88
import { useCommunityContext } from '../../community/CommunityContext';
99
import { useAuthenticationContext } from '../../../../core/auth/authentication/hooks/useAuthenticationContext';
1010
import { SimpleContainerProps } from '../../../../core/container/SimpleContainer';
11+
import useSendMessageToCommunityLeads from '../../CommunityLeads/useSendMessageToCommunityLeads';
1112

1213
interface ApplicationContainerState {
1314
loading: boolean;
@@ -48,30 +49,24 @@ export const OpportunityApplicationButtonContainer: FC<OpportunityApplicationBut
4849

4950
const parentUrl = challengeNameId ? buildChallengeUrl(spaceNameId, challengeNameId) : buildSpaceUrl(spaceNameId);
5051
const communityLeadUsers = _communityPrivileges?.space?.opportunity?.community?.leadUsers ?? [];
51-
const communityAdminUsers = _communityPrivileges?.space?.opportunity?.community?.adminUsers ?? [];
5252
const leadUsers = communityLeadUsers.map(user => ({
5353
id: user.id,
5454
displayName: user.profile.displayName,
5555
country: user.profile.location?.country,
5656
city: user.profile.location?.city,
5757
avatarUri: user.profile.avatar?.uri,
5858
}));
59-
const adminUsers = communityAdminUsers.map(user => ({
60-
id: user.id,
61-
displayName: user.profile.displayName,
62-
country: user.profile.location?.country,
63-
city: user.profile.location?.city,
64-
avatarUri: user.profile.avatar?.uri,
65-
}));
59+
const communityId = _communityPrivileges?.space.opportunity?.community?.id;
60+
const sendMessageToCommunityLeads = useSendMessageToCommunityLeads(communityId);
6661

6762
const loading = communityPrivilegesLoading;
6863

6964
const applicationButtonProps: OpportunityApplicationButtonProps = {
7065
isAuthenticated,
7166
isMember,
7267
isParentMember,
68+
sendMessageToCommunityLeads,
7369
leadUsers,
74-
adminUsers,
7570
parentUrl,
7671
loading,
7772
};

src/domain/community/application/containers/communityUserPrivilegesWithParentCommunity.graphql

-15
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,6 @@ query communityUserPrivilegesWithParentCommunity(
5959
}
6060
}
6161
}
62-
adminUsers: usersInRole(role: ADMIN) {
63-
id
64-
profile {
65-
id
66-
displayName
67-
avatar: visual(type: AVATAR) {
68-
...VisualUri
69-
}
70-
location {
71-
id
72-
country
73-
city
74-
}
75-
}
76-
}
7762
}
7863
}
7964
}

0 commit comments

Comments
 (0)