Skip to content

Commit 5e20141

Browse files
authored
Merge pull request #2053 from MoveOnOrg/stage-main-11-1-bugfixes-only
Stage main 11.1 release candidate
2 parents 9df3984 + 44767f3 commit 5e20141

File tree

18 files changed

+202
-156
lines changed

18 files changed

+202
-156
lines changed

__test__/extensions/service-vendors/twilio.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ describe("twilio", () => {
475475
describe("Number buying", () => {
476476
it("buys numbers in batches from twilio", async () => {
477477
const org2 = await cacheableData.organization.load(organizationId2);
478-
await twilio.buyNumbersInAreaCode(org2, "212", 35);
478+
await twilio.buyNumbersInAreaCode(org2, "212", 35, {
479+
skipOrgMessageService: true
480+
});
479481
const inventoryCount = await r.getCount(
480482
r.knex("owned_phone_number").where({
481483
area_code: "212",

src/api/schema.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ const rootSchema = gql`
384384
organizationId: ID!
385385
areaCode: String!
386386
limit: Int!
387-
addToOrganizationMessagingService: Boolean
388387
): JobRequest
389388
deletePhoneNumbers(organizationId: ID!, areaCode: String!): JobRequest
390389
releaseCampaignNumbers(campaignId: ID!): Campaign!

src/components/AssignmentTexter/ContactController.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export class ContactController extends React.Component {
7474
// In fact, without the code below, we will 'double-jump' each message
7575
// we send or change the status in some way.
7676
// Below, we update our index with the contact that matches our current index.
77-
7877
if (nextState.currentContactIndex != this.state.currentContactIndex) {
7978
console.log(
8079
"updateindex <cur> <next>",

src/components/AssignmentTexter/Controls.jsx

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -530,36 +530,49 @@ export class AssignmentTexterContactControls extends React.Component {
530530
renderNeedsResponseToggleButton(contact) {
531531
const { messageStatus } = contact;
532532
let button = null;
533-
if (messageStatus === "needsMessage") {
534-
return null;
535-
} else if (messageStatus === "closed") {
536-
// todo: add flex: style.
537-
button = (
538-
<Button
539-
onClick={() => this.props.onEditStatus("needsResponse")}
540-
className={css(flexStyles.button)}
541-
style={{ flex: "1 1 auto" }}
542-
disabled={!!this.props.contact.optOut}
543-
color="default"
544-
variant="outlined"
545-
>
546-
Reopen
547-
</Button>
548-
);
549-
} else {
550-
button = (
551-
<Button
552-
onClick={() => this.props.onEditStatus("closed", true)}
553-
className={css(flexStyles.button)}
554-
disabled={!!this.props.contact.optOut}
555-
color="default"
556-
variant="outlined"
557-
>
558-
Skip
559-
</Button>
560-
);
533+
if (messageStatus !== "needsMessage") {
534+
const status = this.state.messageStatus || messageStatus;
535+
const onClick = (newStatus, finishContact) => async () => {
536+
const res = await this.props.onEditStatus(newStatus, finishContact);
537+
if (
538+
res &&
539+
res.data &&
540+
res.data.editCampaignContactMessageStatus &&
541+
res.data.editCampaignContactMessageStatus.messageStatus
542+
) {
543+
this.setState({
544+
messageStatus:
545+
res.data.editCampaignContactMessageStatus.messageStatus
546+
});
547+
}
548+
};
549+
if (status === "closed") {
550+
button = (
551+
<Button
552+
onClick={onClick("needsResponse")}
553+
className={css(flexStyles.button)}
554+
style={{ flex: "1 1 auto" }}
555+
disabled={!!this.props.contact.optOut}
556+
color="default"
557+
variant="outlined"
558+
>
559+
Reopen
560+
</Button>
561+
);
562+
} else {
563+
button = (
564+
<Button
565+
onClick={onClick("closed", true)}
566+
className={css(flexStyles.button)}
567+
disabled={!!this.props.contact.optOut}
568+
color="default"
569+
variant="outlined"
570+
>
571+
Skip
572+
</Button>
573+
);
574+
}
561575
}
562-
563576
return button;
564577
}
565578

src/components/forms/GSTextField.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export default class GSTextField extends GSFormField {
2525
multiline,
2626
name,
2727
onChange,
28+
onFocus,
29+
onBlur,
2830
placeholder,
2931
required,
3032
rows,
@@ -56,6 +58,7 @@ export default class GSTextField extends GSFormField {
5658
margin,
5759
multiline,
5860
name,
61+
onBlur,
5962
placeholder,
6063
required,
6164
rows,
@@ -83,7 +86,12 @@ export default class GSTextField extends GSFormField {
8386
<TextField
8487
{...dataTest}
8588
label={this.floatingLabelText()}
86-
onFocus={event => event.target.select()}
89+
onFocus={event => {
90+
event.target.select();
91+
if (onFocus) {
92+
onFocus(event);
93+
}
94+
}}
8795
{...textFieldProps}
8896
onChange={event => {
8997
onChange(event.target.value);

src/containers/AdminPhoneNumberInventory.js

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ class AdminPhoneNumberInventory extends React.Component {
6363

6464
this.state = {
6565
buyNumbersDialogOpen: false,
66-
buyNumbersFormValues: {
67-
addToOrganizationMessagingService: false
68-
},
66+
buyNumbersFormValues: {},
6967
sortCol: "state",
7068
sortOrder: "asc",
7169
filters: {},
@@ -84,8 +82,7 @@ class AdminPhoneNumberInventory extends React.Component {
8482
.number()
8583
.required()
8684
.max(window.MAX_NUMBERS_PER_BUY_JOB)
87-
.min(1),
88-
addToOrganizationMessagingService: yup.bool()
85+
.min(1)
8986
});
9087
}
9188

@@ -117,23 +114,14 @@ class AdminPhoneNumberInventory extends React.Component {
117114
};
118115

119116
handleBuyNumbersSubmit = async () => {
120-
const {
121-
areaCode,
122-
limit,
123-
addToOrganizationMessagingService
124-
} = this.state.buyNumbersFormValues;
125-
await this.props.mutations.buyPhoneNumbers(
126-
areaCode,
127-
limit,
128-
addToOrganizationMessagingService
129-
);
117+
const { areaCode, limit } = this.state.buyNumbersFormValues;
118+
await this.props.mutations.buyPhoneNumbers(areaCode, limit);
130119

131120
this.setState({
132121
buyNumbersDialogOpen: false,
133122
buyNumbersFormValues: {
134123
areaCode: null,
135-
limit: null,
136-
addToOrganizationMessagingService: false
124+
limit: null
137125
}
138126
});
139127
};
@@ -299,30 +287,6 @@ class AdminPhoneNumberInventory extends React.Component {
299287
name="limit"
300288
{...dataTest("limit")}
301289
/>
302-
{serviceName === "twilio" &&
303-
serviceConfig.TWILIO_MESSAGE_SERVICE_SID &&
304-
serviceConfig.TWILIO_MESSAGE_SERVICE_SID.length > 0 &&
305-
!this.props.data.organization.campaignPhoneNumbersEnabled && (
306-
<Form.Field
307-
name="addToOrganizationMessagingService"
308-
as={props => (
309-
<FormControlLabel
310-
{...props}
311-
checked={props.value}
312-
label="Add to this organization's Messaging Service"
313-
control={<Switch color="primary" />}
314-
/>
315-
)}
316-
style={{
317-
marginTop: 30
318-
}}
319-
onToggle={(_, toggled) => {
320-
this.handleFormChange({
321-
addToOrganizationMessagingService: toggled
322-
});
323-
}}
324-
/>
325-
)}
326290
</div>
327291
<div style={inlineStyles.dialogActions}>
328292
<Button
@@ -507,23 +471,17 @@ const queries = {
507471
};
508472

509473
const mutations = {
510-
buyPhoneNumbers: ownProps => (
511-
areaCode,
512-
limit,
513-
addToOrganizationMessagingService
514-
) => ({
474+
buyPhoneNumbers: ownProps => (areaCode, limit) => ({
515475
mutation: gql`
516476
mutation buyPhoneNumbers(
517477
$organizationId: ID!
518478
$areaCode: String!
519479
$limit: Int!
520-
$addToOrganizationMessagingService: Boolean
521480
) {
522481
buyPhoneNumbers(
523482
organizationId: $organizationId
524483
areaCode: $areaCode
525484
limit: $limit
526-
addToOrganizationMessagingService: $addToOrganizationMessagingService
527485
) {
528486
id
529487
}
@@ -532,8 +490,7 @@ const mutations = {
532490
variables: {
533491
organizationId: ownProps.params.organizationId,
534492
areaCode,
535-
limit,
536-
addToOrganizationMessagingService
493+
limit
537494
},
538495
refetchQueries: () => ["getOrganizationData"]
539496
}),

src/containers/AssignmentTexterContact.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,15 @@ export class AssignmentTexterContact extends React.Component {
286286

287287
handleEditStatus = async (messageStatus, finishContact) => {
288288
const { contact } = this.props;
289-
await this.props.mutations.editCampaignContactMessageStatus(
289+
const res = await this.props.mutations.editCampaignContactMessageStatus(
290290
messageStatus,
291291
contact.id
292292
);
293293
if (finishContact) {
294294
await this.handleSubmitSurveys();
295295
this.props.onFinishContact();
296296
}
297+
return res;
297298
};
298299

299300
handleOptOut = async ({ optOutMessageText }) => {

src/extensions/contact-loaders/redash/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ export async function processContactLoad(job, maxContacts, organization) {
215215
}
216216
// 1. start query
217217
const startQueryUrl = `${baseUrl}/api/queries/${queryId}/refresh${params}`;
218-
console.log("REDASH 1");
219218
let refreshRedashResult;
220219
try {
221220
refreshRedashResult = await httpRequest(startQueryUrl, {
@@ -249,12 +248,10 @@ export async function processContactLoad(job, maxContacts, organization) {
249248
// 2. poll job status
250249
const jobQueryId = redashJobData.job.id;
251250
const redashPollStatusUrl = `${baseUrl}/api/jobs/${jobQueryId}`;
252-
console.log("REDASH 2", redashJobData);
253251
const redashQueryCompleted = await httpRequest(redashPollStatusUrl, {
254252
method: "get",
255253
bodyRetryFunction: async res => {
256254
const json = await res.json();
257-
console.log("statusValidation", json);
258255
const jobStatus = json && json.job && json.job.status;
259256
return jobStatus === 3 || jobStatus === 4 ? json : { RETRY: 1 };
260257
},
@@ -263,7 +260,6 @@ export async function processContactLoad(job, maxContacts, organization) {
263260
retryDelayMs: 3000, // 3 seconds
264261
...httpsArgs(organization)
265262
});
266-
console.log("refreshDataResult", redashQueryCompleted);
267263
if (redashQueryCompleted.job.status === 4) {
268264
await failedContactLoad(
269265
job,

src/extensions/service-managers/per-campaign-messageservices/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ export async function onCampaignUpdateSignal({
237237
return await _editCampaignData(organization, campaign);
238238
}
239239

240+
export async function onBuyPhoneNumbers({ organization, serviceName, opts }) {
241+
return {
242+
opts: {
243+
skipOrgMessageService: true
244+
}
245+
};
246+
}
247+
240248
export async function onVendorServiceFullyConfigured({
241249
organization,
242250
serviceName

src/extensions/service-managers/scrub-bad-mobilenums/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from "lodash";
22
import { r, cacheableData } from "../../../server/models";
3-
import { getFeatures } from "../../../server/api/lib/config";
3+
import { getConfig, getFeatures } from "../../../server/api/lib/config";
44
import { Jobs } from "../../../workers/job-processes";
55
import { jobRunner } from "../../job-runners";
66
import { getServiceFromOrganization } from "../../service-vendors";
@@ -80,7 +80,6 @@ export async function getCampaignData({
8080
// MUST NOT RETURN SECRETS!
8181
// called both from edit and stats contexts: editMode==true for edit page
8282
if (!fromCampaignStatsPage) {
83-
// TODO: get campaignFeatures current
8483
const features = getFeatures(campaign);
8584
const {
8685
scrubBadMobileNumsFreshStart = false,
@@ -90,6 +89,10 @@ export async function getCampaignData({
9089
scrubBadMobileNumsDeletedOnUpload = null
9190
} = features;
9291

92+
const scrubMobileOptional = getConfig(
93+
"SCRUB_MOBILE_OPTIONAL",
94+
organization
95+
);
9396
const serviceClient = getServiceFromOrganization(organization);
9497
const scrubBadMobileNumsGettable =
9598
typeof serviceClient.getContactInfo === "function";
@@ -111,10 +114,13 @@ export async function getCampaignData({
111114
scrubBadMobileNumsGettable,
112115
scrubBadMobileNumsCount,
113116
scrubBadMobileNumsFinishedDeleteCount,
114-
scrubBadMobileNumsDeletedOnUpload
117+
scrubBadMobileNumsDeletedOnUpload,
118+
scrubMobileOptional
115119
},
116120
fullyConfigured:
117-
scrubBadMobileNumsFinished || scrubBadMobileNumsCount === 0
121+
scrubBadMobileNumsFinished ||
122+
scrubBadMobileNumsCount === 0 ||
123+
scrubMobileOptional
118124
};
119125
}
120126
}

0 commit comments

Comments
 (0)