Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove deprecated bulk sending implementation #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions __test__/AssignmentSummary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,8 @@ describe('AssignmentSummary text', function t() {
)
})

each([[0, false], [1, false], [0, true], [1, true]]).test(
'renders title and html for notInUSA=%s and allowSendAll=%s',
(notInUSA, allowSendAll) => {
window.NOT_IN_USA = notInUSA
window.ALLOW_SEND_ALL = allowSendAll
const title = this.summary.find(CardTitle)
expect(title.prop('title')).toBe('New Campaign')
// expect(title.find(CardTitle).prop('subtitle')).toBe('asdf - Jan 31 2018')

const htmlWrapper = this.summary.findWhere(
d => d.length && d.type() === 'div' && d.prop('dangerouslySetInnerHTML')
)
expect(htmlWrapper.prop('dangerouslySetInnerHTML')).toEqual({
__html: 'yoyo'
})
}
)
})

describe('AssignmentSummary actions inUSA and NOT AllowSendAll', () => {
function create(unmessaged, unreplied, badTimezone, past, skipped, isDynamic) {
window.NOT_IN_USA = 0
window.ALLOW_SEND_ALL = false
return mount(
<MuiThemeProvider>
<AssignmentSummary
Expand Down Expand Up @@ -114,35 +93,6 @@ describe('AssignmentSummary actions inUSA and NOT AllowSendAll', () => {
})
})

describe('AssignmentSummary NOT inUSA and AllowSendAll', () => {
function create(unmessaged, unreplied, badTimezone, past, skipped, isDynamic) {
window.NOT_IN_USA = 1
window.ALLOW_SEND_ALL = true
return mount(
<MuiThemeProvider>
<AssignmentSummary
assignment={getAssignment(isDynamic)}
unmessagedCount={unmessaged}
unrepliedCount={unreplied}
badTimezoneCount={badTimezone}
pastMessagesCount={past}
skippedMessagesCount={skipped}
/>
</MuiThemeProvider>
).find(CardActions)
}

it('renders "Send message" with unmessaged', () => {
const actions = create(1, 0, 0, 0, 0, false)
expect(actions.find(RaisedButton).at(0).prop('label')).toBe('Send messages')
})

it('renders "Send messages" with unreplied', () => {
const actions = create(0, 1, 0, 0, 0, false)
expect(actions.find(RaisedButton).at(0).prop('label')).toBe('Send messages')
})
})

it('renders "Send later" when there is a badTimezoneCount', () => {
const actions = mount(
<MuiThemeProvider>
Expand All @@ -167,8 +117,6 @@ describe('contacts filters', () => {
// some hints are here https://github.com/mui-org/material-ui/issues/4200#issuecomment-217738345

it('filters correctly in USA', () => {
window.NOT_IN_USA = 0
window.ALLOW_SEND_ALL = false
const mockRender = jest.fn()
AssignmentSummary.prototype.renderBadgedButton = mockRender
mount(
Expand Down Expand Up @@ -198,34 +146,6 @@ describe('contacts filters', () => {
expect(skippedMessages.title).toBe('Skipped Messages')
expect(skippedMessages.contactsFilter).toBe('skipped')
})
it('filters correctly out of USA', () => {
window.NOT_IN_USA = 1
window.ALLOW_SEND_ALL = true
const mockRender = jest.fn()
AssignmentSummary.prototype.renderBadgedButton = mockRender
mount(
<MuiThemeProvider>
<AssignmentSummary
assignment={getAssignment()}
unmessagedCount={1}
unrepliedCount={1}
badTimezoneCount={4}
skippedMessagesCount={0}
/>
</MuiThemeProvider>
)
const sendMessages = mockRender.mock.calls[0][0]
expect(sendMessages.title).toBe('Past Messages')
expect(sendMessages.contactsFilter).toBe('stale')

const skippedMessages = mockRender.mock.calls[1][0]
expect(skippedMessages.title).toBe('Skipped Messages')
expect(skippedMessages.contactsFilter).toBe('skipped')

const sendFirstTexts = mockRender.mock.calls[2][0]
expect(sendFirstTexts.title).toBe('Send messages')
expect(sendFirstTexts.contactsFilter).toBe('all')
})
})

// https://github.com/Khan/aphrodite/issues/62#issuecomment-267026726
Expand Down
1 change: 0 additions & 1 deletion docs/EXPLANATION-development-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ enviornment variable:
- Make sure the default value will not break the application for users that upgrade from a context before the variable existed.
- Only add to `.env.example` if it's an important variable to know about (e.g. the default value will often be wrong) or the development value will often be different (e.g. a DEBUG\_ type variable)
- `src/server/middleware/render-index.js` is important to update if this variable is needed on the client/React side and can't/shouldn't be sent through a GraphQL api/object. In this case, see the bottom of that file. Be careful since you are printing the variable in _raw javascript_ -- so include a `|| <default>` value within the `${...}` context.
- For any variables that enable features that should not be enabled (for legal reasons) in the United States, always ALSO test for `process.env.NOT_IN_USA` -- this ensures that the code self-documents the context these features will be available (and not available in).

## Understanding DB/.[ORM].(https://stackoverflow.com/questions/1279613/what-is-an-orm-and-where-can-i-learn-more-about-it) calls

Expand Down
12 changes: 0 additions & 12 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ const validators = {
devDefault: "http://localhost:3000",
isClient: true
}),
BULK_SEND_CHUNK_SIZE: num({
desc:
"Chunk size to use when sending all texts at once with ALLOW_SEND_ALL",
default: 100,
isClient: true
}),
CACHE_PREFIX: str({
desc:
"If REDISURL is set, then this will prefix keys CACHE_PREFIX, which might be useful if multiple applications use the same redis server.",
Expand Down Expand Up @@ -515,12 +509,6 @@ const validators = {
default: "development",
isClient: true
}),
NOT_IN_USA: bool({
desc:
"A flag to affirmatively indicate the ability to use features that are discouraged or not legally usable in the United States. Consult with an attorney about the implications for doing so. Default assumes a USA legal context.",
default: false,
isClient: true
}),
OPT_OUT_MESSAGE: str({
desc: "Spoke instance-wide default for opt out message.",
default: undefined
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions src/containers/AssignmentTexterContact/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { applyScript } from "../../lib/scripts";
import { isContactNowWithinCampaignHours } from "../../lib/timezones";
import ApplyTagDialog from "./components/ApplyTagDialog";
import AssignmentTexterSurveys from "./components/AssignmentTexterSurveys";
import BulkSendButton from "./components/BulkSendButton";
import ContactActionDialog from "./components/ContactActionDialog";
import MessageList from "./components/MessageList";
import MessageTextField from "./components/MessageTextField";
Expand Down Expand Up @@ -230,10 +229,6 @@ export class AssignmentTexterContact extends React.Component {
}
};

setDisabled = (disabled = true) => {
this.setState({ disabled });
};

getAvailableInteractionSteps = (questionResponses) => {
const allInteractionSteps = this.props.campaign.interactionSteps;
const availableSteps = [];
Expand Down Expand Up @@ -546,11 +541,6 @@ export class AssignmentTexterContact extends React.Component {
this.props.onFinishContact();
};

bulkSendMessages = async (assignmentId) => {
await this.props.mutations.bulkSendMessages(assignmentId);
this.props.refreshData();
};

handleMessageFormChange = ({ messageText }) => {
const { messageStatus } = this.props.contact;
// Do not allow deviating from the script for the first message of a campaign
Expand Down Expand Up @@ -657,7 +647,6 @@ export class AssignmentTexterContact extends React.Component {
tags,
assignment,
navigationToolbarChildren,
onFinishContact,
theme
} = this.props;
const { userCannedResponses, campaignCannedResponses } = assignment;
Expand All @@ -681,18 +670,6 @@ export class AssignmentTexterContact extends React.Component {
}
disabled={this.state.disabled}
/>
{window.NOT_IN_USA &&
window.ALLOW_SEND_ALL &&
window.BULK_SEND_CHUNK_SIZE ? (
<BulkSendButton
assignment={assignment}
onFinishContact={onFinishContact}
bulkSendMessages={this.bulkSendMessages}
setDisabled={this.setDisabled}
/>
) : (
""
)}
<div style={{ float: "right", marginLeft: 20 }}>
{navigationToolbarChildren}
</div>
Expand Down
50 changes: 1 addition & 49 deletions src/containers/TexterTodoList/components/AssignmentSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,18 @@ export const AssignmentSummary: React.FC<Props> = (props) => {

const {
assignment,
unmessagedCount,
unrepliedCount,
badTimezoneCount,
pastMessagesCount,
skippedMessagesCount
} = props;
const {
title,
description,
hasUnassignedContacts,
dueBy,
primaryColor = context.theme?.defaultCampaignColor,
logoImageUrl = context.theme?.defaultCampaignLogo,
introHtml,
useDynamicAssignment
introHtml
} = assignment.campaign;
const { maxContacts } = assignment;
const dueByText = dueBy
? DateTime.fromISO(dueBy).toFormat("MMM d, yyyy")
: "No Due Date";
Expand All @@ -134,37 +129,6 @@ export const AssignmentSummary: React.FC<Props> = (props) => {
<div dangerouslySetInnerHTML={{ __html: introHtml || "" }} />
</div>
<CardActions className={classes.cardActions}>
{window.NOT_IN_USA && window.ALLOW_SEND_ALL
? ""
: renderBadgedButton({
dataTestText: "sendFirstTexts",
assignment,
title: "Send first texts",
type: "initial",
count: unmessagedCount,
primary: true,
disabled:
(useDynamicAssignment &&
!hasUnassignedContacts &&
unmessagedCount === 0) ||
(useDynamicAssignment && maxContacts === 0) ||
undefined,
contactsFilter: "text",
hideIfZero: !useDynamicAssignment
})}
{window.NOT_IN_USA && window.ALLOW_SEND_ALL
? ""
: renderBadgedButton({
dataTestText: "sendReplies",
assignment,
title: "Send replies",
type: "reply",
count: unrepliedCount,
primary: false,
disabled: false,
contactsFilter: "reply",
hideIfZero: true
})}
{renderBadgedButton({
assignment,
title: "Past Messages",
Expand All @@ -185,18 +149,6 @@ export const AssignmentSummary: React.FC<Props> = (props) => {
contactsFilter: "skipped",
hideIfZero: true
})}
{window.NOT_IN_USA && window.ALLOW_SEND_ALL
? renderBadgedButton({
assignment,
title: "Send messages",
type: "initial",
primary: true,
disabled: false,
contactsFilter: "all",
count: 0,
hideIfZero: false
})
: ""}
{renderBadgedButton({
assignment,
title: "Send later",
Expand Down
1 change: 0 additions & 1 deletion src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface Window {
PASSPORT_STRATEGY: string;
TZ: string;
RENDERED_CLASS_NAMES: string[];
NOT_IN_USA: boolean;
ALLOW_SEND_ALL: boolean;
NODE_ENV: string;
BASE_URL: string;
Expand Down
Loading
Loading