Commit Graph

49 Commits

Author SHA1 Message Date
Anders Kaseorg
f24a0a6b81 ruff: Fix RUF059 Unpacked variable is never used.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-30 16:47:54 -07:00
Sahil Batra
764f4aa2e0 groups: Use realm_for_sharding for limiting NamedUserGroup queries.
For get and filter queries of NamedUserGroup, realm_for_sharding
field is used instead of realm field, as directly using
realm_for_sharding field on NamedUserGroup makes the query faster
than using realm present on the base UserGroup table.
2025-09-23 12:15:53 -07:00
Anders Kaseorg
3f514a4e00 tools: Convert message-screenshot, thread-screenshot to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-10 15:54:28 -07:00
Lauryn Menard
cd4cc1a4b1 tools: Add help text to generate-user-messages-screenshot.
Adds general help description text for the tool that generates
cropped message screenshots for corporate pages.

Notes some of the known issues when updating these screenshots
after there have been UI changes, such as partial dates showing
and truncated channel/topic names in screenshots.
2025-08-14 16:55:13 -07:00
Lauryn Menard
d53f75d0a9 corporate: Update for/education screenshots for canonical Elena.
Fixes the screenshots on the for/education page to have the
canonical last name for the example user Elena Garcia.

Updates year in dates for screenshot content to align with when
the screenshots were taken.

Adjusts the width of the viewport for changes in the message
header bar in the web app. Also closes any alert banner at the
top of the app before navigating to the narrow so that doesn't
impact the cropped screenshot area that's computed later.

Finally, sets hover on the new conversation button so that none
of the message action buttons are visible in the message feed
when the screenshot is taken.
2025-08-14 16:55:13 -07:00
Niloth P
52fb13a2f6 generate-integration-docs-screenshot: Use bot-name option to set email.
Previously, only one bot can be created using the
generate-integration-docs-screenshot script for each integration. This
was because the bot's email was constructed using the integration's
name.

Thus, the bot-name commandline option would not work if a bot already
exists for the integration.

Now, we create the email by cleaning the bot-name value, if passed.
2025-08-04 10:00:02 -07:00
Niloth P
0d30435b29 generate-integration-docs-screenshot: Fix usage of fixtureless options.
Fixed copy paste error in loading commandline options for
fixtureless-integrations.
2025-08-04 10:00:02 -07:00
Niloth P
6a1d231689 integrations: Use directory name to get HTTP headers from fixtures.
Previously, the integration's name was directly being used.
Due to this, the GitHub Sponsors integration which is in the same module
as the GitHub integration could not be used with the
`generate-integration-docs-screenshot` script, as it would be unable to
locate the fixtures.
2025-06-09 15:59:39 -07:00
Niloth P
dac9e476f8 generate-integration-docs-screenshot: Add batch options.
Adds
- `--all-webhook` to batch process all webhook integrations,
- `--all-fixtureless` to batch process all fixtureless integrations.
2025-06-01 11:38:02 -07:00
Niloth P
866785784a generate-integration-docs-screenshot: Add fixtureless arguments.
Add a `fixtureless_group` of arguments to allow passing in the message,
topic and channel via the commandline.
By default, the script uses the screenshot config from
`integrations.py`.
2025-06-01 11:38:02 -07:00
Niloth P
287e1f8fac generate-integration-docs-screenshot: Support fixtureless integrations.
Example screenshots can now be generated for fixtureless integrations,
by sending mock messages using the topic and message text included in
the screenshot config added in the previous commit.
2025-06-01 11:38:02 -07:00
Niloth P
0b8e042627 integrations: Split the getters for fixture_path and image_path.
This is in preparation of adding support for generating screenshots of
fixtureless integrations, which would need to get image_path, without
involving fixture_path.
2025-06-01 11:38:02 -07:00
Niloth P
94a5ced243 integrations: Rename ScreenshotConfig to WebhookScreenshotConfig.
This is in preparation to differentiate the current config dataclass
(used for webhooks) from the FixturelessScreenshotConfig that will be
added for non-webhook integrations in the following commits.
2025-06-01 11:38:02 -07:00
Niloth P
9f92ae710f integrations: Remove support for non-webhook example screenshots.
- Removed the BaseScreenshotConfig dataclass, and merge it with
ScreenshotConfig dataclass.
- Simplified get_fixture_and_image_paths.
- Simplified generate_screenshot_from_config in the screenshot script.
- Deleted send_bot_mock_message.
2025-06-01 11:38:02 -07:00
Niloth P
88e92d050c generate-integration-docs-screenshot: Handle incorrect fixture_name. 2025-06-01 11:35:00 -07:00
Niloth P
68e03f8316 generate-integration-docs-screenshot: Refactor parsing of webhook args.
- Simplified the loading of commandline options into the config dict.
- Split the logic into two new functions. This is in preparation to
later commits that will parse commandline options for non-webhook
integrations by re-using the created functions.
2025-06-01 11:35:00 -07:00
Niloth P
2b358db46b generate-integration-docs-screenshot: Group options by integration type.
Group argparse arguments into common and webhook-specific options.

The common group contains arguments that apply to both webhook and
non-webhook integrations. It is not assigned a description.

A fixtureless, non-webhook group will be added later, when its arguments
are created.
2025-06-01 11:35:00 -07:00
Niloth P
3cb34ef03d generate-integration-docs-screenshot: Rename the fixture option.
to `fixture-name` to match the name of the corresponding field in the
ScreenshotConfig dataclass.

This is in preparation to loading all the options into a config dict
in a single step in a later commit.
2025-06-01 11:35:00 -07:00
Niloth P
20b0ddc4d1 generate-integration-docs-screenshot: Improve help and error messages. 2025-06-01 11:35:00 -07:00
Niloth P
802d1a57c1 generate-integration-docs-screenshot: Rename argument group for clarity.
Rename `group` to `batch_group`.

It's a mutually exclusive group that lets the user decide whether to
generate screenshots one at a time or in a batch.
2025-06-01 11:35:00 -07:00
Niloth P
af1ccbabf1 generate-integration-docs-screenshot: Remove unused argument group.
Removed `fixture_group`.
2025-06-01 11:35:00 -07:00
Niloth P
de0c24fdb8 generate-integration-docs-screenshot: Remove unused function parameter. 2025-06-01 11:35:00 -07:00
Niloth P
7e3218ee45 generate-integration-docs-screenshot: Support plain/text payloads.
All *.txt fixtures were assumed to only contain URL parameters,
now fixtures with plain/text payloads are also supported.
2025-04-16 14:05:29 -07:00
Shubham Padia
0def74b097 message: Make is_modifying_message a mandatory kwarg.
This is valuable so that one is forced to explicitly make a decision
on what is correct when adding new callers. Past experience tells us that
not having to explicitly show the decision leads to people introducing
security bugs in PRs that the maintainer has to catch in review, and our
goal for access control code should be that security bugs are hard to write.
Fixes #33688.
2025-02-28 10:10:33 -08:00
Anders Kaseorg
f223251ffe requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-14 09:42:16 -08:00
Anders Kaseorg
653b0b0436 ruff: Partially reformat Python with Ruff 0.9 (2025 style).
These are the changes that are backwards compatible with the 2024
style.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-14 09:42:16 -08:00
Anders Kaseorg
cf1eed9c22 tools: Use top-level await.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-12-10 19:16:25 -08:00
Niloth P
a0a1f55965 screenshot webhooks: Add support for multipart/form-data fixtures.
Add a common function for webhooks to convert multipart strings to dict.
This facilitates loading a multipart/form-data fixture as a file string,
and converting it.

This will allow testing integrations that use multipart/form-data,
and generating their example screenshots using a script.

Note that this only supports text fields, accommodation for binary files
is not included at the moment.
2024-12-02 18:08:58 -08:00
Niloth P
02049fbbf3 tools/screenshots: Create integration bots using display_name.
Will be adding the updated screenshots of affected integrations as soon
as the PR with the new logos and example screenshots gets merged.
2024-11-21 11:10:12 -08:00
Niloth P
29ef4a05fe tools/screenshots: Fix custom headers crash when using custom options. 2024-11-21 11:10:12 -08:00
Anders Kaseorg
01540b45b0 web: Set "type": "module" and convert various CJS files to ESM.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00
Anders Kaseorg
ff70ab441d dependencies: Remove three JS argument parsing libraries.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-10 16:00:29 -08:00
Anders Kaseorg
9c6e261861 dependencies: Remove mkdirp.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-10 15:02:52 -08:00
Anders Kaseorg
ba8b9a445b eslint: Fix unicorn/prefer-node-protocol.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-08 16:54:15 -07:00
Anders Kaseorg
91ade25ba3 python: Simplify with str.removeprefix, str.removesuffix.
These are available in Python ≥ 3.9.
https://docs.python.org/3/library/stdtypes.html#str.removeprefix

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-09-03 12:30:16 -07:00
Anders Kaseorg
3f29bc42b1 ruff: Fix B905 zip() without an explicit strict= parameter.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-07-13 22:28:22 -07:00
Anders Kaseorg
531b34cb4c ruff: Fix UP007 Use X | Y for type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-07-13 22:28:22 -07:00
Anders Kaseorg
e08a24e47f ruff: Fix UP006 Use list instead of List for type annotation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-07-13 22:28:22 -07:00
roanster007
df68d3cff6 portico: Update screenshots for "for/research" page.
This commit adds the json file and updates screenshots
for the "for/research" page.

Fixes #30128
2024-07-01 16:04:13 -07:00
roanster007
9ad5016cb2 portico: Update screenshots for "for/business", "for/open-source" pages.
This commit updates screenshots for the "for/business" and
"for/open-source" pages, and adds the script for generating
their screenshots at "screenshots/companies.json."

Fixes part of #30128
2024-07-01 16:04:13 -07:00
roanster007
425fa08636 portico: Update screenshots for "for/events" page.
This commit adds the json file and updates screenshots
for the "for/events" page.

Fixes part of #30128
2024-07-01 16:04:13 -07:00
roanster007
5c0db36ffe portico: Update screenshots for "for/education" page.
This commit adds the json file and updates screenshots
for the "for/education" page.

Fixes part of #30128
2024-07-01 16:04:13 -07:00
roanster007
00d127965e portico: Extend the script to generate thread screenshots.
This commit extends the script used to generate thread
screenshots to be able to create invite_only streams,
add starred messages, create user groups, add edited
notice to messages, and send messages from notification
bots.

The window width is updated, and background for the
screenshots is changed to white.

It is also updated so that user-avatars mapping
occurs within the script itself.

This is a prep commit to #30128
2024-07-01 16:04:13 -07:00
roanster007
3aa8b2da40 portico: Add user avatars directory.
This commit adds a user avatars directory, with avatars for some
users, which could be used while generating screenshots.
2024-07-01 16:04:13 -07:00
Alex Vandiver
08b24484d1 upload: Remove redundant acting_user_profile argument.
This argument, effectively added in 9eb47f108c, was never actually
used.
2024-06-26 16:43:11 -07:00
Vector73
8d4c42d460 tools: Replace realm_uri with realm_url.
Replaces `realm_uri` with `realm_url` in "message-screenshot" and "thread-screenshot".

Adds a missing `>` in both files.
2024-06-03 10:07:10 -07:00
roanster007
399dfe1499 portico: Generate screenshots for the /for/research page.
This commit utilizes the script added for auto-generating
screenshots of message threads to generate screenshots
for the "/for/recovery" page.

This commit adds the message data for generating the
screenshots.
2024-05-14 16:17:44 -07:00
roanster007
3f8f10fed7 portico: Add script to auto-generate message screenshots /for/research.
Previously, we manually generated screenshots on /for/research
and other landing pages, which makes them difficult to maintain.

This PR adds a script - generate-user-messages-screenshot, which
expects the path of the filename containing the thread conversation
and path where screenshot needs to be generated, and generates
screenshot at the mentioned location.

Fixes #30016
2024-05-14 16:17:44 -07:00
roanster007
0a7c0ea326 refactor: Relocate screenshots scripts to new tools/screenshots dir.
This commit relocates all the scripts in the tools directory which
are used for auto-generating screenshots to the new
tools/screenshots directory to avoid cluttering the tools/ root.
2024-05-14 16:17:44 -07:00