Skip to content

Commit f13a654

Browse files
committed
Phone number dropdown
1 parent 3e594ec commit f13a654

File tree

5 files changed

+48
-24
lines changed

5 files changed

+48
-24
lines changed

web/package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/public/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
// During web development, you may change values here for rapid testing.
77

88
var config = {
9-
base_url: window.location.origin, // Change to test against a different server
9+
base_url: "http://127.0.0.1:2586", //window.location.origin, // Change to test against a different server
1010
app_root: "/app",
1111
enable_login: true,
1212
enable_signup: true,
13-
enable_payments: true,
13+
enable_payments: false,
1414
enable_reservations: true,
1515
enable_emails: true,
1616
enable_calls: true,

web/public/static/langs/de.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,9 @@
357357
"account_upgrade_dialog_tier_features_reservations_one": "{{reservations}} reserviertes Thema",
358358
"account_upgrade_dialog_tier_features_emails_one": "{{emails}} tägliche E-Mail",
359359
"publish_dialog_call_label": "Telefonanruf",
360-
"publish_dialog_call_placeholder": "Telefonnummer, die angerufen werden soll, z.B. +49123456789, oder 'yes'",
360+
"publish_dialog_call_item": "Telefonnummer {{number}} anrufen",
361361
"publish_dialog_chip_call_label": "Telefonanruf",
362+
"publish_dialog_chip_call_no_verified_numbers_tooltip": "Keine verifizierten Telefonnummern",
362363
"account_basics_phone_numbers_title": "Telefonnummern",
363364
"account_basics_phone_numbers_copied_to_clipboard": "Telefonnummer wurde in die Zwischenablage kopiert",
364365
"account_basics_phone_numbers_dialog_title": "Telefonnummer hinzufügen",

web/public/static/langs/en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"publish_dialog_email_placeholder": "Address to forward the notification to, e.g. phil@example.com",
131131
"publish_dialog_email_reset": "Remove email forward",
132132
"publish_dialog_call_label": "Phone call",
133-
"publish_dialog_call_placeholder": "Phone number to call with the message, e.g. +12223334444, or 'yes'",
133+
"publish_dialog_call_item": "Call phone number {{number}}",
134134
"publish_dialog_call_reset": "Remove phone call",
135135
"publish_dialog_attach_label": "Attachment URL",
136136
"publish_dialog_attach_placeholder": "Attach file by URL, e.g. https://f-droid.org/F-Droid.apk",
@@ -144,6 +144,7 @@
144144
"publish_dialog_chip_click_label": "Click URL",
145145
"publish_dialog_chip_email_label": "Forward to email",
146146
"publish_dialog_chip_call_label": "Phone call",
147+
"publish_dialog_chip_call_no_verified_numbers_tooltip": "No verified phone numbers",
147148
"publish_dialog_chip_attach_url_label": "Attach file by URL",
148149
"publish_dialog_chip_attach_file_label": "Attach local file",
149150
"publish_dialog_chip_delay_label": "Delay delivery",

web/src/components/PublishDialog.js

+38-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import * as React from 'react';
2-
import {useEffect, useRef, useState} from 'react';
2+
import {useContext, useEffect, useRef, useState} from 'react';
33
import theme from "./theme";
4-
import {Checkbox, Chip, FormControl, FormControlLabel, InputLabel, Link, Select, useMediaQuery} from "@mui/material";
4+
import {
5+
Checkbox,
6+
Chip,
7+
FormControl,
8+
FormControlLabel,
9+
InputLabel,
10+
Link,
11+
Select,
12+
Tooltip,
13+
useMediaQuery
14+
} from "@mui/material";
515
import TextField from "@mui/material/TextField";
616
import priority1 from "../img/priority-1.svg";
717
import priority2 from "../img/priority-2.svg";
@@ -29,9 +39,11 @@ import session from "../app/Session";
2939
import routes from "./routes";
3040
import accountApi from "../app/AccountApi";
3141
import {UnauthorizedError} from "../app/errors";
42+
import {AccountContext} from "./App";
3243

3344
const PublishDialog = (props) => {
3445
const { t } = useTranslation();
46+
const { account } = useContext(AccountContext);
3547
const [baseUrl, setBaseUrl] = useState("");
3648
const [topic, setTopic] = useState("");
3749
const [message, setMessage] = useState("");
@@ -416,20 +428,29 @@ const PublishDialog = (props) => {
416428
setCall("");
417429
setShowCall(false);
418430
}}>
419-
<TextField
420-
margin="dense"
421-
label={t("publish_dialog_call_label")}
422-
placeholder={t("publish_dialog_call_placeholder")}
423-
value={call}
424-
onChange={ev => setCall(ev.target.value)}
425-
disabled={disabled}
426-
type="tel"
427-
variant="standard"
431+
<FormControl
428432
fullWidth
429-
inputProps={{
430-
"aria-label": t("publish_dialog_call_label")
431-
}}
432-
/>
433+
variant="standard"
434+
margin="dense"
435+
>
436+
<InputLabel/>
437+
<Select
438+
label={t("publish_dialog_call_label")}
439+
margin="dense"
440+
value={call}
441+
onChange={(ev) => setCall(ev.target.value)}
442+
disabled={disabled}
443+
inputProps={{
444+
"aria-label": t("publish_dialog_call_label")
445+
}}
446+
>
447+
{account?.phone_numbers?.map((phoneNumber, i) =>
448+
<MenuItem key={`phoneNumberMenuItem${i}`} value={phoneNumber} aria-label={phoneNumber}>
449+
{t("publish_dialog_call_item", { number: phoneNumber })}
450+
</MenuItem>
451+
)}
452+
</Select>
453+
</FormControl>
433454
</ClosableRow>
434455
}
435456
{showAttachUrl &&
@@ -536,11 +557,12 @@ const PublishDialog = (props) => {
536557
<div>
537558
{!showClickUrl && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_click_label")} aria-label={t("publish_dialog_chip_click_label")} onClick={() => setShowClickUrl(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
538559
{!showEmail && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_email_label")} aria-label={t("publish_dialog_chip_email_label")} onClick={() => setShowEmail(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
539-
{!showCall && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_call_label")} aria-label={t("publish_dialog_chip_call_label")} onClick={() => setShowCall(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
560+
{account?.phone_numbers?.length > 0 && !showCall && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_call_label")} aria-label={t("publish_dialog_chip_call_label")} onClick={() => { setShowCall(true); setCall(account.phone_numbers[0]); }} sx={{marginRight: 1, marginBottom: 1}}/>}
540561
{!showAttachUrl && !showAttachFile && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_attach_url_label")} aria-label={t("publish_dialog_chip_attach_url_label")} onClick={() => setShowAttachUrl(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
541562
{!showAttachFile && !showAttachUrl && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_attach_file_label")} aria-label={t("publish_dialog_chip_attach_file_label")} onClick={() => handleAttachFileClick()} sx={{marginRight: 1, marginBottom: 1}}/>}
542563
{!showDelay && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_delay_label")} aria-label={t("publish_dialog_chip_delay_label")} onClick={() => setShowDelay(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
543564
{!showTopicUrl && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_topic_label")} aria-label={t("publish_dialog_chip_topic_label")} onClick={() => setShowTopicUrl(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
565+
{account && !account?.phone_numbers && <Tooltip title={t("publish_dialog_chip_call_no_verified_numbers_tooltip")}><span><Chip clickable disabled label={t("publish_dialog_chip_call_label")} aria-label={t("publish_dialog_chip_call_label")} sx={{marginRight: 1, marginBottom: 1}}/></span></Tooltip>}
544566
</div>
545567
<Typography variant="body1" sx={{marginTop: 1, marginBottom: 1}}>
546568
<Trans

0 commit comments

Comments
 (0)