Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

a few changes to make A/B testing easier#537

Merged
dannycoates merged 1 commit intomasterfrom
choo
Aug 25, 2017
Merged

a few changes to make A/B testing easier#537
dannycoates merged 1 commit intomasterfrom
choo

Conversation

@dannycoates
Copy link
Copy Markdown
Contributor

also,

fixes #532
fixes #509
fixes #476
fixes #441
fixes #376

app.route('/legal', require('../templates/legal'));
app.route('/error', require('../templates/error'));
app.route('/blank', require('../templates/blank'));
app.route('*', require('../templates/notFound'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this locally yet, but... don't we need the /__version__ route, as well as the two health check OPs routes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are routes relative to the frontend js app. Server-only routes are in server/routes/index.js

@@ -0,0 +1,17 @@
const choo = require('choo');
const download = require('./download');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is it weird that /app/storage.js uses import * from blah syntax but these other files use require('baz')?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is weird. In order to run this code on the server, for server rendering, without transpiling some of it has to stick with require style. That being the case we might want to just go with node style require everywhere.

if (hours >= 1) {
return `${hours}h ${minutes % 60}m`;
} else if (hours === 0) {
return `${minutes}m ${seconds}s`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant remember if we have a bug or TODO for making these localize-able...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do now #538

)}</span>
<span class="popup-yes" onclick=${deleteFile}>${state.translate(
'deletePopupYes'
)}</span>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these indents look pretty wack. Not sure if that is a prettier bug or some other subtle edge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the line breaks either

}

function cancel(e) {
e.stopPropagation();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be stopProp(e); or not. Or maybe I'm missing where/how the stopProp() is actually being used, versus being a carryover from older code.

<table id="uploaded-files">
<thead>
<tr>
<!-- htmllint attr-bans="false" -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We don't use htmllint anymore, and can kill these comments. Sorry.

</tbody>
</table>
`;
const list = state.storage.files.length ? table : '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check state.storage.files.length sooner and just abort early if there are no files? May save some l20n lookups and templating, etc.

copyBtn.replaceChild(
html`<img src="${assets.get(
'check-16.svg'
)}" class="icon-check"></img>`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was just copy/pasta, but we can just use a shorthand class="icon-check" />. Seeing an </img> feels like all sorts of wrong.

const shim = document.createElement('script');
shim.src = polyfill;
shim.addEventListener('load', () => resolve(true));
shim.addEventListener('error', () => resolve(false));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember how these are being used, but should we be doing resolve(false) or just rejecting the promise?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a design choice. I'd rather return a boolean than use a try/catch block on the await.

@dannycoates dannycoates force-pushed the choo branch 2 times, most recently from 63179f8 to da82cf7 Compare August 25, 2017 16:35
<div id="download-progress">
<div id="dl-title" class="title">${state.translate(
'downloadFinish'
)}</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused on what the difference between state.translate('blah') and just setting a data-l10n-id="baz" attribute and let l20n handle translations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The l20n lib is gone. We don't want two different libs both making changes to the same dom nodes. And bonus, this lets us do l10n on the server as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, OK... in that case, we might have 2 lingering references to data-l10n-id:

$ git grep data-l10n-id

app/templates/error.js:    <img id="upload-error-img" data-l10n-id="errorAltText" src="${assets.get(
app/templates/notFound.js:        )}" id="expired-img" data-l10n-id="linkExpiredAlt"/>

app.post('/api/upload', require('./upload'));
app.get('/api/download/:id', require('./download'));
app.get('/api/exists/:id', require('./exists'));
app.post('/api/delete/:id', require('./delete'));
Copy link
Copy Markdown
Contributor

@ehuggett ehuggett Aug 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this* change have incremented the version number? (or if not, could it do so in the future?) I'm not presuming /__version__ will always be available, but i was hoping to use it for the time being as a sanity check ehuggett/send-cli#1

edit: *(the change of path for upload/download/exists/delete)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version number will change when we tag a release. For the master branch we might want to add a label to the version.json version to indicate that it may not be stable, for example "v1.1.2-master.53e822", meaning the release version will be some semver > 1.1.2. Would that help your situation?

Copy link
Copy Markdown
Contributor

@ehuggett ehuggett Aug 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version number will change when we tag a release.

Its only just dawning on me how foolish attempting to support send.dev.mozaws.net by checking the version number is 🤣 Sorry! (I can't even claim i was half asleep)

It would make the check simpler, but I will check the value of commit AND version to determine this ie if (version == "v1.1.2" && commit == "0bf8481") {ok stable} else {warn about unstable} .
https://send.dev.mozaws.net/__version__
{"commit":"ced640c","source":"https://github.com/mozilla/send/","version":"v1.1.2"}

Which will also work if someone uses the --service-local or --service for dev usage, and might still work on versions >1.1.2 if they are similar enough, so thanks for the suggestion, I didn't realise i already had everything i needed to attempt "reliable" behaviour.

@dannycoates dannycoates deleted the choo branch February 22, 2018 19:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

3 participants