Skip to content

Commit 4450ec4

Browse files
authored
feat: support to update call queue presence (#1004)
* feat: support to update call queue presence * misc: add track events * misc: update i18n * misc: show empty message * misc: fetch data only after module ready
1 parent 9fe109c commit 4450ec4

File tree

34 files changed

+409
-17
lines changed

34 files changed

+409
-17
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import React, { useState, useEffect } from 'react';
2+
import {
3+
Virtuoso,
4+
RcListItem,
5+
RcListItemText,
6+
RcListItemAvatar,
7+
RcListItemSecondaryAction,
8+
RcSwitch,
9+
RcTooltip,
10+
RcAvatar,
11+
RcTypography,
12+
styled,
13+
} from '@ringcentral/juno';
14+
import { CallQueue } from '@ringcentral/juno-icon';
15+
import { BackHeaderView } from '../BackHeaderView';
16+
17+
function CallQueuePresenceItem({
18+
presence,
19+
updatePresence,
20+
}) {
21+
const [acceptCalls, setAcceptCalls] = useState(presence.acceptCalls);
22+
useEffect(() => {
23+
setAcceptCalls(presence.acceptCalls);
24+
}, [presence]);
25+
26+
let tooltipTitle = '';
27+
if (!presence.callQueue.editableMemberStatus) {
28+
tooltipTitle = "This queue does not allow members to change their availability";
29+
}
30+
return (
31+
<RcListItem>
32+
<RcListItemAvatar>
33+
<RcAvatar
34+
iconSymbol={CallQueue}
35+
color="avatar.global"
36+
size="xsmall"
37+
/>
38+
</RcListItemAvatar>
39+
<RcListItemText
40+
primary={presence.callQueue.name}
41+
secondary={`Ext. ${presence.callQueue.extensionNumber}`}
42+
primaryTypographyProps={{
43+
title: presence.callQueue.name,
44+
}}
45+
/>
46+
<RcListItemSecondaryAction>
47+
<RcTooltip title={tooltipTitle}>
48+
<span>
49+
<RcSwitch
50+
checked={acceptCalls}
51+
disabled={!presence.callQueue.editableMemberStatus}
52+
onChange={(_, checked) => {
53+
setAcceptCalls(checked);
54+
updatePresence(checked);
55+
}}
56+
/>
57+
</span>
58+
</RcTooltip>
59+
</RcListItemSecondaryAction>
60+
</RcListItem>
61+
);
62+
}
63+
64+
const StyledText = styled(RcTypography)`
65+
padding: 32px 16px;
66+
`;
67+
68+
export function CallQueueSettingsPanel({
69+
onBackButtonClick,
70+
presences,
71+
updatePresence,
72+
sync,
73+
}) {
74+
useEffect(() => {
75+
sync();
76+
}, []);
77+
78+
const content = presences && presences.length > 0 ? (
79+
<Virtuoso
80+
style={{
81+
height: '100%',
82+
width: '100%',
83+
}}
84+
totalCount={presences.length}
85+
data={presences}
86+
itemContent={(index, presence) => (
87+
<CallQueuePresenceItem
88+
presence={presence}
89+
updatePresence={
90+
(acceptCalls: boolean) => updatePresence(presence.callQueue.id, acceptCalls)
91+
}
92+
/>
93+
)}
94+
/>
95+
) : (
96+
<StyledText variant="body1" color="neutral.f06">
97+
You are not a member of any call queues.
98+
</StyledText>
99+
);
100+
101+
return (
102+
<BackHeaderView
103+
onBack={onBackButtonClick}
104+
title="Manage call queue presence"
105+
>
106+
{content}
107+
</BackHeaderView>
108+
);
109+
}

src/components/SettingsPanel/PresenceSettingSection.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import React, { useState } from 'react';
1919
import { getPresenceStatusName } from '@ringcentral-integration/widgets/lib/getPresenceStatusName';
2020
import { usePresenceItems } from '@ringcentral-integration/widgets/components/PresenceDropdown/usePresenceItems';
2121

22-
import i18n from '@ringcentral-integration/widgets/components/PresenceSettingSection/i18n';
22+
import i18n from './i18n';
2323

24-
import { SwitchLineItem, StyledSettingItem } from './SettingItem';
24+
import { SwitchLineItem, StyledSettingItem, LinkLineItem } from './SettingItem';
2525

2626
const StyledList = styled(RcList)`
2727
background-color: ${palette2('neutral', 'elevation')};
@@ -52,6 +52,8 @@ type PresenceSettingSectionProps = {
5252
setInvisible: (...args: any[]) => any;
5353
toggleAcceptCallQueueCalls: (...args: any[]) => any;
5454
showPresenceSettings: boolean;
55+
gotoCallQueuePresenceSettings: () => void;
56+
showCallQueuePresenceSettings: boolean;
5557
};
5658

5759
const StyledPresenceIcon = styled(RcPresence)`
@@ -69,6 +71,10 @@ const StyledCallQueueSwitch = styled(SwitchLineItem)`
6971
min-height: 40px;
7072
`;
7173

74+
const StyledLinkLineItem = styled(LinkLineItem)`
75+
min-height: 40px;
76+
`;
77+
7278
export const PresenceSettingSection: FunctionComponent<
7379
PresenceSettingSectionProps
7480
> = ({
@@ -82,6 +88,8 @@ export const PresenceSettingSection: FunctionComponent<
8288
setBusy,
8389
setDoNotDisturb,
8490
setInvisible,
91+
gotoCallQueuePresenceSettings,
92+
showCallQueuePresenceSettings,
8593
}) => {
8694
const [showSelects, setShowSelects] = useState(showPresenceSettings);
8795

@@ -103,6 +111,23 @@ export const PresenceSettingSection: FunctionComponent<
103111
onChange={onCallQueueChange}
104112
/>
105113
);
114+
115+
const callQueuePresenceSetting = (
116+
<StyledLinkLineItem
117+
show={
118+
showCallQueuePresenceSettings &&
119+
isCallQueueMember && (
120+
dndStatusProp === dndStatus.takeAllCalls ||
121+
dndStatusProp === dndStatus.takeDepartmentCallsOnly
122+
)
123+
}
124+
currentLocale={currentLocale}
125+
dataSign="callQueuePresenceSetting"
126+
name="callQueuePresenceSetting"
127+
onClick={gotoCallQueuePresenceSettings}
128+
/>
129+
);
130+
106131
const currentStatus = getPresenceStatusName(
107132
userStatus as any,
108133
dndStatusProp as any,
@@ -157,6 +182,7 @@ export const PresenceSettingSection: FunctionComponent<
157182
<StyledList>
158183
{presenceElements}
159184
{acceptQueueCalls}
185+
{callQueuePresenceSetting}
160186
</StyledList>
161187
) : (
162188
null

src/components/SettingsPanel/SettingItem.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const StyledSettingItem = styled(RcListItem)<{ $noBorder?: boolean }>`
3939

4040
interface NewLinkLineItemProps extends LinkLineItemProps {
4141
description?: string;
42+
className?: string;
4243
}
4344

4445
export const LinkLineItem: FunctionComponent<NewLinkLineItemProps> = ({
@@ -50,6 +51,7 @@ export const LinkLineItem: FunctionComponent<NewLinkLineItemProps> = ({
5051
dataSign = undefined,
5152
pendoSignName = undefined,
5253
description = undefined,
54+
className = undefined,
5355
}) => {
5456
if (!show) {
5557
return null;
@@ -59,6 +61,7 @@ export const LinkLineItem: FunctionComponent<NewLinkLineItemProps> = ({
5961
onClick={onClick}
6062
data-sign={dataSign}
6163
data-pendo={pendoSignName}
64+
className={className}
6265
>
6366
<RcListItemText
6467
primary={customTitle || i18n.getString(name, currentLocale)}

src/components/SettingsPanel/SettingsPanel.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ interface NewSettingsPanelProps extends SettingsPanelProps {
9797
smartNoteAutoStartEnabledReadOnly?: boolean;
9898
smartNoteEnabledReadOnlyReason?: string;
9999
smartNoteAutoStartEnabledReadOnlyReason?: string;
100+
gotoCallQueuePresenceSettings: () => void;
101+
showCallQueuePresenceSettings: boolean;
100102
}
101103

102104
function ItemRenderer({ item, currentLocale }: {
@@ -361,6 +363,8 @@ export const SettingsPanel: FunctionComponent<NewSettingsPanelProps> = ({
361363
smartNoteAutoStartEnabledReadOnlyReason = '',
362364
onSmartNoteToggle,
363365
onSmartNoteAutoStartToggle,
366+
gotoCallQueuePresenceSettings,
367+
showCallQueuePresenceSettings,
364368
}) => {
365369
let settingsItems: SettingItem[] = [{
366370
type: 'group',
@@ -581,6 +585,8 @@ export const SettingsPanel: FunctionComponent<NewSettingsPanelProps> = ({
581585
setInvisible={setInvisible}
582586
toggleAcceptCallQueueCalls={toggleAcceptCallQueueCalls}
583587
showPresenceSettings={openPresenceSettings}
588+
showCallQueuePresenceSettings={showCallQueuePresenceSettings}
589+
gotoCallQueuePresenceSettings={gotoCallQueuePresenceSettings}
584590
/>
585591
);
586592
}

src/components/SettingsPanel/i18n/de-DE.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default {
2121
quickAccess: "Einstellung für Schnellzugriff",
2222
report: "Analysebericht",
2323
shareIdea: "Idee teilen",
24-
reportIssue: "Problem melden"
24+
reportIssue: "Problem melden",
25+
status: "Status",
26+
acceptQueueCalls: "Warteschlangenanrufe annehmen"
2527
};
2628

2729
// @key: @#@"region"@#@ @source: @#@"Region"@#@

src/components/SettingsPanel/i18n/en-AU.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export default {
2323
shareIdea: "Share idea",
2424
reportIssue: "Report issue",
2525
advanced: 'Advanced',
26+
callQueuePresenceSetting: 'Manage call queue presence',
27+
status: "Status",
28+
acceptQueueCalls: "Accept calls from call queue"
2629
};
2730

2831
// @key: @#@"region"@#@ @source: @#@"Region"@#@

src/components/SettingsPanel/i18n/en-GB.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export default {
2424
shareIdea: "Share idea",
2525
reportIssue: "Report issue",
2626
advanced: 'Advanced',
27+
callQueuePresenceSetting: 'Manage call queue presence',
28+
status: "Status",
29+
acceptQueueCalls: "Accept calls from call queue"
2730
};
2831

2932
// @key: @#@"region"@#@ @source: @#@"Region"@#@

src/components/SettingsPanel/i18n/en-US.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ export default {
2626
advanced: 'Advanced',
2727
aiAssistant: 'AI Assistant (Beta)',
2828
autoStartAiAssistant: 'Auto-start AI Assistant (Beta)',
29+
callQueuePresenceSetting: 'Manage call queue presence',
30+
status: 'Status',
31+
acceptQueueCalls: 'Accept calls from call queue',
2932
};

src/components/SettingsPanel/i18n/es-419.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export default {
2020
quickAccess: "Configuración de acceso rápido",
2121
report: "Informe de análisis",
2222
shareIdea: "Compartir una idea",
23-
reportIssue: "Informar problema"
23+
reportIssue: "Informar problema",
24+
status: "Estado",
25+
acceptQueueCalls: "Aceptar las llamadas en lista de espera"
2426
};
2527

2628
// @key: @#@"region"@#@ @source: @#@"Region"@#@

src/components/SettingsPanel/i18n/es-ES.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export default {
2020
quickAccess: "Configuración de acceso rápido",
2121
report: "Informe de análisis",
2222
shareIdea: "Compartir idea",
23-
reportIssue: "Comunicar problema"
23+
reportIssue: "Comunicar problema",
24+
status: "Estado",
25+
acceptQueueCalls: "Aceptar llamadas en cola"
2426
};
2527

2628
// @key: @#@"region"@#@ @source: @#@"Region"@#@

0 commit comments

Comments
 (0)