2
0

ClusterInstructionsModal.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import React, { Component } from "react";
  2. import styled from "styled-components";
  3. import TabSelector from "components/TabSelector";
  4. import { Context } from "shared/Context";
  5. type PropsType = {};
  6. type StateType = {
  7. currentTab: string;
  8. currentPage: number;
  9. };
  10. const tabOptions = [{ label: "MacOS", value: "mac" }];
  11. export default class ClusterInstructionsModal extends Component<
  12. PropsType,
  13. StateType
  14. > {
  15. state = {
  16. currentTab: "mac",
  17. currentPage: 0,
  18. };
  19. renderPage = () => {
  20. switch (this.state.currentPage) {
  21. case 0:
  22. return (
  23. <Placeholder>
  24. 1. To install the Porter CLI, run the following in your terminal:
  25. <Code>/bin/bash -c "$(curl -fsSL https://install.porter.run)"</Code>
  26. Alternatively, on macOS you can use Homebrew:
  27. <Code>brew install porter-dev/porter/porter</Code>
  28. 2. Log in to the Porter CLI:
  29. <Code>
  30. porter config set-host {location.protocol + "//" + location.host}
  31. <br />
  32. porter auth login
  33. </Code>
  34. 3. Configure the Porter CLI and link your current context:
  35. <Code>
  36. porter config set-project {this.context.currentProject.id}
  37. <br />
  38. porter connect kubeconfig
  39. </Code>
  40. </Placeholder>
  41. );
  42. case 1:
  43. return (
  44. <Placeholder>
  45. <Bold>Passing a kubeconfig explicitly</Bold>
  46. You can pass a path to a kubeconfig file explicitly via:
  47. <Code>
  48. porter connect kubeconfig --kubeconfig path/to/kubeconfig
  49. </Code>
  50. <Bold>Passing a context list</Bold>
  51. You can initialize Porter with a set of contexts by passing a
  52. context list to start. The contexts that Porter will be able to
  53. access are the same as kubectl config get-contexts. For example, if
  54. there are two contexts named minikube and staging, you could connect
  55. both of them via:
  56. <Code>
  57. porter connect kubeconfig --context minikube --context staging
  58. </Code>
  59. </Placeholder>
  60. );
  61. default:
  62. }
  63. };
  64. render() {
  65. const { currentPage, currentTab } = this.state;
  66. return (
  67. <>
  68. <TabSelector
  69. options={tabOptions}
  70. currentTab={currentTab}
  71. setCurrentTab={(value: string) => {
  72. this.setState({ currentTab: value });
  73. }}
  74. />
  75. {this.renderPage()}
  76. <PageSection>
  77. <PageCount>{currentPage + 1}/2</PageCount>
  78. <i
  79. className="material-icons"
  80. onClick={() => {
  81. currentPage > 0
  82. ? this.setState({ currentPage: currentPage - 1 })
  83. : null;
  84. }}
  85. >
  86. arrow_back
  87. </i>
  88. <i
  89. className="material-icons"
  90. onClick={() => {
  91. currentPage < 1
  92. ? this.setState({ currentPage: currentPage + 1 })
  93. : null;
  94. }}
  95. >
  96. arrow_forward
  97. </i>
  98. </PageSection>
  99. </>
  100. );
  101. }
  102. }
  103. ClusterInstructionsModal.contextType = Context;
  104. const PageCount = styled.div`
  105. margin-right: 9px;
  106. user-select: none;
  107. letter-spacing: 2px;
  108. `;
  109. const PageSection = styled.div`
  110. position: absolute;
  111. bottom: 22px;
  112. right: 20px;
  113. display: flex;
  114. align-items: center;
  115. font-size: 13px;
  116. color: #ffffff;
  117. justify-content: flex-end;
  118. user-select: none;
  119. > i {
  120. font-size: 18px;
  121. margin-left: 2px;
  122. cursor: pointer;
  123. border-radius: 20px;
  124. padding: 5px;
  125. :hover {
  126. background: #ffffff11;
  127. }
  128. }
  129. `;
  130. const Code = styled.div`
  131. background: #181b21;
  132. padding: 10px 15px;
  133. border: 1px solid #ffffff44;
  134. border-radius: 5px;
  135. margin: 10px 0px 15px;
  136. color: #ffffff;
  137. font-size: 13px;
  138. user-select: text;
  139. line-height: 1em;
  140. font-family: monospace;
  141. `;
  142. const A = styled.a`
  143. color: #ffffff;
  144. text-decoration: underline;
  145. cursor: ${(props: { disabled?: boolean }) =>
  146. props.disabled ? "not-allowed" : "pointer"};
  147. `;
  148. const Placeholder = styled.div`
  149. color: #aaaabb;
  150. font-size: 13px;
  151. margin-left: 0px;
  152. margin-top: 25px;
  153. line-height: 1.6em;
  154. user-select: none;
  155. `;
  156. const Bold = styled.div`
  157. font-weight: 600;
  158. margin-bottom: 7px;
  159. `;