-
Notifications
You must be signed in to change notification settings - Fork 370
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
change: [M3-8415] - Hide SMTP warning for Linodes and accounts that have SMTP enabled #10991
Changes from all commits
454eae2
aaf7e3e
a88b4aa
b09b99e
822a751
9d3b403
09c78cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/api-v4": Added | ||
--- | ||
|
||
'SMTP Enabled' account & Linode capabilities ([#10991](https://github.com/linode/manager/pull/10991)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Changed | ||
--- | ||
|
||
Hide SMTP warning for Linodes and accounts that have SMTP enabled ([#10991](https://github.com/linode/manager/pull/10991)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,32 @@ import * as React from 'react'; | |
import { Link } from 'src/components/Link'; | ||
import { SupportLink } from 'src/components/SupportLink'; | ||
import { Typography } from 'src/components/Typography'; | ||
import { MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED } from 'src/constants'; | ||
import { useAccount } from 'src/queries/account/account'; | ||
import { sendLinodeCreateDocsEvent } from 'src/utilities/analytics/customEventAnalytics'; | ||
|
||
import type { Linode } from '@linode/api-v4'; | ||
|
||
export interface SMTPRestrictionTextProps { | ||
children: (props: { text: React.ReactNode }) => React.ReactNode; | ||
linode?: Linode; | ||
supportLink?: { | ||
id: number; | ||
label: string; | ||
}; | ||
} | ||
|
||
export const SMTPRestrictionText = (props: SMTPRestrictionTextProps) => { | ||
const { supportLink } = props; | ||
const { linode, supportLink } = props; | ||
const { data: account } = useAccount(); | ||
|
||
const displayRestrictionText = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More of a backend question: Do we know if it's possible for an account to have SMTP_ENABLED, but an individual Linode is still disabled (with net exceptions on its ports)? If that state were possible, we're currently showing the notice for the Linode, which seems like what we'd want for transparency... unless, somehow, the individual net exceptions don't always get removed when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, it's possible. I was surprised to learn that there is no logic in the API that links the customer tag with the Net Filter Exceptions of a particular Linode. Adding the tag is a manual process used by support representatives when a customer requests SMTP abilities on their Linode and it is only used to keep track of which customers have had this request granted. The availability of SMTP for a Linode is determined solely by the presence (or lack thereof) of the SMTP Net Filter Exceptions. There is also a field on the customer called 'Default Net Filter Exceptions' that is applied by default to new Linodes. So the choice to only use the capability from the Linode object was intentional, since that is the source of truth of whether a particular Linode is SMTP-capable. For a detailed summary of this topic, I suggest the KB article SMTP Port Restrictions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Super helpful context and surprises me also.
Got it; agree with this. |
||
linode === undefined | ||
? !account?.capabilities.includes('SMTP Enabled') | ||
: !linode.capabilities?.includes('SMTP Enabled'); | ||
|
||
// If there account was created before restrictions were put into place, | ||
// there's no need to display anything. | ||
const text = !accountCreatedAfterRestrictions( | ||
account?.active_since | ||
) ? null : ( | ||
const text = displayRestrictionText ? ( | ||
<Typography variant="body1"> | ||
SMTP ports may be restricted on this Linode. Need to send email? Review | ||
our{' '} | ||
|
@@ -46,26 +51,7 @@ export const SMTPRestrictionText = (props: SMTPRestrictionTextProps) => { | |
)} | ||
. | ||
</Typography> | ||
); | ||
|
||
// eslint-disable-next-line | ||
return <>{props.children({ text })}</>; | ||
}; | ||
|
||
export const accountCreatedAfterRestrictions = (_accountCreated?: string) => { | ||
// Default to `true` for bad input. | ||
if (!_accountCreated) { | ||
return true; | ||
} | ||
|
||
const restrictionsImplemented = new Date( | ||
MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED | ||
).getTime(); | ||
const accountCreated = new Date(_accountCreated).getTime(); | ||
|
||
if (isNaN(accountCreated)) { | ||
return true; | ||
} | ||
) : null; | ||
|
||
return accountCreated >= restrictionsImplemented; | ||
return props.children({ text }); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are directly using the SMTP status of accounts/Linodes, we no longer need this magic date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! π