#513 WIP add user and team bio into the hubconfig and hub header
Closed 6 years ago by ryanlerch. Opened 6 years ago by ryanlerch.
ryanlerch/fedora-hubs user-bio  into  develop

@@ -90,6 +90,7 @@ 

      KEYS = (

          "archived", "summary", "left_width", "avatar", "visibility",

          "chat_domain", "chat_channel", "mailing_list", "calendar",

+         "bio",

      ) + tuple(p["name"] for p in DEV_PLATFORMS)

      CONVERTERS = {

          "archived": BooleanConverter(),
@@ -103,6 +104,7 @@ 

          "visibility": "public",

          "left_width": 8,

          "avatar": "",

+         "bio": "",

      }

      LISTS = ("pagure", "github")

      VALIDATORS = {

@@ -23,6 +23,14 @@ 

      id: "hubs.core.config.general.summary_help",

      defaultMessage: "This text will be displayed at the top of the hub.",

    },

+   bio: {

+     id: "hubs.core.config.general.bio",

+     defaultMessage: "Summary",

+   },

+   bio_help: {

+     id: "hubs.core.config.general.bio_help",

+     defaultMessage: "A short paragraph describing the hub",

+   },

    left_width: {

      id: "hubs.core.config.general.left_width",

      defaultMessage: "Left width",
@@ -76,7 +84,7 @@ 

  

      let invalid = {};

      if (this.props.error && this.props.error.fields) {

-       ["summary", "left_width", "visibility", "avatar"].forEach((key) => {

+       ["summary", "left_width", "visibility", "avatar", "bio"].forEach((key) => {

          invalid[key] = this.props.error.fields[key];

        });

      }
@@ -108,6 +116,28 @@ 

            </p>

          </div>

          <div className="form-group row">

+           <label htmlFor="hub-settings-general-bio">

+             <FormattedMessage {...messages.bio} />

+           </label>

+           <textarea

+             type="text"

+             name="bio"

+             className={"form-control" + (invalid.bio ? " is-invalid" : "")}

+             id="hub-settings-general-bio"

+             disabled={stillLoading}

+             onChange={this.handleChange}

+             value={this.props.hubConfig.bio || ""}

+             />

+           { invalid.bio &&

+             <div className="invalid-feedback">

+               {invalid.bio}

+             </div>

+           }

+           <p className="form-text text-muted">

+             <FormattedMessage {...messages.bio_help} />

+           </p>

+         </div>

+         <div className="form-group row">

            <label htmlFor="hub-settings-general-leftwidth">

              <FormattedMessage {...messages.left_width} />

            </label>

@@ -22,3 +22,8 @@ 

      position: absolute;

      left: 1rem;

  }

+ 

+ .HubHeader .userBioBubble{

+     background: white;

+     border-radius: 15px;

+ }

@@ -9,6 +9,7 @@ 

  

    render() {

      return (

+       <div>

        <div className="HubHeaderLeft h-100">

          <HubStats

            hub={this.props.hub}
@@ -28,9 +29,42 @@ 

            <div className="clearfix"></div>

          </div>

        </div>

+       <BioBubble

+             bio={this.props.hub.config.bio}

+             hub_type={this.props.hub.type}

+             />

+       </div>

      );

    }

  }

  HubHeaderLeft.propTypes = {

    hub: PropTypes.object.isRequired,

  }

+ 

+ class BioBubble extends React.Component {

+     render() {

+       if (this.props.bio != ""){

+         if (this.props.hub_type == 'user'){

+           return (

+             <div className="userBioBubble mt-3 mb-2 py-2 px-3">

+             {this.props.bio}

+             </div>

+           )

+         } else if (this.props.hub_type == 'team'){

+           return (

+             <div className="alert alert-info mt-3 mb-2 py-2 px-3">

+             {this.props.bio}

+             </div>

+           )

+         } else {

+           return null;

+         }

+       } else {

+         return null;

+       }

+     }

+   }

+   BioBubble.propTypes = {

+     bio: PropTypes.string.isRequired,

+     hub_type: PropTypes.string.isRequired,

+   } 

\ No newline at end of file

@@ -41,7 +41,7 @@ 

                  hub={this.props.hub}

                  />

              </div>

-             <div className={`col-md-${right_width} text-center align-self-center`}>

+             <div className={`col-md-${right_width} text-center`}>

                <HeaderRight

                  hub={this.props.hub}

                  />

file modified
+7 -21
@@ -45,6 +45,10 @@ 

      summary='The Internationalization Team',

      avatar=placekitten,

      archived=True,

+     bio='The Fedora I18N project works on internationalization (i18n)'

+         'to support the localization (l10n) of Fedora in many languages.'

+         'Translation of Fedora software and documentation are handled by'

+         'the Fedora L10N project.',

  ))

  

  widget = hubs.models.Widget(
@@ -68,20 +72,6 @@ 

      }))

  hub.widgets.append(widget)

  

- widget = hubs.models.Widget(

-     plugin='sticky', index=1, left=True, _config=json.dumps({

-         'text': """

- <p>The Fedora I18N project works on internationalization (i18n) to support the

- localization (l10n) of Fedora in many languages. Translation of Fedora software

- and documentation are handled by the Fedora L10N project.</p> <p>The goals of

- the Project are to:</p> <ul><li>Develop, package, and maintain applications

- like input methods for different languages</li> <li>Improve applications and

- utilities to support and process different languages</li> <li>Quality-assure

- that existing applications meet i18n standards</li> <li>Support the

- infrastructure of the Fedora Localization Project</li></ul>

- """,

-     }))

- hub.widgets.append(widget)

  widget = hubs.models.Widget(plugin='feed', index=2, left=True)

  hub.widgets.append(widget)

  
@@ -102,6 +92,9 @@ 

  hub.config["chat_channel"] = '#fedora-hubs'

  hub.config["pagure"] = 'fedora-hubs'

  hub.config["calendar"] = 'commops'

+ hub.config["bio"] = "Bringing more heat and light to Fedora, so you don't \

+ have to choose between 'building things' and 'building communities \

+ that build things."

  

  widget = hubs.models.Widget(

      plugin='rules', index=1, _config=json.dumps({
@@ -126,13 +119,6 @@ 

                              }))

  hub.widgets.append(widget)

  

- widget = hubs.models.Widget(

-     plugin='sticky', index=1, left=True, _config=json.dumps({

-         'text': "Bringing more heat and light to Fedora, so you don't have "

-                 "to choose between 'building things' and 'building "

-                 "communities that build things.'",

-     }))

- hub.widgets.append(widget)

  widget = hubs.models.Widget(plugin='feed', index=2, left=True)

  hub.widgets.append(widget)