Since our button is being injected into the Composer Footer,
-we receive the local id of the current draft as a prop (a read-only
-property). Since our code depends on this prop, we mark it as a requirement.
+
The ComponentRegistry manages all React components in N1.
We’re rendering a Popover with a Menu inside. These components are part
-of Edgehill’s standard nylas-component-kit library, and make it easy to build
-interfaces that match the rest of Edgehill’s UI.
+
A Store is a Flux component which contains all business logic and data
+models to be consumed by React components to render markup.
Helper method to render the button that will activate the popover. Using the
-RetinaImg component makes it easy to display an image from our package.
-RetinaImg will automatically chose the best image format for our display.
+
Notice that this file is main.cjsx rather than main.coffee. We use the
+.cjsx filetype because we use the CJSX DSL to describe markup for React to
+render. Without the CJSX, we could just name this file main.coffee instead.
Obtain the session for the current draft. The draft session provides us
-the draft object and also manages saving changes to the local cache and
-Nilas API as multiple parts of the application touch the draft.
+
Adding a @displayName to a React component helps for debugging.
Use Node’s request library to perform the translation using the Yandex API.
+
A React component’s render method returns a virtual DOM element described
+in CJSX. render is deterministic: with the same input, it will always
+render the same output. Here, the input is provided by @isPhishingAttempt.
+@state and @props are popular inputs as well.
To update the draft, we add the new body to it’s session. The session object
-automatically marshalls changes to the database and ensures that others accessing
-the same draft are notified of changes.
+
We add some more application logic to decide how to render.
if from isntnulland reply_to isntnull
+ React.createElement("div", {"className": "phishingIndicator"},
+ React.createElement("b", null, "This message looks suspicious!"),
+ React.createElement("p", null, "It originates from ", (from), " but replies will go to ", (reply_to), ".")
+ )
@@ -265,14 +189,15 @@ the same draft are notified of changes.
In this package, the MessageStore is the source of our data which will be
+the input for the render function. @isPhishingAttempt is performing some
+domain-specific application logic to prepare the data for render.
This package’s strategy to ascertain whether or not the email is a
+phishing attempt boils down to checking the replyTo attributes on
+Message models from MessageStore.
+
+
+
+
if message.replyTo? and message.replyTo.length != 0
Serialize is called when your package is about to be unmounted.
You can return a state object that will be passed back to your package
when it is re-activated.
This optional method is called when the window is shutting down,
or when your package is being updated or disabled. If your package is
@@ -308,7 +338,7 @@ subscribing to events, release them here.