Commit Graph

13044 Commits

Author SHA1 Message Date
YashRE42 ca57400771 stream_create: Always insert change-stream-privacy button.
Previously, if an admin created a private stream with shared history
or a private stream with protected history, they would see the general
tab for that stream in the right side of the subscriptions_overlay as
expected, but, they would not see the pencil button to change stream
privacy unless they clicked a different stream and came back.

The reason for this has to do with how we receive events when we
create a sub. We first get an event with type "stream" and op
"create", we then get an event with type "subscription" and op "add"
ie we create the stream and then sub ourselves to it. Now, we render
`stream_settings.hbs` while handling the "stream create" event, at
this time we pass `can_change_stream_permissions` as false since
`(!sub.invite_only || sub.subscribed)` is false because we're not
subscribed yet. This causes us to skip the insertion of the
"change-stream-privacy" block which is a problem because when we're
handling the "subscription add" event, we run
`stream_ui_updates.update_change_stream_privacy_settings(sub)` which
tries to show the element via `.show()` but can't since the element
does not exist and as a result the admin user does not see the pencil
edit button.

This commit fixes the above bug by changing the template such that we
always insert the button, but conditionally apply
`style="display:none"`.

Fixes: #20345.
2021-11-24 10:49:29 -08:00
YashRE42 775018a818 stream_privacy_modal: Fix vertical alignment of radio inputs.
Fixes: #20347.
2021-11-24 10:39:23 -08:00
Sahil Batra 83a9401a89 settings_data: Remove redundant check from user_can_edit_topic_of_any_message.
We already check the everyone case in user_has_permission so there is no
need to check it in user_can_edit_topic_of_any_message.
2021-11-24 10:37:51 -08:00
Sahil Batra 8411c6eb21 settings_data: Move checks for nobody and owners_only case to user_has_permission. 2021-11-24 10:37:51 -08:00
Steve Howell 981a8d0189 templates: Clean up recipient_row.hbs. 2021-11-24 13:56:39 +00:00
Steve Howell fdd63546b2 linters: Rewrite check-templates.
I rewrote most of tools/lib/pretty-printer.py, which
was fairly easy due to being able to crib some
important details from the previous implementation.

The main motivation for the rewrite was that we weren't
handling else/elif blocks correctly, and it was difficult
to modify the previous code. The else/elif shortcomings
were somewhat historical in nature--the original parser
didn't recognize them (since they weren't in any Zulip
templates at the time), and then the pretty printer was
mostly able to hack around that due to the "nudge"
strategy. Eventually the nudge strategy became too
brittle.

The "nudge" strategy was that we would mostly trust
the existing templates, and we would just nudge over
some lines in cases of obviously faulty indentation.

Now we are bit more opinionated and rigorous, and
we basically set the indentation explicitly for any
line that is not in a code/script block. This leads
to this diff touching several templates for mostly
minor fix-ups.

We aren't completely opinionated, as we respect the
author's line wrapping decisions in many cases, and
we also allow authors not to indent blocks within
the template language's block constructs.
2021-11-23 15:55:54 -08:00
Steve Howell 4792af5682 templates: Prevent dangling end tags.
In cases where an opening tag is so long that we stretch
it to 2+ lines of code, we should try to use block-style
formatting in the template code.

Unfortunately, we have lots of legacy code that violates
this concept, so this is a timid fix.

There are also legit use cases like textarea where we
probably need to keep the ugly template syntax for things
to render properly.
2021-11-23 15:55:54 -08:00
Aman Agrawal 1e5866b785 hashchange: Update spectator hash when hash changed internally.
replaceState / pushState update browser hash without calling
hashchange. So, we need to update state manually in those cases.
2021-11-23 15:50:06 -08:00
Aman Agrawal dabc8fa99f hashchange: Remove unused function.
We are using sethash for the same purpose now.
2021-11-23 15:50:06 -08:00
Aman Agrawal 6da34fd283 hashchange: Extract function to update spectator_old_hash. 2021-11-23 15:50:06 -08:00
Ganesh Pawar a7badd726f api_key_modal: Migrate modal to Micromodal. 2021-11-23 15:43:38 -08:00
Ganesh Pawar f5fbf5f0e0 change_password: Migrate modal to dialog_widget. 2021-11-23 15:41:54 -08:00
Ganesh Pawar 3b5b98c8f9 modal: Set margin-bottom to 10px.
Bootstrap sets the margin-bottom to 20px for alert classes, which
is too much for our needs.
2021-11-23 15:41:54 -08:00
Anders Kaseorg f194ffbee8 compose_actions: Remove self-import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-11-23 15:21:48 -08:00
Tim Abbott 959c2547bb css: Delete now unused subscription-control-label class.
We're now styling these widgets identically to settings, and don't see
a special class.
2021-11-23 14:50:00 -08:00
Tim Abbott 5ac2241cf9 stream settings: Remove further differences from settings.css.
This fixes various visual glitches that resulted from reusing
components and overriding key elements of them.  The specific logical
changes are as follows:

* Delete custom checkbox positioning for stream settings; we now just
  use the common app_components.css code.
* Remove custom subscription-control-label styling; just use settings
  defaults.
* Copy the h3/h4 styling from settings.css. Ideally we'll deduplicate
  this in further cleanup.
* Add the inline property to stream_settings_checkbox elements, to
  reduce variable with settings_checkbox.hbs.
* Place every individual input inside an input-group, so that we can
  use the standard settings.css styling.
2021-11-23 14:48:17 -08:00
YashRE42 53a5942ab3 stream_types: Remove new-style class in stream_types.hbs.
Previously, the stream_edit modal relied on the new-style class to set
the margin-bottom value for stream-message-retention-days-input to 0,
in order to override the value set by bootstrap. The class new-style
is unhelpful because of its generic name, and in addition, time has /
will eroded away the significance of its name.

Hence, this commit adds the necessary rules to subscriptions.css and
removes the new-style class.

In order to make this change, this commit adds a block to
`subscriptions.css` with the selector `#stream_privacy_modal
.stream-message-retention-days-input input[type="text"]` one important
rule that this adds is `height: inherit;`. Adding this rule solves a
minor UI glitch where selecting "retain N days after posting" would
cause the save and cancel buttons to jump down by a pixel or so.

Fixes: #20222.
2021-11-23 14:11:35 -08:00
YashRE42 d1aefd4207 stream_create: Set handler on retention dropdown to show days input.
The stream creation form currently does not setup its own handler for
displaying the "N:" input when ".stream_message_retention_setting" is
changed.

Prior to e793ef7f62d280300afeeab2f4a086e99858a5a9, this form would
sometimes work as intended because stream_edit would set the handler
on this dropdown, when it was opened. However, after that commit, this
would simply never work.

Hence, in this commit, we make changes so that stream_create correctly
sets the handler on its dropdown. This causes us to repeat ourselves a
little and as such is not the cleanest solution, but this might be the
best we can do due to the complications of stream_edit opening a
modal.
2021-11-23 14:10:49 -08:00
YashRE42 6b370fee8a stream_edit: Be more specific w/ ".stream_message_retention_setting".
The stream creation form also uses the same stream_types template as
the stream privacy modal, however, it currently does not setup its own
handler for displaying the "N:" input when
".stream_message_retention_setting" is changed.

Previously, if one opened the stream creation form, then opened the
stream edit modal, and then went back to the stream creation form, the
drop down would correctly also .show() the input, because the handler
here would also target that selector. This is incorrect since we can't
always expect the stream_edit modal to be opened first, stream_create
should set up its own handlers.

Hence, as a prep commit to fixing stream_creation, and to ensure we
don't add duplicate handlers, in this commit we change all selectors
that targeted ".stream_message_retention_setting" to
"#stream_privacy_modal .stream_message_retention_setting" in this
file.
2021-11-23 14:10:49 -08:00
YashRE42 9851ed82a7 stream_settings: Remove unused rule referencing .modal-body .grey-box.
In d62e44fcba we migrate to using
micromodal for this pop up (via dialog_widget), as a result the
.modal-body style no longer applied as that class is not used.

In 55adf88e667da02284f0a6ffb6bcfdf73b5427cb we remove the grey-box
class from the stream_types template, hence even if the above wasn't
true, this rule would still not apply.

This commit thus removes this rule.
2021-11-23 14:10:49 -08:00
YashRE42 7151147907 stream_settings: Replace ul, li tags with div tags for checkboxes.
Due to reasons similar to 5de115a964, we
switch from using `ul`/`li`s to using `div`s here.
2021-11-23 14:10:49 -08:00
YashRE42 aaef190a36 stream_settings: Remove grey-box from personal tab & stream create.
Previously, the presence of the styles applied by grey-box caused a
visual disparity between the stream settings overlay and the
personal/organization settings overlay, hence, this commit removes
this class.
2021-11-23 14:10:49 -08:00
YashRE42 afa62609bc stream_types: Remove grey-box class.
Previously, the presence of the styles applied by grey-box caused a
visual disparity between this modal and similar settings in our
organisation settings view, hence, this commit removes this class.
2021-11-23 14:10:48 -08:00
Sahil Batra 5607712794 stream_settings: Disable stream-privacy choices according to org settings.
The public and private stream choices in stream creation form are disabled
according to create_public_stream_policy and create_private_stream_policy
settings. It is not needed to disable them in stream privacy modal since
only admins can change the privacy of stream and they are allowed to
create public and private streams always irrespective of the setting.
2021-11-23 13:48:58 -08:00
Sahil Batra 25ba96488d settings: Add frontend part for create_web_public_stream_policy.
This commit has the following changes -

- Adds dropdown for changing create_web_public_stream_policy and this
dropdown is visible only if settings.WEB_PUBLIC_STREAMS_ENABLED and
enable_spectator_access is set to True. This dropdown is live-udpated
on changing enable_spectator_access setting.

- The web-public stream option in stream creation form and stream privacy
modal is hidden if one of settings.WEB_PUBLIC_STREAMS_ENABLED or
enable_spectator_access is set to False except in stream privacy modal
when the stream is already web-public so that the user is not confused by
none of the options being selected.

- We disable the web-public stream option in stream creation form and
in stream-privacy modals of stream which are not already web-public
when the user is not allowed to create web-public streams as per
create_web_public_stream_policy setting.

- We use on_show parameter to hide or disable the options in stream-privacy
modal because we use the visible property of element to remove the bottom
border from last element in the stream-privacy choices and thus we have
to wait for the modal to be visible.

Fixes #20287.  Fixes #20296.
2021-11-23 13:48:43 -08:00
Sahil Batra 443d8b6a65 settings: Add user_can_create_web_public_streams function.
This commit adds user_can_create_web_public_streams function
in settings_data.js which will be used in further commits
to disable or hide the UI elements for creating web-public
streams.
2021-11-23 10:48:20 -08:00
Sahil Batra 260851cd0e settings: Show enable_spectator_access option if server-setting is enabled.
We show the "Allow creating web-public streams" setting in UI only if
settings.WEB_PUBLIC_STREAMS_ENABLED is true on the server.
2021-11-23 10:48:20 -08:00
Sahil Batra 828927b724 server_events_dispatch: Remove unnecessary 'realm_' prefix.
We do not have 'realm_' prefix to the settings used as keys
in realm_settings object, we directly use the setting name.

This commit removes the 'realm_' prefix from enable_spectator_access
setting.
2021-11-23 10:48:20 -08:00
Aman Agrawal bf93ae1644 ui: Align bottom components in the same horizontal line. 2021-11-22 18:44:32 -08:00
Aman Agrawal 061e274716 compose: Add dividers.
These improves the visual organization of the compose controls.

This is consistent with the divider we have for the navbar.
2021-11-22 18:44:32 -08:00
Aman Agrawal 2b8aa5ce2d compose: Add formatting buttons to bottom of compose box.
This is a very frequently requested feature for organizations that are
new to Markdown, that brings Zulip's UI more in line with that of
competing projects and other markdown editors like the GitHub UI.
2021-11-22 18:44:31 -08:00
Aman Agrawal 2af933678c compose: Refactor bottom part of compose box.
* We use flexbox instead of `position: relative` to align elements.
* Increase clickable area of icons using more padding.
* Increase space between elements.
* Fix mobile compose box icon alignment.
2021-11-22 18:29:45 -08:00
Aman Agrawal 29cdd99220 giphy: Use single element for tooltip and popover.
This works surprisingly unlike my previous attempts to do so.

WARN: This is a pseudo commit and should only be merged with upcoming
compose box bottom refactoring commit since the css changes required
for this change are missing here and are not required after that
commit.
2021-11-22 18:29:45 -08:00
Aman Agrawal 3423797efa compose: Remove drafts link.
Since we have the drafts button in top left corner and we need space
to insert formatting buttons in the bottom of compose box; removing
drafts link makes sense.
2021-11-22 18:29:45 -08:00
Aman Agrawal 9d0dded959 composebox_typeahead: Don't propagate after handling tab.
After we set focus manually to the send button, `tab` propagation
should be stopped.
2021-11-22 18:29:45 -08:00
Julia Bichler 32f206e1e5 popovers: Add sidebar menu to delete all drafts.
This provides a convenient interface to hide all drafts.

Fixes #19360.

However, we may want to continue to implement a button in the drafts
overlay as well for doing this operation.
2021-11-22 17:01:47 -08:00
Johan Ehinger 4207f0a299 settings: Add UI setting option for controlling invite expiration time.
Add a UI for controlling invititation expiration time, supported
options are 1 day, 3 days, 10 days and 30 days.

Fixes #19680.
2021-11-22 16:40:14 -08:00
Tim Abbott a7898ed305 stream_data: Rename id_is_subscribed to is_subscribed. 2021-11-22 15:44:30 -08:00
Tim Abbott 53d9797044 stream_data: Rename is_subscribed to is_subscribed_by_name.
Generally the stream_data module aims to do lookup by ID, not name,
wherever possible, so we should represent that in the function names.
2021-11-22 15:44:30 -08:00
Tim Abbott 043d83b434 unread: Lookup subscription status by ID.
We prefer to use IDs, not stream names, to do lookups wherever both
are available.
2021-11-22 15:39:58 -08:00
Tim Abbott 3f4d66109b stream_data: Rename get_invite_only helper method.
Since this library is intended to primarily work by user ID, we want
to name all methods that do lookups by stream name explicitly.
2021-11-22 15:32:14 -08:00
Aman Agrawal d9338a68d1 compose: Show globe icon for web public streams.
Fixes #20285.
2021-11-22 15:31:22 -08:00
Aman Agrawal a7b2c7f7ea recipient_row: Show globe icon for web public streams. 2021-11-22 15:26:21 -08:00
Aman Agrawal e8ec42bf8a stream_bar: Rename update_lock_icon_for_stream. 2021-11-22 15:26:21 -08:00
Aman Agrawal 4e5e1a2542 recipient_row: Generalize class name for icon in recipient_row. 2021-11-22 15:26:21 -08:00
Aman Agrawal a39d9ee4fd portico: Center align moving label text in input. 2021-11-22 15:02:00 -08:00
Ganesh Pawar 291aaf373f modal: Add support for modal event handlers. 2021-11-22 15:00:38 -08:00
Ganesh Pawar 8908ea99ec modal: Add support for linking the submit button to a form element. 2021-11-22 15:00:38 -08:00
Sahil Batra 1cdc7306c6 slash: Change description of /light command in typeahead. 2021-11-22 14:59:16 -08:00
YashRE42 717c4ae603 refactor: Remove duplication from reactions.add_clean_reaction.
In commit 3d86267041 we add logic to
`/shared/emoji.js` which duplicated some of the logic in this
function. Since this isn't desirable, we remove the duplicate logic
here and instead just call `emoji.get_emoji_details_for_rendering`.
2021-11-20 20:57:54 -08:00