Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditStreamCard: Better choose when to disable stream-access options #5427

Merged
merged 8 commits into from
Jul 1, 2022

Conversation

chrisbobbe
Copy link
Contributor

See Greg's comment on CZO:

For the behavior here, I think one description of a good behavior would be that if you want to change a stream's access policy, you need to both
(a) have permission to edit the stream at all (which currently means you're an org admin/owner), and
(b) have permission to create streams with that access policy (according to realm_create_*_stream_policy.)

IIUC, that's the behavior we currently do have in the web UI and enforced by the server.

So, implement that behavior in the mobile UI.

Also disable the public and private options when creating a stream, since that hadn't been done yet.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks @chrisbobbe! This logic looks good.

The duplication in the various disabledIfNotInitialValue expressions is pretty voluminous, though, and I think it'd be better to not duplicate -- otherwise, it's the sort of code where it'd be very easy for the different copies to diverge accidentally, with e.g. a bug being fixed in one place but not the other.

I'll push an additional commit to dedupe those. Take a look, and please go ahead and merge if it looks good to you.

Comment on lines 129 to 136
const { text } = learnMoreButton;
switch (typeof text) {
case 'undefined':
return undefined;
case 'string':
return _(text);
default:
return _(text.text, text.values);
Copy link
Member

Choose a reason for hiding this comment

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

This feels like something best abstracted into a central place, with an appropriate name. I see there's a couple other examples of it above, too.

It looks like we currently don't have a handy helper for doing this unpacking of LocalizableText; mainly we just do it in the implementation of ZulipTextIntl. I'll see about doing that as a followup PR.

Copy link
Member

Choose a reason for hiding this comment

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

chrisbobbe and others added 8 commits July 1, 2022 19:34
While still making it clear to admins and owners that they can
change the policy, by making the "Learn more" button's text explicit
about what the button can help you do.

After this, the code for finding the right `message` is ready to be
pulled out into a helper that simply converts a
CreateWebPublicStreamPolicyT value into a user-friendly explanation.
We'll do that soon.
…admins

See discussion at
  https://chat.zulip.org/#narrow/stream/378-api-design/topic/.22Stream.20administrator.22.20for.20change.20stream.20type/near/1390982

In particular, Greg says:

> For the behavior here, I think one description of a good behavior
> would be that if you want to change a stream's access policy, you
> need to both
>
> (a) have permission to edit the stream at all (which currently
>     means you're an org admin/owner), and
>
> (b) have permission to create streams with that access policy
>     (according to `realm_create_*_stream_policy`.)
@chrisbobbe
Copy link
Contributor Author

Thanks for the review! Revision pushed.

@chrisbobbe chrisbobbe merged commit 71b6d46 into zulip:main Jul 1, 2022
@chrisbobbe
Copy link
Contributor Author

Take a look, and please go ahead and merge if it looks good to you.

Ah, right. Done.

@chrisbobbe chrisbobbe deleted the pr-stream-access-policy branch July 1, 2022 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants