ExpandableResource.tsx 2.0 KB

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