ExpandableResource.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React, { Component } from "react";
  2. import styled from "styled-components";
  3. import { Context } from "shared/Context";
  4. import ResourceTab from "./ResourceTab";
  5. type PropsType = {
  6. resource: any;
  7. handleClick?: () => void;
  8. selected?: boolean;
  9. isLast?: boolean;
  10. roundAllCorners?: boolean;
  11. };
  12. type StateType = any;
  13. export default class ExpandableResource extends Component<
  14. PropsType,
  15. StateType
  16. > {
  17. render() {
  18. let { resource } = this.props;
  19. return (
  20. <ResourceTab
  21. label={resource.label}
  22. name={resource.name}
  23. status={{ label: resource.status }}
  24. >
  25. <ExpandedWrapper>
  26. <StatusSection>
  27. <StatusHeader>
  28. <Status>
  29. <Key>Status:</Key> {resource.status}
  30. </Status>
  31. <Timestamp>Updated {resource.timestamp}</Timestamp>
  32. </StatusHeader>
  33. {resource.message}
  34. </StatusSection>
  35. {Object.keys(this.props.resource.data).map(
  36. (key: string, i: number) => {
  37. return (
  38. <Pair key={i}>
  39. <Key>{key}:</Key>
  40. {this.props.resource.data[key]}
  41. </Pair>
  42. );
  43. }
  44. )}
  45. </ExpandedWrapper>
  46. </ResourceTab>
  47. );
  48. }
  49. }
  50. ExpandableResource.contextType = Context;
  51. const Timestamp = styled.div`
  52. font-size: 12px;
  53. color: #ffffff44;
  54. `;
  55. const StatusHeader = styled.div`
  56. display: flex;
  57. align-items: center;
  58. justify-content: space-between;
  59. margin-bottom: 20px;
  60. `;
  61. const Status = styled.div`
  62. display: flex;
  63. align-items: center;
  64. color: #aaaabb;
  65. `;
  66. const StatusSection = styled.div`
  67. border-radius: 8px;
  68. background: #ffffff11;
  69. font-size: 13px;
  70. padding: 20px 20px 25px;
  71. `;
  72. const ExpandedWrapper = styled.div`
  73. padding: 20px 20px 25px;
  74. `;
  75. const Pair = styled.div`
  76. margin-top: 20px;
  77. font-size: 13px;
  78. padding: 0 5px;
  79. color: #aaaabb;
  80. display: flex;
  81. align-items: center;
  82. `;
  83. const Key = styled.div`
  84. font-weight: bold;
  85. color: #ffffff;
  86. margin-right: 8px;
  87. `;