|
| 1 | +import React from "react" |
| 2 | +import { NodeData } from "src/hooks/node-data" |
| 3 | + |
| 4 | +// TODO(tailscale/corp#13775): legacy.tsx contains a set of components |
| 5 | +// that (crudely) implement the pre-2023 web client. These are implemented |
| 6 | +// purely to ease migration to the new React-based web client, and will |
| 7 | +// eventually be completely removed. |
| 8 | + |
| 9 | +export function Header(props: { data: NodeData }) { |
| 10 | + const { data } = props |
| 11 | + |
| 12 | + return ( |
| 13 | + <header className="flex justify-between items-center min-width-0 py-2 mb-8"> |
| 14 | + <svg |
| 15 | + width="26" |
| 16 | + height="26" |
| 17 | + viewBox="0 0 23 23" |
| 18 | + fill="none" |
| 19 | + xmlns="http://www.w3.org/2000/svg" |
| 20 | + className="flex-shrink-0 mr-4" |
| 21 | + > |
| 22 | + <circle |
| 23 | + opacity="0.2" |
| 24 | + cx="3.4" |
| 25 | + cy="3.25" |
| 26 | + r="2.7" |
| 27 | + fill="currentColor" |
| 28 | + ></circle> |
| 29 | + <circle cx="3.4" cy="11.3" r="2.7" fill="currentColor"></circle> |
| 30 | + <circle |
| 31 | + opacity="0.2" |
| 32 | + cx="3.4" |
| 33 | + cy="19.5" |
| 34 | + r="2.7" |
| 35 | + fill="currentColor" |
| 36 | + ></circle> |
| 37 | + <circle cx="11.5" cy="11.3" r="2.7" fill="currentColor"></circle> |
| 38 | + <circle cx="11.5" cy="19.5" r="2.7" fill="currentColor"></circle> |
| 39 | + <circle |
| 40 | + opacity="0.2" |
| 41 | + cx="11.5" |
| 42 | + cy="3.25" |
| 43 | + r="2.7" |
| 44 | + fill="currentColor" |
| 45 | + ></circle> |
| 46 | + <circle |
| 47 | + opacity="0.2" |
| 48 | + cx="19.5" |
| 49 | + cy="3.25" |
| 50 | + r="2.7" |
| 51 | + fill="currentColor" |
| 52 | + ></circle> |
| 53 | + <circle cx="19.5" cy="11.3" r="2.7" fill="currentColor"></circle> |
| 54 | + <circle |
| 55 | + opacity="0.2" |
| 56 | + cx="19.5" |
| 57 | + cy="19.5" |
| 58 | + r="2.7" |
| 59 | + fill="currentColor" |
| 60 | + ></circle> |
| 61 | + </svg> |
| 62 | + <div className="flex items-center justify-end space-x-2 w-2/3"> |
| 63 | + {data.Profile && ( |
| 64 | + <> |
| 65 | + <div className="text-right w-full leading-4"> |
| 66 | + <h4 className="truncate leading-normal"> |
| 67 | + {data.Profile.LoginName} |
| 68 | + </h4> |
| 69 | + <div className="text-xs text-gray-500 text-right"> |
| 70 | + <a href="#" className="hover:text-gray-700 js-loginButton"> |
| 71 | + Switch account |
| 72 | + </a>{" "} |
| 73 | + |{" "} |
| 74 | + <a href="#" className="hover:text-gray-700 js-loginButton"> |
| 75 | + Reauthenticate |
| 76 | + </a>{" "} |
| 77 | + |{" "} |
| 78 | + <a href="#" className="hover:text-gray-700 js-logoutButton"> |
| 79 | + Logout |
| 80 | + </a> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + <div className="relative flex-shrink-0 w-8 h-8 rounded-full overflow-hidden"> |
| 84 | + {data.Profile.ProfilePicURL ? ( |
| 85 | + <div |
| 86 | + className="w-8 h-8 flex pointer-events-none rounded-full bg-gray-200" |
| 87 | + style={{ |
| 88 | + backgroundImage: `url(${data.Profile.ProfilePicURL})`, |
| 89 | + backgroundSize: "cover", |
| 90 | + }} |
| 91 | + /> |
| 92 | + ) : ( |
| 93 | + <div className="w-8 h-8 flex pointer-events-none rounded-full border border-gray-400 border-dashed" /> |
| 94 | + )} |
| 95 | + </div> |
| 96 | + </> |
| 97 | + )} |
| 98 | + </div> |
| 99 | + </header> |
| 100 | + ) |
| 101 | +} |
| 102 | + |
| 103 | +export function IP(props: { data: NodeData }) { |
| 104 | + const { data } = props |
| 105 | + |
| 106 | + if (!data.IP) { |
| 107 | + return null |
| 108 | + } |
| 109 | + |
| 110 | + return ( |
| 111 | + <> |
| 112 | + <div className="border border-gray-200 bg-gray-50 rounded-md p-2 pl-3 pr-3 width-full flex items-center justify-between"> |
| 113 | + <div className="flex items-center min-width-0"> |
| 114 | + <svg |
| 115 | + className="flex-shrink-0 text-gray-600 mr-3 ml-1" |
| 116 | + xmlns="http://www.w3.org/2000/svg" |
| 117 | + width="20" |
| 118 | + height="20" |
| 119 | + viewBox="0 0 24 24" |
| 120 | + fill="none" |
| 121 | + stroke="currentColor" |
| 122 | + strokeWidth="2" |
| 123 | + strokeLinecap="round" |
| 124 | + strokeLinejoin="round" |
| 125 | + > |
| 126 | + <rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect> |
| 127 | + <rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect> |
| 128 | + <line x1="6" y1="6" x2="6.01" y2="6"></line> |
| 129 | + <line x1="6" y1="18" x2="6.01" y2="18"></line> |
| 130 | + </svg> |
| 131 | + <div> |
| 132 | + <h4 className="font-semibold truncate mr-2">{data.DeviceName}</h4> |
| 133 | + </div> |
| 134 | + </div> |
| 135 | + <h5>{data.IP}</h5> |
| 136 | + </div> |
| 137 | + <p className="mt-1 ml-1 mb-6 text-xs text-gray-600"> |
| 138 | + Debug info: Tailscale {data.IPNVersion}, tun={data.TUNMode.toString()} |
| 139 | + {data.IsSynology && ( |
| 140 | + <> |
| 141 | + , DSM{data.DSMVersion} |
| 142 | + {data.TUNMode || ( |
| 143 | + <> |
| 144 | + {" "} |
| 145 | + ( |
| 146 | + <a |
| 147 | + href="https://tailscale.com/kb/1152/synology-outbound/" |
| 148 | + className="link-underline text-gray-600" |
| 149 | + target="_blank" |
| 150 | + aria-label="Configure outbound synology traffic" |
| 151 | + rel="noopener noreferrer" |
| 152 | + > |
| 153 | + outgoing access not configured |
| 154 | + </a> |
| 155 | + ) |
| 156 | + </> |
| 157 | + )} |
| 158 | + </> |
| 159 | + )} |
| 160 | + </p> |
| 161 | + </> |
| 162 | + ) |
| 163 | +} |
| 164 | + |
| 165 | +export function State(props: { data: NodeData }) { |
| 166 | + const { data } = props |
| 167 | + |
| 168 | + switch (data.Status) { |
| 169 | + case "NeedsLogin": |
| 170 | + case "NoState": |
| 171 | + if (data.IP) { |
| 172 | + return ( |
| 173 | + <> |
| 174 | + <div className="mb-6"> |
| 175 | + <p className="text-gray-700"> |
| 176 | + Your device's key has expired. Reauthenticate this device by |
| 177 | + logging in again, or{" "} |
| 178 | + <a |
| 179 | + href="https://tailscale.com/kb/1028/key-expiry" |
| 180 | + className="link" |
| 181 | + target="_blank" |
| 182 | + > |
| 183 | + learn more |
| 184 | + </a> |
| 185 | + . |
| 186 | + </p> |
| 187 | + </div> |
| 188 | + <a href="#" className="mb-4 js-loginButton" target="_blank"> |
| 189 | + <button className="button button-blue w-full"> |
| 190 | + Reauthenticate |
| 191 | + </button> |
| 192 | + </a> |
| 193 | + </> |
| 194 | + ) |
| 195 | + } else { |
| 196 | + return ( |
| 197 | + <> |
| 198 | + <div className="mb-6"> |
| 199 | + <h3 className="text-3xl font-semibold mb-3">Log in</h3> |
| 200 | + <p className="text-gray-700"> |
| 201 | + Get started by logging in to your Tailscale network. |
| 202 | + Or, learn more at{" "} |
| 203 | + <a |
| 204 | + href="https://tailscale.com/" |
| 205 | + className="link" |
| 206 | + target="_blank" |
| 207 | + > |
| 208 | + tailscale.com |
| 209 | + </a> |
| 210 | + . |
| 211 | + </p> |
| 212 | + </div> |
| 213 | + <a href="#" className="mb-4 js-loginButton" target="_blank"> |
| 214 | + <button className="button button-blue w-full">Log In</button> |
| 215 | + </a> |
| 216 | + </> |
| 217 | + ) |
| 218 | + } |
| 219 | + case "NeedsMachineAuth": |
| 220 | + return ( |
| 221 | + <div className="mb-4"> |
| 222 | + This device is authorized, but needs approval from a network admin |
| 223 | + before it can connect to the network. |
| 224 | + </div> |
| 225 | + ) |
| 226 | + default: |
| 227 | + return ( |
| 228 | + <> |
| 229 | + <div className="mb-4"> |
| 230 | + <p> |
| 231 | + You are connected! Access this device over Tailscale using the |
| 232 | + device name or IP address above. |
| 233 | + </p> |
| 234 | + </div> |
| 235 | + <div className="mb-4"> |
| 236 | + <a href="#" className="mb-4 js-advertiseExitNode"> |
| 237 | + {data.AdvertiseExitNode ? ( |
| 238 | + <button |
| 239 | + className="button button-red button-medium" |
| 240 | + id="enabled" |
| 241 | + > |
| 242 | + Stop advertising Exit Node |
| 243 | + </button> |
| 244 | + ) : ( |
| 245 | + <button |
| 246 | + className="button button-blue button-medium" |
| 247 | + id="enabled" |
| 248 | + > |
| 249 | + Advertise as Exit Node |
| 250 | + </button> |
| 251 | + )} |
| 252 | + </a> |
| 253 | + </div> |
| 254 | + </> |
| 255 | + ) |
| 256 | + } |
| 257 | +} |
| 258 | + |
| 259 | +export function Footer(props: { data: NodeData }) { |
| 260 | + const { data } = props |
| 261 | + |
| 262 | + return ( |
| 263 | + <footer className="container max-w-lg mx-auto text-center"> |
| 264 | + <a |
| 265 | + className="text-xs text-gray-500 hover:text-gray-600" |
| 266 | + href={data.LicensesURL} |
| 267 | + > |
| 268 | + Open Source Licenses |
| 269 | + </a> |
| 270 | + </footer> |
| 271 | + ) |
| 272 | +} |
0 commit comments