#413 Some improvements on the basic IRC widget
Merged 6 years ago by abompard. Opened 6 years ago by abompard.
abompard/fedora-hubs feature/irc  into  develop

file modified
+13 -1
@@ -123,7 +123,19 @@ 

      )

      hub.widgets.append(widget)

  

-     # TODO - set up irc widget with the right irc channel

+     # IRC

+     if irc_channel and irc_network:

+         hub.config.chat_domain = irc_network

+         hub.config.chat_channel = irc_channel

I recommend a few tests to assert this if statement works as expected.

+     hub.widgets.append(

+         hubs.models.Widget(

+             plugin='irc', index=2,

+             _config=json.dumps({

+                 'height': 450,

+             })

+         )

+     )

Should the widget append() be inside the if statement?

+ 

      # TODO - set up mailing list with the right mailing list.

  

      # TODO - set up feed with aggregate of users stuff unless we have some

@@ -8,17 +8,35 @@ 

  class IRCWidget extends React.Component {

  

    render() {

+     const domain = this.props.hub.config.chat_domain;

+     const channel = this.props.hub.config.chat_channel;

+     let content;

+     if (!domain || !channel) {

+       content = "No IRC channel configured.";

+       if (this.props.currentUser.can_config_hub) {

+         content += " Go to \"Hubs settings\" to configure it.";

+       }

Oh I suppose this is why we don't want that append inside the if block above.

+       content = (

+         <p className="text-warning p-2">

+           <em>{content}</em>

+         </p>

+       );

+     } else {

+       content = (

+         <ChatClient

+           domain={domain}

+           channel={channel}

+           height={this.props.widget.config.height}

+           />

+       );

+     }

      return (

        <WidgetChrome

          widget={this.props.widget}

          editMode={this.props.editMode}

          >

          <div className="IRCWidget">

-           <ChatClient

-             domain={this.props.hub.config.chat_domain}

-             channel={this.props.hub.config.chat_channel}

-             height={this.props.widget.config.height}

-             />

+           {content}

          </div>

        </WidgetChrome>

      );
@@ -34,6 +52,7 @@ 

  const mapStateToProps = (state) => {

    return {

      hub: state.entities.hub,

+     currentUser: state.currentUser,

    }

  };

  

This changeset gives a better error message when no IRC channel is configured, and adds the IRC widget by default for group hubs.

Should the widget append() be inside the if statement?

I recommend a few tests to assert this if statement works as expected.

Oh I suppose this is why we don't want that append inside the if block above.

rebased onto 747043b

6 years ago

Pull-Request has been merged by abompard

6 years ago