Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Remove write access to town square. Hide it when no unread messages. #831

Conversation

stanchan
Copy link
Contributor

Summary

Hide edit able elements for Town Square for non admin users when "ExperimentalTownSquareIsReadOnly": true.
Hide:

  • channel view actions: post textbox, Edit channel header, Edit channel purpose, Rename channel.
  • post view actions: reply, pin, emoji, + emoji icon.
    Also, hide town square link on the LHS when there are no unread messages and it is not favorited.

These changes were discussed in the original PRs:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Touches critical sections of the codebase (auth, posting, etc.)

cc @jason @dmeza

@dmeza
Copy link
Contributor

dmeza commented Feb 17, 2018

@jasonblais here's a gif of the changes from an admin and non admin point of view.

Some context on the changes. People began to misuse/troll through town square by changing header, display name, lots of emojis. They wanted a way out. It was compounded because of the bug of every reload going to town square and also since it was slow to load because of the amount of emojis and join messages.

The changes are:

  • For admins will have activated all functionality for town square and the channel is always visible in the LHS (no changes).
  • For non admins they can not take any action in town square and it will be hidden in the LHS if user is not on town square, there are no unread messages or it's not favorited. It's searchable through command+K.

There are changes to the mobile application that will be committed back soon. Let me know if you'd like to discuss.

townsquarereadonly

@jasonblais
Copy link
Contributor

@dmeza

Most of the proposed changes for team admins and members make sense. Have left notes for 1 - 4:

  1. Post textbox: In v4.7.0 and later, the textbox is actually disabled already. You can test it on pre-release.mattermost.com.

Would that work for your team? As it might seem as a bug to end users if the textbox is missing in Town Square.

image

  1. Emoji icon and File upload icon in post textbox: already hidden in the textbox, as part of 1) above
  2. Reply icon: would prefer to keep this. For instance, a System Admin might make an announcement, and then replies with updates. Having them in a single comment thread can be useful. That being said, commenting is disabled as shown below. Would you have thoughts?

image

  1. Hide town square on the LHS: This I'm worried about as it could be confusing to end users.

Assuming we don't allow people to misuse/troll Town Square, and that the reload issue is fixed, would people still want Town Square to be hidden from the sidebar?

The worry I have is how it might impact initial on-boarding. Could new users have an empty channel sidebar, if they're not added to channels (and Town Square isn't on LHS)?


I'll test the expected cases for system admins, team admins and members on these items, but agree with the proposed changes of not allowing non-system admins to:

  • Edit channel header
  • Edit channel purpose
  • Rename channel
  • Pin a message
  • Emoji react to a message

@jasonblais jasonblais added 1: PM Review Requires review by a product manager Setup Old Test Server Triggers the creation of a test server labels Feb 17, 2018
@jasonblais jasonblais self-requested a review February 17, 2018 18:33
@jasonblais jasonblais self-assigned this Feb 17, 2018
@dmeza
Copy link
Contributor

dmeza commented Feb 19, 2018

@jasonblais I'll show 1. and 2. and get an answer.
For 3. Admins have all the functionality and can reply, so your case would be covered. Non admin users have reply restricted.
For 4. on-boarding wouldn't be a problem for of non admins. Initially a user starts in town square and has another channel available (off-topic). If the user removes all other channels, it's taken to town square and it's visible on the LHS:

townsquarereadonly_single_channel

@jasonblais
Copy link
Contributor

3 - That's true, but would it be beneficial to allow the user to view all the replies in the comment thread on RHS?

Maybe we remove the Reply option from the [...] menu (since the non-admin can't reply to the post), but keep the reply arrow when applicable. What do you think?

  1. True. The other worry I have is inconsistency, since we don't hide any other channels at the moment.

After this PR, which limits people from misuse/trolling in Town Square, and that the reload issue is fixed, would people still want Town Square to be hidden from the sidebar?

@dmeza
Copy link
Contributor

dmeza commented Feb 20, 2018

@jasonblais I'll review 3. with the team.

  1. I understand it, but in this case town square is the only channel that's different. With this option enabled it's read only and it's the only channel you can not leave. It's already not consistent with the other channels.

One of the most requests features is to be able to leave town-square. Users can leave off-topic, but not town-square. They only want to see the channels that they joined. They say it's distracting and frustrating given the amount of users. The idea is to reduce noise as much as possible.

@jasonblais
Copy link
Contributor

Thanks @dmeza, I'll bring this up with our UX team

@herooftimeandspace
Copy link
Contributor

  1. I'm fine with notifying the user that the channel is read-only in the input box.
  2. Also good. Our change also removes the ability to react to an system admin post that has existing reactions, which 1. does not address.
  3. I don't see the value of the RHS in a read-only announcement room where only admins will post. The likelihood that a threaded conversation would be difficult to follow seems low to me.
  4. I could see gating behind a second flag like "ExperimentalHideDefaultChannelinLHS" or even turning this into a toggle in Account Settings.

@jasonblais
Copy link
Contributor

Sorry for the huge delay in replying. I think majority of what you said makes sense, but I just want to run it by Lindsay as well.

Most of the Mattermost team has been travelling this week, so our responses times are slower than usual. Bare with us.

@dmeza dmeza force-pushed the remove_write_access_to_town_hall_to_master branch from e0babc8 to 5df95b1 Compare March 2, 2018 01:26
@dmeza
Copy link
Contributor

dmeza commented Mar 2, 2018

@jasonblais rebased to latest from master and fixed conflicts. Removed the change to hide the Post textbox.

@dmeza dmeza force-pushed the remove_write_access_to_town_hall_to_master branch from 5df95b1 to d4da8cd Compare March 7, 2018 17:20
@dmeza
Copy link
Contributor

dmeza commented Mar 7, 2018

Rebased to latest from master. Added logic to hide links in header to invite and set header when "ExperimentalTownSquareIsReadOnly": true.

@jasonblais
Copy link
Contributor

jasonblais commented Mar 14, 2018

Discussed with our team.

Summarizing the above discussion below:

  1. Don't allow non-system admins to (team agrees):
  • Edit channel header
  • Edit channel purpose
  • Rename channel
  • Pin a message
  • Emoji react to a message
  1. Moreover, for non-system admins, disable textbox, and emoji icon & file upload icon in the post textbox (already implemented)

  2. @herooftimeandspace @dmeza We're wondering how much benefit is there for removing the reply arrow for read-only channels? It adds an additional case to test and maintain for upcoming releases. It might be simpler to just keep it, since there isn't any harm for the user. Thoughts?

  3. Given this setting is experimental and you're main users of it, we're okay trying this out where Town Square is hidden when it's read. We will test it on pre-release once it's merged and see how it feels. If it's against user expectations, we'll consider adding it as a separate config flag before we ship. Does that sound good?

@herooftimeandspace
Copy link
Contributor

  1. Looks good.
  2. We have this in our staging environment. I think the experience is better, thank you.
  3. As long as the reply sidebar also disables textbox, emoji icon and file upload icon, then I'm satisified. Let's listen for feedback on this though. Some users may feel misled by a button that results in no actions available.
  4. Thanks!

@jasonblais
Copy link
Contributor

  1. Yeah, it does disable them similar to the center channel. Agree we can listen to user feedback too.

@dmeza if you can help update the PR for 3 (don't hide reply arrow), I'll test this PR and we should be good to merge it soon.

@dmeza dmeza force-pushed the remove_write_access_to_town_hall_to_master branch 2 times, most recently from a561864 to 1a03d05 Compare March 15, 2018 18:37
@dmeza
Copy link
Contributor

dmeza commented Mar 15, 2018

@jasonblais rebased to latest from MM master and fixed conflicts. Made changes to allow view and click on reply for all users. Hide actions from RHS for non admins.
I think this is all the changes requested.

@jasonblais jasonblais removed the Setup Old Test Server Triggers the creation of a test server label Mar 16, 2018
@mattermost mattermost deleted a comment from mattermod Mar 16, 2018
@mattermost mattermost deleted a comment from mattermod Mar 16, 2018
@mattermost mattermost deleted a comment from mattermod Mar 16, 2018
@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Mar 16, 2018
@jasonblais
Copy link
Contributor

@jwilander Would you be able to help SSH to the spinmint and set ExperimentalTownSquareIsReadOnly in config.json to true? I'll test the changes.

I know PMs should be able to do ssh to the server and make the change, but I haven't got around to it yet..

@jwilander
Copy link
Member

@jasonblais done

@jasonblais
Copy link
Contributor

@jwilander Seems town square isn't in read-only after logging into a member account. Wondering if the config.json update went true or if there's a bug.

@@ -29,11 +31,16 @@ function mapStateToProps(state) {
const config = getConfig(state);
const enableTutorial = config.EnableTutorial === 'true';
const tutorialStep = getInt(state, Preferences.TUTORIAL_STEP, getCurrentUserId(state), TutorialSteps.FINISHED);
const channel = getCurrentChannel(state);
const isReadOnly = channel && channel.name === Constants.DEFAULT_CHANNEL &&
!UserStore.isSystemAdminForCurrentUser() &&
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be using the UserStore directly here. You could instead import the isCurrentUserSystemAdmin selector from 'mattermost-redux/selectors/entities/users` and use that instead

Copy link
Member

@hmhealey hmhealey Mar 19, 2018

Choose a reason for hiding this comment

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

Also, should this be just system admin or can a team admin still modify the town square?

@@ -29,11 +31,16 @@ function mapStateToProps(state) {
const config = getConfig(state);
const enableTutorial = config.EnableTutorial === 'true';
const tutorialStep = getInt(state, Preferences.TUTORIAL_STEP, getCurrentUserId(state), TutorialSteps.FINISHED);
const channel = getCurrentChannel(state);
const isReadOnly = channel && channel.name === Constants.DEFAULT_CHANNEL &&
Copy link
Member

Choose a reason for hiding this comment

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

Could you make this into a selector function? I think you'll need this in the mobile repo as well, so it could live in the redux repo. It could be something like isCurrentChannelReadOnly

if (selected) {
posts = getPostsForThread(state, {rootId: selected.id});
channel = getChannel(state, selected.channel_id);
isReadOnly = channel && channel.name === Constants.DEFAULT_CHANNEL &&
Copy link
Member

Choose a reason for hiding this comment

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

That selector would also be used here


return {
channelId,
deactivatedChannel: getDeactivatedChannel(state, channelId),
showTutorial: enableTutorial && tutorialStep <= TutorialSteps.INTRO_SCREENS,
isReadOnly,
Copy link
Member

Choose a reason for hiding this comment

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

If we had a selector, would it be simpler if we just had the connected components grab that value from the store themselves when they need it instead of passing it up from here? There's a lot of layout components that have been changed by this PR just to pass around isReadOnly to their children.

@@ -78,6 +78,7 @@ function mapStateToProps(state) {
unreads: getUnreads(state),
showCreatePublicChannelOption,
showCreatePrivateChannelOption,
isTownSquareReadOnly: !isSystemAdmin && config.ExperimentalTownSquareIsReadOnly === 'true',
Copy link
Member

Choose a reason for hiding this comment

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

And here

@dmeza
Copy link
Contributor

dmeza commented Mar 22, 2018

@hmhealey made the changes requested and rebased to latest from master.
This is the redux PR: mattermost/mattermost-redux#429

Copy link
Member

@jwilander jwilander left a comment

Choose a reason for hiding this comment

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

LGTM

@hmhealey hmhealey added the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Mar 26, 2018
@hmhealey
Copy link
Member

Now waiting on mattermost/mattermost-redux#429

@hmhealey hmhealey removed the 2: Dev Review Requires review by a core commiter label Mar 26, 2018
@dmeza dmeza force-pushed the remove_write_access_to_town_hall_to_master branch from 2138b71 to e8b247b Compare March 26, 2018 15:39
@dmeza
Copy link
Contributor

dmeza commented Mar 26, 2018

Rebased to latest from master and tested that everything is working because of change on mattermost/mattermost-redux#429

@dmeza
Copy link
Contributor

dmeza commented Mar 27, 2018

@jasonblais @jwilander will this be merged for 4.9?

@jasonblais
Copy link
Contributor

@dmeza Looks like it's ready to merge, but there are some conflicting files.

@jwilander @hmhealey any concerns with merging this today for v4.9?

Hide reply, pin, emoji actions in town square when "ExperimentalTownSquareIsReadOnly": true for non admin users.
Hide + emoticon icon so not action can be taken for regular users.
For regular users hide town square when ExperimentalTownSquareIsReadOnly=true and there are no unread messages and it is not favorited.
Allow reply on ReadOnly channel and hide RHS actions
Refactor to move isReadOnly logic to redux selectors. Also moved to the specific impacted component.
@dmeza dmeza force-pushed the remove_write_access_to_town_hall_to_master branch from e8b247b to 96e050a Compare March 28, 2018 04:01
@dmeza
Copy link
Contributor

dmeza commented Mar 28, 2018

@jasonblais @jwilander @hmhealey rebased to latest from master, fixed conflicts and tested that it's working.

@jasonblais jasonblais added 4: Reviews Complete All reviewers have approved the pull request and removed Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) labels Mar 28, 2018
@jwilander jwilander merged commit bafea1d into mattermost:master Mar 28, 2018
@jwilander
Copy link
Member

Awesome work on this @dmeza ! Glad it's going in :)

@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Mar 28, 2018
@lindalumitchell lindalumitchell added the Tests/Done Release tests have been written label Apr 3, 2018
@dmeza dmeza deleted the remove_write_access_to_town_hall_to_master branch December 7, 2018 18:29
hmhealey pushed a commit that referenced this pull request Aug 28, 2020
… track if a user is a System Admin (#831)

* added setUserRoles to Client4 to pass the roles in analytics 'user_actual_role' event

* only set user_actual_role in case of admin user

* check for presence of roles

* cleaner user role access, reported role names

* changed role name to be more consistent
hmhealey pushed a commit that referenced this pull request Mar 17, 2021
… track if a user is a System Admin (#831)

* added setUserRoles to Client4 to pass the roles in analytics 'user_actual_role' event

* only set user_actual_role in case of admin user

* check for presence of roles

* cleaner user role access, reported role names

* changed role name to be more consistent
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation Tests/Done Release tests have been written
Projects
None yet
8 participants