#37 Removed redundancy in Blockers
Closed 2 years ago by lbrabec. Opened 3 years ago by emma50.
fedora-qa/ emma50/landingpage reduced_redundancy_in_blockers  into  master

file modified
+14 -80
@@ -1,85 +1,19 @@ 

- import React, { Component } from "react"

- import { Row } from "reactstrap"

+ import React from "react"

  import SourceLink from "./SourceLink"

+ import Stats from "./Stats"

  

- class Blockers extends Component {

-   constructor(props) {

-     super(props)

-     this.state = { blockerbugs: {}, release: 0 }

-   }

- 

-   render() {

-     if (this.props.data)

-       return (

-         <div>

-           <h1 className="padded">

-             Fedora {this.props.release} blockers and FEs{" "}

-             <SourceLink href="https://qa.fedoraproject.org/blockerbugs/" />

-           </h1>

-           <Row>

-             <div className="col-md-6">

-               <table className="events">

-                 <thead>

-                   <tr>

-                     <td colSpan="2">

-                       <b>Beta</b>

-                     </td>

-                   </tr>

-                 </thead>

-                 <tbody>

-                   <tr>

-                     <td>Proposed Blockers</td>

-                     <td className="bugscount">{this.props.data.beta_blockers_proposed}</td>

-                   </tr>

-                   <tr>

-                     <td>Accepted Blockers</td>

-                     <td className="bugscount">{this.props.data.beta_blockers}</td>

-                   </tr>

-                   <tr>

-                     <td>Proposed FEs</td>

-                     <td className="bugscount">{this.props.data.beta_fe_proposed}</td>

-                   </tr>

-                   <tr>

-                     <td>Accepted FEs</td>

-                     <td className="bugscount">{this.props.data.beta_fe}</td>

-                   </tr>

-                 </tbody>

-               </table>

-             </div>

- 

-             <div className="col-md-6">

-               <table className="events">

-                 <thead>

-                   <tr>

-                     <td colSpan="2">

-                       <b>Final</b>

-                     </td>

-                   </tr>

-                 </thead>

-                 <tbody>

-                   <tr>

-                     <td>Proposed Blockers</td>

-                     <td className="bugscount">{this.props.data.final_blockers_proposed}</td>

-                   </tr>

-                   <tr>

-                     <td>Accepted Blockers</td>

-                     <td className="bugscount">{this.props.data.final_blockers}</td>

-                   </tr>

-                   <tr>

-                     <td>Proposed FEs</td>

-                     <td className="bugscount">{this.props.data.final_fe_proposed}</td>

-                   </tr>

-                   <tr>

-                     <td>Accepted FEs</td>

-                     <td className="bugscount">{this.props.data.final_fe}</td>

-                   </tr>

-                 </tbody>

-               </table>

-             </div>

-           </Row>

-         </div>

-       )

-   }

+ const Blockers = ({data, release}) => {

+   

+   if (data)

+     return (

+       <div>

+         <h1 className="padded">

+           Fedora {release} blockers and FEs{" "}

+           <SourceLink href="https://qa.fedoraproject.org/blockerbugs/" />

+         </h1>

+         <Stats data={data} />

+       </div>

+     )

  }

  

  export default Blockers

@@ -0,0 +1,67 @@ 

+ import React from "react"

+ import { Row } from "reactstrap"

+ 

+ const Stats = ({data}) => (

+   <Row>

+     <div className="col-md-6">

+       <table className="events">

+         <thead>

+           <tr>

+             <td colSpan="2">

+               <b>Beta</b>

+             </td>

+           </tr>

+         </thead>

+         <tbody>

+           <tr>

+             <td>Proposed Blockers</td>

+             <td className="bugscount">{data.beta_blockers_proposed}</td>

+           </tr>

+           <tr>

+             <td>Accepted Blockers</td>

+             <td className="bugscount">{data.beta_blockers}</td>

+           </tr>

+           <tr>

+             <td>Proposed FEs</td>

+             <td className="bugscount">{data.beta_fe_proposed}</td>

+           </tr>

+           <tr>

+             <td>Accepted FEs</td>

+             <td className="bugscount">{data.beta_fe}</td>

+           </tr>

+         </tbody>

+       </table>

+     </div>

+     <div className="col-md-6">

+       <table className="events">

+         <thead>

+           <tr>

+             <td colSpan="2">

+               <b>Final</b>

+             </td>

+           </tr>

+         </thead>

+         <tbody>

+           <tr>

+             <td>Proposed Blockers</td>

+             <td className="bugscount">{data.final_blockers_proposed}</td>

+           </tr>

+           <tr>

+             <td>Accepted Blockers</td>

+             <td className="bugscount">{data.final_blockers}</td>

+           </tr>

+           <tr>

+             <td>Proposed FEs</td>

+             <td className="bugscount">{data.final_fe_proposed}</td>

+           </tr>

+           <tr>

+             <td>Accepted FEs</td>

+             <td className="bugscount">{data.final_fe}</td>

+           </tr>

+         </tbody>

+       </table>

+     </div>

+   </Row>

+ )

+ 

+ export default Stats 

\ No newline at end of file

Issue

https://pagure.io/fedora-qa/landingpage/issue/6

Changes

  • Created a functional component with the name final-stat to hold final table
  • Created another functional component with the name beta-stat to hold beta table
  • Converted blocker component from a class component to a functional component because the state in constructor function is redundant
  • Implemented ES6 object destructuring of props on final-stat, beta-stat and blocker component

This change didn't reduce the redundancy of code at all. Instead of having the same code twice in src/landingpage/Blockers.js, now there is the same code in two separate files src/landingpage/stats/BetaStat.js and src/landingpage/stats/FinalStat.js. One general component for both beta and final stats is a way to go here.

Metadata Update from @lbrabec:
- Pull-request tagged with: review in progress

3 years ago

Thank you for the review @lbrabec.
I'll make the changes now.

2 new commits added

  • Merge branch 'reduced_redundancy_in_blockers' of ssh://pagure.io/forks/emma50/fedora-qa/landingpage into reduced_redundancy_in_blockers
  • Merge branch 'reduced_redundancy_in_blockers' of ssh://pagure.io/forks/emma50/fedora-qa/landingpage into reduced_redundancy_in_blockers
3 years ago

Thanks for participating in contribution period of Outreachy. This pull-request has not been selected to be merged and will be closed for housecleaning purposes. We may revisit this pull-request later, but as of now we will focus on merging pull-requests from our accepted intern.

Pull-Request has been closed by lbrabec

2 years ago