* Reapply "[web] Promisify MetricsEmailController and InstitutionHubsController …"
This reverts commit ea14df1395f1dc2fa7d41fc7837849f9686425b5.
* Fix changes to node-fetch: `statusCode` -> `status` (!!)
* Update test
* Handle no-content without throwing (!)
Avoid error `Unexpected end of JSON input` when doing `response.json()` on an empty response when status is 204
Related: https://github.com/node-fetch/node-fetch/issues/165
* Also return `204` when no data in departments_data and roles_data
* Revert "Handle no-content without throwing (!)", and return null instead
This reverts commits 3baa779f7a9e64804e54a276faf865ab9252f336 and 51507a3d763d7006c8b01414a7c79bd3f3b6948b.
* Update tests: `assert_nil`
* Fixup: Update tests: assert null
* Use `fetchJSON` in Institution.fetchV1Data
* Proxy errors from server without throwing 500
GitOrigin-RevId: 9c13e293f3fed3abd2accddd1a9060ed02b96ba2
* add RestoreFileOrigin in overleaf-editor-core
* support source to be an object
* use sourceOrOrigin as param
* rename to originOrSource so the priority is more clear
* get timestamp from version
* fix test
* include version and min_count in getUpdatesFromHistory
* extractOriginOrSource util function
* fix RestoreManagerTests
GitOrigin-RevId: 0ace05a6ade2794c753a9d0bffb4f858ecc6899a
This config is superseded by `plansFeatures.js` that is imported by `plansConfig.js` which is directly used in the pug template.
GitOrigin-RevId: ae0a0e1ff7c8a64022ab378d17943fe4a7ed3b35
* Promisify LdapController
* Update tests LdapControllerTests.js
* Promisify `AuthenticationController.finishLogin`
* Simplify null checks in LdapController
* Fix: don't use spread operator in module.exports
* Make `AuthenticationController.promises.finishLogin` a promise that resolves
* Fixup: `finishLogin` does not call `next` then the promise finishes, it calls it only on errors
* Use `Modules.promises.hooks.fire`
* Revert `processPassportLogin` callback style
* Update error handling: Use `OError.tag` instead of `logger.err`
* Fix unit tests: Rely on callbacks rather than promises
* Fix: Actually call `passport.authenticate` (!!)
* Update test: fixup `passport.authenticate` mocks
This would have caught the bugs that the previous commit is solving
* Remove `.then(() => next())` in `processPassportLogin`
Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com>
---------
Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com>
GitOrigin-RevId: a7eab5f5289956aeb8f2418408958daef3511ab7
* [web] revert binary file
* use addEntityWithName if file was deleted
* todo comments
* only show Revert file in ui even if deleted
* use _revertBinaryFile function
* emit new ids when reverting
* format:fix
* await emitToRoom calls
* use EditorController.upsertFile
* remove _revertBinaryFile function
* binary file check
* mock importFile method in tests
* move findElementByPath stub
* debug ci error
* resolve with empty object as file
* fix tests
* remove await before expect()
* format:fix
* test when binary file exists and when it does not
* use "file-revert" for source
* [web] revert existing file without ranges support (#18107)
* [web] revert existing file without ranges support
* ignore document_updated_externally if file-revert
* fix test
GitOrigin-RevId: a5e0c83a7635bc7d934dec9debe916bdd4beb51e
* Create `getPaginatedEndpointIterator` to iterate each page
* Create `waitMs` util, it will replace `slowCallback`
* Make `handleAPIError` async
* Make `isAccountUsingPaypal` async
* Make `attemptInvoiceCollection` async
* Make `attemptInvoicesCollection` async
* Use `await` instead of `new Promise`
* Remove unused callbackified `attemptInvoiceCollection`
* Run `attemptInvoiceCollection` for each page instead of gathering all pages in the beginning
* Add test on fetching multiple pages of invoice
GitOrigin-RevId: 2674b18c6ca5732b873fb2bc71b515909006f93d
* Rename `RecurlyWrapper` to `promises`, as it will only contain the promises soon
* Update `apiRequest`
* Update `_parseXml`
* Update `_parseXmlAndGetAttribute`
* Update `_parse*Xml`
* Update `updateAccountEmailAddress`
* Update `checkAccountExists`
* Update `createAccount`
* Update `createBillingInfo`
* Update `setAddressAndCompanyBillingInfo`
* Update `createSubscription`
* Update `_createPaypalSubscription`
* Update `_handle422Response`
* Update `_createCreditCardSubscription`
* Update `createSubscription`
* Update `getSubscriptions`
* Update `getSubscription`
* Update `getPaginatedEndpoint`
* Update `getAccount`
* Update `getAccountActiveCoupons`
* Update `getCoupon`
* Update `getBillingInfo`
* Update `getAccountPastDueInvoices`
* Update `attemptInvoiceCollection`
* Update `updateSubscription`
* Update `createFixedAmmountCoupon`
* Update `lookupCoupon`
* Update `redeemCoupon`
* Update `extendTrial`
* Update `listAccountActiveSubscriptions`
* To find which functions to add as callbackified, I used this Regex:
`RecurlyWrapper\.(?!promises)[^.\s]*`
And after adding callbackified functions, we're left with no results with the Regex:
`RecurlyWrapper\.(?!promises|apiUrl|_buildXml|_parseXml|attemptInvoiceCollection|createFixedAmmountCoupon|getAccountActiveCoupons|getBillingInfo|getPaginatedEndpoint|getSubscription|updateAccountEmailAddress)[^.\s]*`
* Update unit tests
* Test `getSubscription` both as "promise" and as "callback"
I'm not sure if we want to generalize this.
* Fix: add missing `await`s (!!)
* Change `apiRequest` to reject errors instead of resolving it in an object
* Fixup for CollectPayPalPastDueInvoice test
* Fix: callbackify `getSubscriptions` (!!)
* Replace `.then(...)` chain by multiple `await`
* Fixup `attemptInvoicesCollection`: prevent reading length of undefined
* Use `return await` when returning promises
Per https://github.com/overleaf/internal/pull/18384#pullrequestreview-2065738771
GitOrigin-RevId: ceda755b24fd29f97a27e60ac5db9bc7e369f932
* Fix `revokeAllUserSessions` call in `_cleanupUser`
The user object should be passed, not the _id
* Change `revokeAllUserSessions` signature, take `req` and `stayLoggedIn` arguments
* Update uses of `revokeAllUserSessions`
* Fix promisified `revokeAllUserSessions` args
* Update tests
* Destroy or Regenerate the session in the end of `revokeAllUserSessions`
Per https://github.com/overleaf/internal/issues/17036#issuecomment-1938398570
* Revert "Destroy or Regenerate the session in the end of `revokeAllUserSessions`"
This reverts commit fe30734dbe45b27d2931d2e43a711d591bb85787.
* Rename `revokeAllUserSessions` to `removeSessionsFromRedis`
* Fixup tests
* Fix: add optional chaining in `req.sessionID` (!!)
GitOrigin-RevId: d41676bf00f463230af495e09c65fb9ee521f49f
* Fix: Invoices collected array length comparison
Update the code with the correct condition to respect the intent of the previous implementation ("exit with non zero code when no invoicess were processed").
See 5476f39984
However, I'm not sure if erroring when no invoices are collected is actually what we want to do.
* Wrap `collect_paypal_past_due_invoice` script and export the function
* Fixup typo `accoutns`
* Log invoices collection data before throwing
* Add note: `handleAPIError` is silencing the errors
* Create a test on `collect_paypal_past_due_invoice`
* Replace `console.log` by `@overleaf/logger` (bunyan)
Our `console.warn` show up as Errors (in red) in GCP. For example the following is an error in GCP:
```
Errors in attemptInvoiceCollection with id=2693634 OError: Recurly API returned with status code: 400
```
https://github.com/overleaf/internal/blob/5476f39/services/web/scripts/recurly/collect_paypal_past_due_invoice.js#L9
---
Does it correctly set the levels as warnings if we use `@overleaf/logger`
GitOrigin-RevId: 37c8bdf4afd8cef4706700aafb44480ec8966a74
* Revert "Merge pull request #14143 from overleaf/jlm-unsampled-compiles"
This reverts commit 2457977d61756be52db506d7c84531b22a26abe0, reversing
changes made to 3c452b3943c453707aac90d38e7b5b2ea9df0df4.
* Re-add export of `getPercentile` in SplitTestHandler.js
Was previously removed in aa8c0aadec
GitOrigin-RevId: 42c48829e7246a6bdb9dbb2d075638c1eafdf2f0
* Load correct JS for the active Bootstrap version
* Tidy up bootstrapVersion declaration
* Add Bootstrap JS to website redesign layout
* FIx error on interstitial subscriptions page
* Remove unnecessary import of jQuery and Bootstrap
* Use global entrypointScripts in bootstrap-js mixin
GitOrigin-RevId: 6b1977354a72dc69008fc0d2e3baec2f28d97f6b
* Handle error cause by `currencyDisplay: 'narrowSymbol'` in old browsers
RangeError
Value narrowSymbol out of range for Number.prototype.toLocaleString options property currencyDisplay
* Make `formatCurrencyLocalized` bulletproof
GitOrigin-RevId: 26e8abc6f9fb7c06c2d14b9d86af2d84fb9f32e3
* Add `#main-content` to some pug pages
This fixes our `skip-to-content` accessibility anchor links. Alternatively or additionally, we can set `suppressSkipToContent = true` in some pages: that will remove the anchor link in the page.
While working on this, I noticed that sometimes we still have a bit of extra nesting or components that should maybe be out of `<main>` or `#main-content`. In a future PR we can maybe update these elements to target the "real core content" of the page.
* Add `suppressSkipToContent` in confirm-email page
GitOrigin-RevId: 6cbf4112f2d1a2d8eff06f142d0c2b4f3a5d9cff
Revert "Revert "[web] Store anonymous users split test assignments in new format in session""
GitOrigin-RevId: bd48a21c17df91eda1536378d8d999a1933e83a2
* Add a unit test on `SubscriptionFormatters.formatPrice`
* Add JSDoc to `formatPrice`
Also: Name the functions before exporting:
This fixes my IDE (WebStorm) navigation
* Make `'USD'` the default param instead of reassigning
* Create `formatCurrency` function
* Use `formatCurrency` in SubscriptionFormatters
* Use an `isNoCentsCurrency` logic for `CLP` `JPY` `KRW` `VND`
And remove custom `CLP` logic and locale
* Add `locale` param to `formatPrice`
* Generate `groups.json` and `localizedPlanPricing.json`
```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```
* Update scripts/plan-prices/plans.js to generate numbers instead of localized amounts
* Generate `groups.json` and `localizedPlanPricing.json`
```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```
* Remove generation of `plans.json`
As /services/web/frontend/js/main/plans.js was removed in https://github.com/overleaf/internal/pull/12593
* Sort currencies in alphabetical order in scripts/plan-prices/plans.js
* Generate `groups.json` and `localizedPlanPricing.json`
```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```
* Use `formatCurrency` in price-summary.tsx
* Use `formatCurrency` in Subscription Pug files
* Fix unit tests SubscriptionHelperTests.js
* Remove unused `currencySymbol`
* Change to `formatCurrency` in other React components
* Add `CurrencyCode` JSDoc types
* Duplicate `formatCurrency` into services/web/app/src/util
* Wrap tests in a top-level describe block
* Use `narrowSymbol`
* Fix tests with `narrowSymbol` expects
* Revert deletion of old `formatPrice` in SubscriptionFormatters.js
* Rename `formatCurrency` -> `formatCurrencyLocalized`
* Revert deletion of `CurrencySymbol`
* Add split-test in SubscriptionController.js
* Add split-test in SubscriptionViewModelBuilder.js
* Add split-test in plans
* Add split-test in subscription-dashboard-context.tsx
* Add split-test in 4 more components
* Update tests
* Show currency and payment methods in interstitial page
* Fix `–` being printed. Use `–` instead
* Fix test with NOK
* Storybook: Fix missing `SplitTestProvider`
* Storybook: Revert "Remove unused `currencySymbol`"
This reverts commit e55387d4753f97bbf8e39e0fdc3ad17312122aaa.
* Replace `getSplitTestVariant` by `useSplitTestContext`
* Use parameterize currencyFormat in `generateInitialLocalizedGroupPrice`
* Fixup import paths of `formatCurrencyLocalized`
* Replace `% 1 === 0` by `Number.isInteger`
* Add comment explaining that any combinations of languages/currencies could happen
* Fixup after rebase: import `useSplitTestContext`
* Revert "Remove SplitTestProvider from subscription root"
This reverts commit be9f378fda715b86589ab0759737581c72321d87.
* Revert "Remove split test provider from some tests"
This reverts commit 985522932b550cfd38fa6a4f4c3d2ebaee6ff7df.
GitOrigin-RevId: 59a83cbbe0f7cc7e45f189c654e23fcf9bfa37af
* Send operations to project-history when resolving/unresolving comments
* small fixes
* added doc_id in web unit test
* Revert "added doc_id in web unit test"
This reverts commit f0b8251abfce17965d5e1b0e45d8784fcf1d9eed.
* fix mocked dependency in test
* wip: web unit tests
* document updater, reopen test
* document-updater tests
* format fix
* fix typo
* fix callsArgWith
* fix reopenThread calls in doc updater tests
* fix typos
* log error if chat api resolve failes
* log error when reopening thread
* sendStatus calls done() in tests
* using OError instead of logging
* removed timers
* preserve legacy endpoints
* update after merge
* Remove timer check in HttpControllerTest
* prettier
* added "legacy" in log
* remove metrics.timer
* fix promisify issues
* remove unused cb
GitOrigin-RevId: 849538c86996973a065c727835e93028e5429344