| |
@@ -1,37 +1,45 @@
|
| |
- import React, { Component } from "react"
|
| |
- import _ from "lodash"
|
| |
+ import React, { useState } from "react";
|
| |
+ import { Collapse, Button, CardBody, Card } from "reactstrap";
|
| |
+ import _ from "lodash";
|
| |
|
| |
- class Hideable extends Component {
|
| |
- constructor(props) {
|
| |
- super(props)
|
| |
- this.id = _.uniqueId("hideable-id-")
|
| |
- }
|
| |
+ const Hideable = (props) => {
|
| |
+ const [id, setId] = useState(_.uniqueId("hideable-id-"));
|
| |
+ const [isCollapsed, setIsCollapsed] = useState(true);
|
| |
+ const toggler = () => setIsCollapsed(!isCollapsed);
|
| |
|
| |
- render() {
|
| |
- if (this.props.component_name === undefined) {
|
| |
- return <div key={this.id} />
|
| |
- }
|
| |
- return (
|
| |
- <div
|
| |
- key={this.id}
|
| |
- className={
|
| |
- this.props.config_mode
|
| |
- ? this.props.is_enabled
|
| |
- ? "border border-dark"
|
| |
- : "bgcl border border-dark"
|
| |
- : ""
|
| |
- }>
|
| |
- {this.props.children}
|
| |
- <a
|
| |
- href="#"
|
| |
- className={this.props.config_mode ? "d-block text-center badge badge-primary" : "d-none"}
|
| |
- onClick={(e) => this.props.toggle_handler(e, this.props.component_name)}
|
| |
- role="button">
|
| |
- {this.props.is_enabled ? "Disable" : "Enable"}
|
| |
- </a>
|
| |
- </div>
|
| |
- )
|
| |
+ if (props.component_name === undefined) {
|
| |
+ return <div key={id} />;
|
| |
}
|
| |
- }
|
| |
+ return (
|
| |
+ <div
|
| |
+ key={id}
|
| |
+ className={
|
| |
+ props.config_mode
|
| |
+ ? props.is_enabled
|
| |
+ ? "border border-dark"
|
| |
+ : "bgcl border border-dark"
|
| |
+ : ""
|
| |
+ }
|
| |
+ >
|
| |
+ <Button
|
| |
+ className={
|
| |
+ props.config_mode
|
| |
+ ? "d-block text-center badge badge-primary"
|
| |
+ : "d-none"
|
| |
+ }
|
| |
+ onClick={(e) => toggler(e, props.component_name)}
|
| |
+ role="button"
|
| |
+ style={{ width:'100%' }}
|
| |
+ >
|
| |
+ {isCollapsed ? "hide" : "display"}
|
| |
+ </Button>
|
| |
+ <Collapse isOpen={isCollapsed}>
|
| |
+ <Card>
|
| |
+ <CardBody>{props.children}</CardBody>
|
| |
+ </Card>
|
| |
+ </Collapse>
|
| |
+ </div>
|
| |
+ );
|
| |
+ };
|
| |
|
| |
- export default Hideable
|
| |
+ export default Hideable;
|
| |
This pull request is related to https://pagure.io/fedora-qa/landingpage/issue/24
/I have converted the disabling/enabling to the collapse functionality to reduce a button clicks to enhance the functionality /
/if a user clicks on Configure visibility of the info-cards they can collapse to display that component and hide the component /
/ if they save it will take effect on the landing page./