Skip to content

Commit cc9f5f1

Browse files
Renamed constants and updated list of fils to update
1 parent 5126081 commit cc9f5f1

File tree

4 files changed

+93
-80
lines changed

4 files changed

+93
-80
lines changed

scripts/ui-library-set-variables-values

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const fs = require("fs");
22
const readline = require("readline");
3-
const path = require("path");
43

54
// Function to update the file content
65
function updateFileContent(filePath, replacements) {
@@ -39,8 +38,17 @@ const filesToUpdate = [
3938
// ui-library-filesharing-chat-composite
4039
"../ui-library-filesharing-chat-composite/api/local.settings.json",
4140
"../ui-library-filesharing-chat-composite/app/src/App.tsx",
42-
43-
41+
42+
// ui-library-starting-with-chat-stateful
43+
"../ui-library-starting-with-chat-stateful/src/App.tsx",
44+
45+
// ui-library-filesharing-ui-components
46+
"../ui-library-filesharing-ui-components/api/local.settings.json",
47+
"../ui-library-filesharing-ui-components/app/src/App.tsx",
48+
49+
// ui-library-quickstart-teams-interop-meeting-chat
50+
"../ui-library-quickstart-teams-interop-meeting-chat/src/App.tsx",
51+
4452
// Add more file paths as needed
4553
];
4654

@@ -64,18 +72,18 @@ async function main() {
6472
const endpointUrl = await promptUser(
6573
"Enter Azure Communication Services Resource Endpoint: "
6674
);
67-
const azureStorageConnectionString = await promptUser(
68-
"Enter Azure Communication Services Storage Connection String: "
69-
);
70-
const token = await promptUser(
71-
"Enter Azure Communication Services Resource Access Token: "
72-
);
73-
const userId = await promptUser("Enter User Id associated to the token: ");
74-
const threadId = await promptUser(
75-
"Enter Azure Communication Services thread id: "
76-
);
77-
const teamsMeetingLink = await promptUser("Enter Teams Meeting link: ");
78-
const displayName = await promptUser("Enter Display Name: ");
75+
const azureStorageConnectionString = await promptUser(
76+
"Enter Azure Communication Services Storage Connection String: "
77+
);
78+
const token = await promptUser(
79+
"Enter Azure Communication Services Resource Access Token: "
80+
);
81+
const userId = await promptUser("Enter User Id associated to the token: ");
82+
const threadId = await promptUser(
83+
"Enter Azure Communication Services thread id: "
84+
);
85+
const teamsMeetingLink = await promptUser("Enter Teams Meeting link: ");
86+
const displayName = await promptUser("Enter Display Name: ");
7987

8088
const replacements = {
8189
"const ENDPOINT_URL =": endpointUrl,
@@ -84,7 +92,7 @@ async function main() {
8492
"const DISPLAY_NAME =": displayName,
8593
'"azureStorageConnectionString":': azureStorageConnectionString,
8694
"const TEAMS_MEETING_LINK =": teamsMeetingLink,
87-
"const THREAD_ID =": threadId;
95+
"const THREAD_ID =": threadId,
8896
};
8997
console.log(replacements);
9098
filesToUpdate.forEach((filePath) => {
@@ -133,7 +141,7 @@ function restoreBackups() {
133141
.join("\n");
134142

135143
fs.writeFileSync(filePath, restoredContent, "utf8");
136-
console.log(`File ${filePath} restored from backup.`);
144+
console.log(`Constants in ${filePath} restored to default values.`);
137145
});
138146
}
139147

ui-library-filesharing-ui-components/app/src/App.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,25 @@ function App(): JSX.Element {
1717
registerIcons({ icons: DEFAULT_COMPONENT_ICONS });
1818
initializeFileTypeIcons();
1919

20-
const endpointUrl = '<Azure Communication Services Resource Endpoint>';
21-
const token = '<Azure Communication Services Resource Access Token>';
22-
const userId = '<User Id associated to the token>';
23-
const threadId = '<Get thread id from chat service>';
24-
const displayName = '<Display Name>';
20+
const ENDPOINT_URL = "<Azure Communication Services Resource Endpoint>";
21+
const TOKEN = "<Azure Communication Services Resource Access Token>";
22+
const USER_ID = "<User Id associated to the token>";
23+
const THREAD_ID = "<Get thread id from chat service>";
24+
const DISPLAY_NAME = "<Display Name>";
2525

26-
const tokenCredential = new AzureCommunicationTokenCredential(
27-
token
28-
);
26+
const tokenCredential = new AzureCommunicationTokenCredential(TOKEN);
2927

3028
// Instantiate the statefulChatClient
3129
const statefulChatClient = createStatefulChatClient({
32-
userId: { communicationUserId: userId },
33-
displayName: displayName,
34-
endpoint: endpointUrl,
30+
userId: { communicationUserId: USER_ID },
31+
displayName: DISPLAY_NAME,
32+
endpoint: ENDPOINT_URL,
3533
credential: tokenCredential,
3634
});
3735

3836
statefulChatClient.startRealtimeNotifications();
3937

40-
const chatThreadClient = statefulChatClient.getChatThreadClient(threadId);
38+
const chatThreadClient = statefulChatClient.getChatThreadClient(THREAD_ID);
4139

4240
initializeThreadState(chatThreadClient);
4341

@@ -52,9 +50,7 @@ function App(): JSX.Element {
5250
);
5351
}
5452

55-
async function initializeThreadState(
56-
chatThreadClient: ChatThreadClient
57-
): Promise<void> {
53+
async function initializeThreadState(chatThreadClient: ChatThreadClient): Promise<void> {
5854
await chatThreadClient.getProperties();
5955
for await (const _page of chatThreadClient.listParticipants().byPage()) {
6056
// Simply fetching participants updates the cached state in client.
Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import React, {
2-
useMemo,
3-
} from 'react';
4-
import { TeamsMeetingLinkLocator } from '@azure/communication-calling';
5-
import { AzureCommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';
1+
import React, { useMemo } from "react";
2+
import { TeamsMeetingLinkLocator } from "@azure/communication-calling";
3+
import {
4+
AzureCommunicationTokenCredential,
5+
CommunicationUserIdentifier,
6+
} from "@azure/communication-common";
67
import {
78
CallAndChatLocator,
89
CallWithChatComposite,
910
useAzureCommunicationCallWithChatAdapter,
10-
CallWithChatCompositeOptions
11-
} from '@azure/communication-react';
12-
import { Theme, PartialTheme, Spinner } from '@fluentui/react';
11+
CallWithChatCompositeOptions,
12+
} from "@azure/communication-react";
13+
import { Theme, PartialTheme, Spinner } from "@fluentui/react";
1314

1415
/**
1516
* Authentication information needed for your client application to use
@@ -21,18 +22,18 @@ import { Theme, PartialTheme, Spinner } from '@fluentui/react';
2122
* In a real application, your backend service would provide these to the client
2223
* application after the user goes through your authentication flow.
2324
*/
24-
const ENDPOINT_URL = '<Azure Communication Resource Endpoint URL>';
25-
const USER_ID = '<Azure Communication User ID>';
26-
const TOKEN = '<Azure Communication Service Resource Token>';
27-
const TEAMS_MEETING_LINK = '<Teams Meeting Link>';
25+
const ENDPOINT_URL = "<Azure Communication Services Resource Endpoint>";
26+
const USER_ID = "<User Id associated to the token>";
27+
const TOKEN = "<Azure Communication Services Resource Access Token>";
28+
const TEAMS_MEETING_LINK = "<Teams Meeting Link>";
2829

2930
/**
3031
* Display name for the local participant.
3132
* In a real application, this would be part of the user data that your
3233
* backend services provides to the client application after the user
3334
* goes through your authentication flow.
3435
*/
35-
const DISPLAY_NAME = '<Azure Communication User Display Name>';
36+
const DISPLAY_NAME = "<Display Name>";
3637
/**
3738
* By default, the `richTextEditorEnabled` is set to false,
3839
* which means the plain text editor will be used for the SendBox component and the MessageThread component's edit function.
@@ -41,7 +42,6 @@ const DISPLAY_NAME = '<Azure Communication User Display Name>';
4142
*/
4243
const richTextEditorEnabled = false;
4344

44-
4545
export type CallWithChatExampleProps = {
4646
// Props needed for the construction of the CallWithChatAdapter
4747
userId: CommunicationUserIdentifier;
@@ -56,10 +56,15 @@ export type CallWithChatExampleProps = {
5656
callInvitationURL?: string;
5757
};
5858

59-
export const CallWithChatExperience = (props: CallWithChatExampleProps): JSX.Element => {
59+
export const CallWithChatExperience = (
60+
props: CallWithChatExampleProps
61+
): JSX.Element => {
6062
// Construct a credential for the user with the token retrieved from your server. This credential
6163
// must be memoized to ensure useAzureCommunicationCallWithChatAdapter is not retriggered on every render pass.
62-
const credential = useMemo(() => new AzureCommunicationTokenCredential(props.token), [props.token]);
64+
const credential = useMemo(
65+
() => new AzureCommunicationTokenCredential(props.token),
66+
[props.token]
67+
);
6368

6469
// Create the adapter using a custom react hook provided in the @azure/communication-react package.
6570
// See https://aka.ms/acsstorybook?path=/docs/composite-adapters--page for more information on adapter construction and alternative constructors.
@@ -68,7 +73,7 @@ export const CallWithChatExperience = (props: CallWithChatExampleProps): JSX.Ele
6873
displayName: props.displayName,
6974
credential,
7075
locator: props.locator,
71-
endpoint: props.endpointUrl
76+
endpoint: props.endpointUrl,
7277
});
7378

7479
// The adapter is created asynchronously by the useAzureCommunicationCallWithChatAdapter hook.
@@ -77,23 +82,29 @@ export const CallWithChatExperience = (props: CallWithChatExampleProps): JSX.Ele
7782
return <Spinner label="Initializing..." />;
7883
}
7984

80-
return <CallWithChatComposite adapter={adapter} fluentTheme={props.fluentTheme} options={props.compositeOptions} />;
85+
return (
86+
<CallWithChatComposite
87+
adapter={adapter}
88+
fluentTheme={props.fluentTheme}
89+
options={props.compositeOptions}
90+
/>
91+
);
8192
};
8293

8394
/**
8495
* Entry point of your application.
8596
*/
8697
function App(): JSX.Element {
87-
return (
88-
<CallWithChatExperience
89-
userId = {{ communicationUserId: USER_ID }}
90-
token={ TOKEN }
91-
displayName = { DISPLAY_NAME }
92-
endpointUrl={ ENDPOINT_URL }
93-
locator = { { meetingLink: TEAMS_MEETING_LINK } }
94-
compositeOptions={{ richTextEditor: richTextEditorEnabled }}
95-
/>
96-
);
98+
return (
99+
<CallWithChatExperience
100+
userId={{ communicationUserId: USER_ID }}
101+
token={TOKEN}
102+
displayName={DISPLAY_NAME}
103+
endpointUrl={ENDPOINT_URL}
104+
locator={{ meetingLink: TEAMS_MEETING_LINK }}
105+
compositeOptions={{ richTextEditor: richTextEditorEnabled }}
106+
/>
107+
);
97108
}
98109

99110
export default App;
Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
1-
import { AzureCommunicationTokenCredential } from '@azure/communication-common';
1+
import { AzureCommunicationTokenCredential } from "@azure/communication-common";
22
import {
33
createStatefulChatClient,
44
FluentThemeProvider,
55
ChatClientProvider,
66
ChatThreadClientProvider,
7-
DEFAULT_COMPONENT_ICONS
8-
} from '@azure/communication-react';
9-
import React from 'react';
10-
import ChatComponents from './ChatComponentsStateful';
11-
import { initializeIcons, registerIcons } from '@fluentui/react';
7+
DEFAULT_COMPONENT_ICONS,
8+
} from "@azure/communication-react";
9+
import React from "react";
10+
import ChatComponents from "./ChatComponentsStateful";
11+
import { initializeIcons, registerIcons } from "@fluentui/react";
1212

1313
initializeIcons();
1414
registerIcons({ icons: DEFAULT_COMPONENT_ICONS });
1515

1616
function App(): JSX.Element {
17-
const endpointUrl = '<Azure Communication Services Resource Endpoint>';
18-
const token = '<Azure Communication Services Resource Access Token>';
19-
const userId = '<User Id associated to the token>';
20-
const threadId = '<Get thread id from chat service>';
21-
const displayName = '<Display Name>';
17+
const ENDPOINT_URL = "<Azure Communication Services Resource Endpoint>";
18+
const TOKEN = "<Azure Communication Services Resource Access Token>";
19+
const USER_ID = "<User Id associated to the token>";
20+
const THREAD_ID = "<Get thread id from chat service>";
21+
const DISPLAY_NAME = "<Display Name>";
2222

23-
24-
const tokenCredential = new AzureCommunicationTokenCredential(token);
23+
const tokenCredential = new AzureCommunicationTokenCredential(TOKEN);
2524
//Instantiate the statefulChatClient
2625
const statefulChatClient = createStatefulChatClient({
27-
userId: { communicationUserId: userId },
28-
displayName: displayName,
29-
endpoint: endpointUrl,
30-
credential: tokenCredential
26+
userId: { communicationUserId: USER_ID },
27+
displayName: DISPLAY_NAME,
28+
endpoint: ENDPOINT_URL,
29+
credential: tokenCredential,
3130
});
3231

33-
const chatThreadClient = statefulChatClient.getChatThreadClient(threadId);
32+
const chatThreadClient = statefulChatClient.getChatThreadClient(THREAD_ID);
3433

3534
//Listen to notifications
3635
statefulChatClient.startRealtimeNotifications();
3736

38-
3937
return (
4038
<FluentThemeProvider>
4139
<ChatClientProvider chatClient={statefulChatClient}>
@@ -47,4 +45,4 @@ function App(): JSX.Element {
4745
);
4846
}
4947

50-
export default App;
48+
export default App;

0 commit comments

Comments
 (0)