Commit Graph

1269 Commits

Author SHA1 Message Date
Tessa Walsh
a02f7a6826
Ensure lexical sort for org names (#1958)
Fixes #1955 

Orgs list endpoint sorting now works as follows:
- Default org is always sorted first
- Name sorting now works on a lowercased version of the org names to
ensure lexical sorting

The lodash `sortBy` resorting of orgs in the "All Organizations"
dropdown list in the nav bar has also been removed so that the backend
sorting is applied instead.

Tests have been updated accordingly.
2024-07-23 13:13:04 -07:00
Ilya Kreymer
8c0321bdea
Pydantic 2.x update + type fixes + python 3.12 (#1947)
* updates pydantic to 2.x
* also update to python 3.12
* additional type fixes:
- all Optional[] types must have a default value
- update to constrained types
- URL types converted from str
- test updates

Fixes #1940
2024-07-22 17:23:03 -07:00
Ilya Kreymer
cb909ffc95
api docs cleanup + readd webhooks: (#1949)
- readd webhooks (regression from #1941)
- set order of tags in docs
- add missing tag to route
2024-07-22 09:00:59 -07:00
Ilya Kreymer
cd00f52cca
Fix queue response models + additional testing for queue + exclusions (#1948)
Follow-up to regressions from #1928, this PR:
- Fixes response models for queue endpoints, which had incorrect model
- Adds tests for queue get, queue match, and exclusions add / remove to
ensure regressions like this can be caught via tests. This involves
starting a new crawl in test_run_crawls() instead of relying on implicit
running via fixtures, make it easier to test crawl while it's running.
- Adds additional typing for crawls apis, including making
delete_crawls() have correct typing, consistent derived class override
- Adds check to ensure queue + exclusion operations can not be called
when crawl is not running
2024-07-22 09:00:23 -07:00
Ilya Kreymer
0cc99044e7 quickfix: pin mypy version to avoid issues with latest release 2024-07-19 18:30:57 -07:00
Tessa Walsh
2237120cd5
Add API endpoint to recalculate org storage (#1943)
Fixes #1942 

This process might be a bit slow for large orgs, may consider moving it to background job in #1898.
2024-07-19 18:29:20 -07:00
Tessa Walsh
6ccaad26d8
Ensure org name and slug uniqueness is case-insensitive (#1929)
Fixes #1927 

Also adds tests to ensure index is working as expected, and migration to
rename orgs that have names or slugs identical to other orgs except for
case before the new case-insensitive index is built.
2024-07-18 15:30:12 -07:00
Ilya Kreymer
b1ccdc4d16
OpenAPI Metadata for API Endpoints (#1941)
- Updates the `/docs` and `/redoc` API endpoints to have better metadata,
including using Browsertrix favicon and our logo for the `/redoc` endpoint.
- add new logo file 'docs-logo.svg' to root

Based on info at:
https://fastapi.tiangolo.com/how-to/extending-openapi/
https://fastapi.tiangolo.com/tutorial/metadata/

---------
Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
2024-07-18 11:11:38 -07:00
Tessa Walsh
3bf7967754
Fix regression with saving new workflow due to profileid type error (#1946)
Fixes #1945
2024-07-18 09:35:52 -07:00
sua yoo
f7a675ea2d
feat: Show single org status alert banner (#1937)
Resolves #1876

### Changes

Displays single banner for critical org alerts.

---------
Co-authored-by: Ilya Kreymer <ikreymer@users.noreply.github.com>
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
2024-07-17 18:50:53 -07:00
sua yoo
42b4768b59
feat: Billing UI fast-follows (#1936)
### Changes
- Updates customer portal link label
- Opens billing portal in the same tab
- Shows separate cancel date
- Makes payment failed appear as error
- Fixes crawl time quota
2024-07-17 17:13:28 -07:00
Tessa Walsh
c772ee2362
Fix response model for crawl errors API endpoint (#1939)
Follow-up fix for #1920 for crawl errors endpoint, which returns a 500
following #1928, caught in nightly tests.
2024-07-17 10:52:14 -07:00
Ilya Kreymer
335700e683
Additional typing cleanup (#1938)
Misc typing fixes, including in profiles and time functions

---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-07-17 10:49:22 -07:00
Ilya Kreymer
4db3053a9f
fix crawlFilenameTemplate + add_crawl_config cleanup (fixes #1932) (#1935)
- ensure crawlFilenameTemplate is part of the CrawlConfig model
- change CrawlConfig init to use type-safe construction
- add a run_now_internal() that is shared for starting crawl, either on
demand or from new config
- add OrgOps.can_run_crawls() to check against org quotas for crawling
- cleanup profile updates, remove _lookup_profile, only check for
EmptyStr in update

---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-07-17 10:48:25 -07:00
Ilya Kreymer
27059c91a5 version: bump to 1.11.0-beta.1 2024-07-17 10:06:49 -07:00
Tessa Walsh
60afb19472
Add API endpoint to import subscription for existing org (#1930)
Fixes #1926 

- adds /subscriptions/import endpoint for importing an existing subscription to an existing org
- add SubscriptionImport object and log as 'import' event in subscription events collection

---------
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
2024-07-16 16:17:02 -07:00
Emma Segal-Grossman
224b011070
Small UI fixes (#1934)
Fixes a few things that have been bugging me:

- Overflow buttons in list view now (mostly) take up the their full cell
area, instead of there being a couple pixels around the button where
clicking would do nothing or cause navigation

  - | before | after |
    | --- | --- |
| <img width="238" alt="Screenshot 2024-07-16 at 3 35 25 PM"
src="https://github.com/user-attachments/assets/afbda6d6-703b-4ed8-96be-a9c37660430d">
| <img width="236" alt="Screenshot 2024-07-16 at 3 35 02 PM"
src="https://github.com/user-attachments/assets/417a326a-08d2-42b2-85c3-fa007ea3bff8">
|

- Changes the class that `tab-list` uses internally so that it doesn't
conflict with Tailwind's `container` class, which prevents the tab
content from being limited at the default Tailwind container width
- Adds a couple of Tailwind plugins for styling CSS parts
(`part-[...]:`) and for arbitrary attributes (`attr-[...]:`)
2024-07-16 17:01:55 -04:00
sua yoo
5e9e897713
feat: Improve org name and slug validation (#1924)
- Verifies org slug (name) availability when creating new org
- Show org max length error when signing up
- Highlights org error field when signing up
- Fixes org name max length discrepancy
- Standardizes org slug to lowercase
2024-07-16 13:07:09 -07:00
sua yoo
79ff806352
update org url errors 2024-07-16 12:59:54 -07:00
sua yoo
8577b5bd93
update superadmin error 2024-07-16 12:59:54 -07:00
sua yoo
38a877fa8d
Update frontend/src/utils/form.ts
Co-authored-by: Emma Segal-Grossman <hi@emma.cafe>
2024-07-16 12:57:12 -07:00
Tessa Walsh
d41647e6c2
Document all API endpoints with response models (#1928)
Fixes #1920 

Adds response models to all API endpoints that were missing them,
documenting current behavior without making any changes at this stage to
standardize responses.

Follow-up work will involve adding generics to some of the response models
2024-07-16 12:48:38 -07:00
Tessa Walsh
aaf18e70a0
Add created date to Organization and fix datetimes across backend (#1921)
Fixes #1916

- Add `created` field to Organization and OrgOut, set on org creation
- Add migration to backfill `created` dates from first workflow
`created`
- Replace `datetime.now()` and `datetime.utcnow()` across app with
consistent timezone-aware `utils.dt_now` helper function, which now uses
`datetime.now(timezone.utc)`. This is in part to ensure consistency in
how we handle datetimes, and also to get ahead of timezone naive
datetime creation methods like `datetime.utcnow()` being deprecated in
Python 3.12. For more, see:
https://blog.miguelgrinberg.com/post/it-s-time-for-a-change-datetime-utcnow-is-now-deprecated
2024-07-15 19:46:32 -07:00
sua yoo
a234a36057
standarize slugify 2024-07-15 12:06:43 -07:00
sua yoo
bafc96ac94
check org slug 2024-07-15 12:05:19 -07:00
sua yoo
adea46640e
standardize max length 2024-07-15 11:40:15 -07:00
sua yoo
6f031f1059
show correct field when validating 2024-07-15 11:02:10 -07:00
sua yoo
bdd279c4f8
show validation message 2024-07-15 10:36:16 -07:00
Tessa Walsh
a546fb6fe0
Improve handling of duplicate org name/slug (#1917)
Initial implementation of #1892 

- Modifies the backend to return `duplicate_org_name` or
`duplicate_org_slug` as appropriate on a pymongo `DuplicateKeyError`
- Updates frontend to handle `duplicate_org_name`, `duplicate_org_slug`,
and `invalid_slug` error details
- Update errors to be more consistent, also return `duplicate_org_subscription.subId` for duplicate subscription instead of the more generic `already_exists`
---------
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
2024-07-10 19:24:50 -07:00
Ilya Kreymer
9a67e28f13
Adds Subscription API (#1914)
Fixes https://github.com/webrecorder/browsertrix/issues/1905

- adds a new top-level `/api/subscriptions` endpoint and SubOps handler on
the backend.
- enable subscriptions API endpoints available only if `billing_enabled` is
set in helm chart
- new POST /subscriptions/create, /subscriptions/update,
/subscriptions/cancel API endpoints
- Subscriptions mongo collection storing timestamped /subscription
API events
- GET /subscriptions/events API to get subscription events, support for filtering and sorting
- Subscription data model 
- Support for setting and handling readOnlyOnCancel on org
- /orgs/<id>/billing-portal to lookup portalUrl using external API
- subscription in org getter and list views
- mark org as readOnly for subscription status `paused_payment_failed`, clears it on status `active`

---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-07-10 17:41:16 -07:00
sua yoo
d4334d42bc
feat: Enable self-service user access to billing portal (#1908)
Resolves https://github.com/webrecorder/browsertrix/issues/1875
Follows https://github.com/webrecorder/browsertrix/pull/1914

### Changes

- When billing is enabled, adds billing tab to org settings that
displays billing information if applicable
- Handles external link to manage plan
- Refactors org quota type to always be present
- Refactors org settings into `TailwindComponent`
2024-07-10 17:11:01 -07:00
sua yoo
020c9dc1b8
feat: Allow superadmins to delete org (#1788)
Resolves https://github.com/webrecorder/browsertrix/issues/1453

<!-- Fixes #issue_number -->

### Changes

Allows super-admins to delete an org via UI
2024-07-10 17:02:00 -07:00
Tessa Walsh
5aa0ab62cb
Add nightly backend tests for org deletion while browsers are running (#1919)
Fixes #1918
2024-07-10 16:52:27 -07:00
sua yoo
4207cc0116
chore: fix frontend test dependencies 2024-07-08 17:18:16 -07:00
sua yoo
d6977069ef
feat: Manage org read-only state + superadmin view refresh (#1909)
- Displays org status in superadmin view
- Enables superadmins to update org read-only status
- Sorts orgs alphabetically
- Refactors org list to `TailwindComponent`
2024-07-08 11:41:27 -07:00
sua yoo
c97900ec2b
Merge branch 'main' into frontend-org-manage-readonly 2024-07-08 11:20:30 -07:00
sua yoo
6cd5295a31
update copy 2024-07-08 11:16:22 -07:00
sua yoo
dd63c4d980
Update frontend/src/components/orgs-list.ts
Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
2024-07-08 11:05:25 -07:00
Tessa Walsh
f1274a6ffc
Add counts for HTML pages, files, and errors to QA tab (#1913)
Fixes #1859 

Adds a section on the QA page showing the breakdown of HTML Pages, non-html files captured as pages, and failed pages in the crawl
2024-07-03 14:23:34 -07:00
sua yoo
aa961493fd
test: Remove temporary commonjs module mocks (#1910)
No issue created, but noticed issue here
ed0d489cda

### Changes

- Removes unused node module mocks and use commonjs plugin to import
modules in tests
- Fixes org form test after removing temporary stub
2024-07-03 16:45:56 -04:00
Tessa Walsh
192737ea99
Add API endpoint to delete org (#1448)
Fixes #903 

Adds superuser-only API endpoint to delete an org and all of its data

---------

Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
2024-07-03 16:00:11 -04:00
Noah
9088101ef6
feat: support both ipv6 and ipv4 nginx resolver
updates the script to generate the nginx resolver to support both ipv6 and ipv4
2024-07-03 12:00:16 -07:00
Vinzenz Sinapius
01d8bdc5e6
Crawler network policy (#1727)
Limit egress traffic from crawler/profilebrowser pods to the internet
and limited internal services like dns, redis, frontend, auth-signer on certain ports

---------
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
2024-07-03 10:55:03 -07:00
Tessa Walsh
bca05ac185 Fix typing 2024-07-03 11:25:01 -04:00
Tessa Walsh
497cfdc561
Merge branch 'main' into frontend-org-manage-readonly 2024-07-03 11:15:47 -04:00
Tessa Walsh
787ebc8738 Add one more pylint disable comment 2024-07-03 11:14:46 -04:00
Tessa Walsh
5a563d20d9 Fix linting issues 2024-07-03 11:10:10 -04:00
Tessa Walsh
d3fb33a78a Add and apply backend sorting for org list
The default org will always be sorted first, regardless of sort options.
Orgs after the first will be sorted by name ascending by default.
Sorting currently supported on name, slug, and readOnly.
2024-07-03 11:01:01 -04:00
Ilya Kreymer
1c42e21b8a
Refactor Invites and Registration, Flatten Per-User Invites (#1902)
Fixes #1432

Refactors the invite + registration system to be simpler and more consistent
with regards to existing user invites. Previously, per-user invites are
stored in the user.invites dict instead of in the invites collection,
which creates a few issues:
- Existing user do not show up in Org Invites list: #1432 
- Existing user invites also do not expire, unlike new user invites,
creating potential security issue.

Instead, existing user invites should be treated like new user invites.
This PR moves them into the same collection,
adding a `userid` field to InvitePending to match with an existing user.

If a user already exists, it will be matched by userid, instead of by
email. This allows for user to update their email while still being
invited. Note that the email of the invited existing user will not
change in the invite email. This is also by design: an admin of one org
should not be given any hint that an invited user already has an
account, such as by having their email automatically update. For an org
admin, the invite to a new or existing user should be indistinguishable.

The sha256 of invite token is stored instead of actual token for better
security.

The registration system has also been refactored with the following
changes:
- Auto-creation of new orgs for new users has been removed
- User.create_user() replaces the old User._create() and just creates the user with
additional complex logic around org auto-add
- Users are added to org in org add_user_to_org()
- Users are added to org through invites with add_user_with_invite()

Tests:
- Additional tests include verifying that existing and new pending
invites appear in the pending invites list
- Tests for `/users/invite/<token>?email=` and
`/users/me/invite/<token>` endpoints
- Deleting pending invites
- Additional tests added for user self-registration, including existing
user self-registration to default org of existing user (in nightly
tests)
2024-07-02 15:13:27 -07:00
Tessa Walsh
f076e7d9e3
Add superuser API endpoints to export and import org data (#1394)
Fixes #890 

This PR introduces new streaming superuser-only API endpoints to export
and import database information for an organization. New Adminstrator
deployment documentation on how to manage the process and copy files
between S3 buckets as needed is also included.

---------

Co-authored-by: Henry Wilkinson <henry@wilkinson.graphics>
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
2024-07-02 17:14:34 -04:00