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

[NEW] Improve room types API and usages #8274

Closed
wants to merge 24 commits into from

Conversation

mrsimpson
Copy link
Collaborator

@mrsimpson mrsimpson commented Sep 23, 2017

Addresses #8246.

  • Enhances the API which can be used to add room types
  • Replaces hard-coded values in reuse-UI-components (channel-settings, members-list)
  • Extends the spotlight search to include other room types

Custom room type creation UI is explicitly excluded from this PR as this will raise additional questions and is actually independent.
It's being implemented in #8264-room-types-creation-ui, PR will be started once this PR is merged to develop.

Motivation

I implemented custom room types for an enhancement in my master. When testing, I found that I needed some modifications in generic functions (as it was coded to particular room types, probably legacy code).

This PR shall make it possible that no modifications are necessary but that the roomTyes-API generically being consumed.

@RocketChat RocketChat deleted a comment Sep 25, 2017
@@ -164,7 +165,10 @@ Template.channelSettings.onCreated(function() {
save(value, room) {
let nameValidation;
if (!RocketChat.authz.hasAllPermission('edit-room', room._id) || (room.t !== 'c' && room.t !== 'p')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we treat all of the default room types as the other "custom" types and provide sane defaults for them? That way code like this can be merged into one line and not be nested?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@graywolf336 I thought of that as well. I wanted to keep the footprint of this PR as small as possible, 100% compatible - and make the review easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mrsimpson in my opinion, I would rather take the time to review the pull request now than spend time in the future following the path of the code each time it has to be interacted with...if that makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@graywolf336 This absolutely makes sense! I would propose to modify all places as I started it. Then, in one "final" commit, I would implement the defined methods for the inbuilt room-types. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mrsimpson Whichever way is easier for you will work for me. 👍

Copy link
Collaborator Author

@mrsimpson mrsimpson Oct 1, 2017

Choose a reason for hiding this comment

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

@graywolf336 I adapted the hard-coded values with interface calls.

@graywolf336
Copy link
Contributor

I am liking where this is headed, will allow for easy customization for other people when they decide to fork Rocket.Chat and customize it. 👍


if (!config.canBeDeleted) {
config.canBeDeleted = function(room) {
return Meteor.isServer ?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@graywolf336 Unfortunately, the client- and server-side-method-signatures vary.
I preferred having this switch in the generic code compared to having dedicated client-side-files or redundantly implementing this. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@mrsimpson
Copy link
Collaborator Author

@graywolf336 Can you please verify the merge-ability? I feel I'm done with the scope I need.
I'm sure I didn't hit all the hard-coded-places, but I'd shift it until there's a need

@RocketChat RocketChat deleted a comment Oct 2, 2017
@RocketChat RocketChat deleted a comment Oct 2, 2017
@mrsimpson
Copy link
Collaborator Author

mrsimpson commented Oct 5, 2017

@graywolf336 I implemented a tabbed creation dialog in assistify@3459fa8 . As discussed, I'll make that UI-stuff part of another PR once you accept this one ;)

tabbed creation dialog

@mrsimpson mrsimpson changed the title [NEW] Enable channel settings for custom room types [NEW] Improve room types AI and usages Oct 9, 2017
…l over their definitions beyound the expected.
@geekgonecrazy geekgonecrazy changed the title [NEW] Improve room types AI and usages [NEW] Improve room types API and usages Oct 12, 2017
This allows for each different type of room to define
which setting it wants to display instead of them
being hard coded on the settings tab controller.
@@ -1,4 +1,5 @@
/* globals RocketChatTabBar */
import { RocketChatTabBar } from 'meteor/rocketchat:lib';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@graywolf336 well, it seems you're on a globals-killing-spree already ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, figured I would start the process ;)

What is this file? Great question! To make Rocket.Chat more "modular"
and to make the "rocketchat:lib" package more of a core package
with the libraries, this index file contains the exported members
for the *client* pieces of code which does include the shared
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@graywolf336 does that not affect the server as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

It does, but that file is specific to the client. The server has another one dedicated to it.

Copy link
Contributor

@graywolf336 graywolf336 left a comment

Choose a reason for hiding this comment

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

I'm excited to have these changes, the Rocket.Chat Apps will benefit greatly from this as it proves the ground for them to provide custom room types.

@graywolf336 graywolf336 added this to the 0.60.0 milestone Oct 16, 2017
if (Meteor.isClient) {
routeConfig.triggersExit = [roomExit];
}
return FlowRouter.route(config.route.path, routeConfig);

return FlowRouter.route(roomConfig.route.path, routeConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just realized, this method say we return void yet here we return whatever FlowRouter.route returns. 🤔

What are your thoughts @mrsimpson on changing this method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe it should rerun void. It’s an anti pattern in some parts of the RC code to just make the last statement of a function return - without meaningful semantics

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

E. G. Create a bunch of settings and the last statement is return this.add()

@graywolf336
Copy link
Contributor

Closing in favor of #9009 so that we can merge it due to conflicts.

@graywolf336 graywolf336 closed this Dec 4, 2017
@mrsimpson mrsimpson deleted the core/#8264-room-types branch December 7, 2020 09:08
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.

2 participants