From 5dcee953ffbd87888385c2d7e9ac56bbec0b82fb Mon Sep 17 00:00:00 2001 From: Sophie Stadler Date: Wed, 20 Mar 2024 12:52:50 -0400 Subject: [PATCH] DEVPROD-4196: Display persistent DNS name (#2303) --- src/gql/fragments/baseHost.graphql | 1 + src/gql/generated/types.ts | 5 +++++ .../useDisableSpawnExpirationCheckbox.test.tsx | 11 ++++++++++- src/pages/host/Metadata.tsx | 4 ++++ src/pages/host/index.tsx | 8 +++++--- .../spawn/spawnHost/SpawnHostButton.test.tsx | 1 + .../spawn/spawnHost/SpawnHostCard.stories.tsx | 1 + src/pages/spawn/spawnHost/SpawnHostCard.tsx | 5 ++++- .../spawn/spawnHost/SpawnHostTableActions.tsx | 2 +- .../SpawnHostCard.stories.storyshot | 16 +++++++++++++++- .../spawn/spawnVolume/SpawnVolumeModal.test.tsx | 2 ++ 11 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/gql/fragments/baseHost.graphql b/src/gql/fragments/baseHost.graphql index d745908125..788acff39b 100644 --- a/src/gql/fragments/baseHost.graphql +++ b/src/gql/fragments/baseHost.graphql @@ -1,6 +1,7 @@ fragment BaseHost on Host { hostUrl id + persistentDnsName provider startedBy status diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index 6cb14209a4..f257cc513c 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -3285,6 +3285,7 @@ export type BaseHostFragment = { __typename?: "Host"; hostUrl: string; id: string; + persistentDnsName: string; provider: string; startedBy: string; status: string; @@ -3320,6 +3321,7 @@ export type BaseSpawnHostFragment = { noExpiration: boolean; hostUrl: string; id: string; + persistentDnsName: string; provider: string; startedBy: string; status: string; @@ -4786,6 +4788,7 @@ export type EditSpawnHostMutation = { noExpiration: boolean; hostUrl: string; id: string; + persistentDnsName: string; provider: string; startedBy: string; status: string; @@ -5962,6 +5965,7 @@ export type HostQuery = { lastCommunicationTime?: Date | null; hostUrl: string; id: string; + persistentDnsName: string; provider: string; startedBy: string; status: string; @@ -6420,6 +6424,7 @@ export type MyHostsQuery = { noExpiration: boolean; hostUrl: string; id: string; + persistentDnsName: string; provider: string; startedBy: string; status: string; diff --git a/src/hooks/tests/useDisableSpawnExpirationCheckbox.test.tsx b/src/hooks/tests/useDisableSpawnExpirationCheckbox.test.tsx index 974c1820ef..e32f5b9f06 100644 --- a/src/hooks/tests/useDisableSpawnExpirationCheckbox.test.tsx +++ b/src/hooks/tests/useDisableSpawnExpirationCheckbox.test.tsx @@ -208,7 +208,10 @@ const volume = { migrating: false, }; -const myHostBase: Omit = { +const myHostBase: Omit< + MyHostsQuery["myHosts"][0], + "noExpiration" | "persistentDnsName" | "id" +> = { expiration: new Date("2021-10-28T22:37:40Z"), distro: { isVirtualWorkStation: true, @@ -248,24 +251,30 @@ const myHostsMock: ApolloMock = { { ...myHostBase, noExpiration: false, + persistentDnsName: "", id: "i-05a2f286b802fd144", __typename: "Host", }, { ...myHostBase, noExpiration: true, + persistentDnsName: + "ta-arst-workstation-123.workstations.build.10gen.cc", id: "i-09d810d09f9cd9a1d", __typename: "Host", }, { ...myHostBase, noExpiration: true, + persistentDnsName: + "ta-arst-workstation-123.workstations.build.10gen.cc", id: "i-010cb384f2a0af1f4", __typename: "Host", }, { ...myHostBase, noExpiration: false, + persistentDnsName: "", id: "i-08bc47799b6331c58", __typename: "Host", }, diff --git a/src/pages/host/Metadata.tsx b/src/pages/host/Metadata.tsx index f1476ae039..d1ed30446b 100644 --- a/src/pages/host/Metadata.tsx +++ b/src/pages/host/Metadata.tsx @@ -23,6 +23,7 @@ export const Metadata: React.FC<{ distroId, hostUrl, lastCommunicationTime, + persistentDnsName, provider, runningTask, startedBy, @@ -40,6 +41,9 @@ export const Metadata: React.FC<{ Host Details User: {user} {hostUrl && Host Name: {hostUrl}} + {persistentDnsName && ( + Persistent DNS Name: {persistentDnsName} + )} {lastCommunicationTime && ( Last Communication:{" "} diff --git a/src/pages/host/index.tsx b/src/pages/host/index.tsx index b3286d4ec1..802f53c26a 100644 --- a/src/pages/host/index.tsx +++ b/src/pages/host/index.tsx @@ -49,10 +49,12 @@ const Host: React.FC = () => { }); const host = hostData?.host; - const { distro, hostUrl, id: hostId, user } = host || {}; + const { distro, hostUrl, id: hostId, persistentDnsName, user } = host || {}; const bootstrapMethod = distro?.bootstrapMethod; const status = host?.status as HostStatus; - const sshCommand = `ssh ${user}@${hostUrl}`; + + const sshAddress = persistentDnsName || hostUrl; + const sshCommand = `ssh ${user}@${sshAddress}`; const tag = host?.tag ?? ""; const { search } = useLocation(); @@ -127,7 +129,7 @@ const Host: React.FC = () => { host={host} error={error} /> - {hostUrl && ( + {sshAddress && ( {sshCommand} diff --git a/src/pages/spawn/spawnHost/SpawnHostButton.test.tsx b/src/pages/spawn/spawnHost/SpawnHostButton.test.tsx index bdc860d5f6..7b04d4ffe6 100644 --- a/src/pages/spawn/spawnHost/SpawnHostButton.test.tsx +++ b/src/pages/spawn/spawnHost/SpawnHostButton.test.tsx @@ -88,6 +88,7 @@ const baseSpawnHost: Omit = { }, ], noExpiration: false, + persistentDnsName: "", provider: "ec2-ondemand", startedBy: "stssss.arst", tag: "evg-ubuntu1804-workstation-20201014223740-6478743249380995507", diff --git a/src/pages/spawn/spawnHost/SpawnHostCard.stories.tsx b/src/pages/spawn/spawnHost/SpawnHostCard.stories.tsx index 0568b69d20..dc56239a51 100644 --- a/src/pages/spawn/spawnHost/SpawnHostCard.stories.tsx +++ b/src/pages/spawn/spawnHost/SpawnHostCard.stories.tsx @@ -51,6 +51,7 @@ const host = { ], volumes: [], noExpiration: true, + persistentDnsName: "mohamed-khelif-abc.workstations.build.10gen.cc", provider: "ec2-ondemand", status: "running", startedBy: "mohamed.khelif", diff --git a/src/pages/spawn/spawnHost/SpawnHostCard.tsx b/src/pages/spawn/spawnHost/SpawnHostCard.tsx index c43047e611..a1b15e5f7e 100644 --- a/src/pages/spawn/spawnHost/SpawnHostCard.tsx +++ b/src/pages/spawn/spawnHost/SpawnHostCard.tsx @@ -54,7 +54,10 @@ const spawnHostCardFieldMaps = (sendEvent: SendEvent) => ({ "Started at": HostUptime, "Expires at": HostExpiration, "SSH User": (host: MyHost) => {host?.distro?.user}, - "DNS Name": (host: MyHost) => {host?.hostUrl}, + "Host Name": (host: MyHost) => {host?.hostUrl}, + "Persistent DNS Name": (host: MyHost) => ( + {host?.persistentDnsName} + ), "Working Directory": (host: MyHost) => {host?.distro?.workDir}, "Availability Zone": (host: MyHost) => {host?.availabilityZone}, "User Tags": (host: MyHost) => ( diff --git a/src/pages/spawn/spawnHost/SpawnHostTableActions.tsx b/src/pages/spawn/spawnHost/SpawnHostTableActions.tsx index ab183a4436..6e1aafbcca 100644 --- a/src/pages/spawn/spawnHost/SpawnHostTableActions.tsx +++ b/src/pages/spawn/spawnHost/SpawnHostTableActions.tsx @@ -19,7 +19,7 @@ export const SpawnHostTableActions: React.FC<{ host: MyHost }> = ({ host }) => ( diff --git a/src/pages/spawn/spawnHost/__snapshots__/SpawnHostCard.stories.storyshot b/src/pages/spawn/spawnHost/__snapshots__/SpawnHostCard.stories.storyshot index f7b6033af2..c522302530 100644 --- a/src/pages/spawn/spawnHost/__snapshots__/SpawnHostCard.stories.storyshot +++ b/src/pages/spawn/spawnHost/__snapshots__/SpawnHostCard.stories.storyshot @@ -94,7 +94,7 @@ exports[`Snapshot Tests Pages/Spawn/Spawn Host Card Default 1`] = `
- DNS Name + Host Name
@@ -102,6 +102,20 @@ exports[`Snapshot Tests Pages/Spawn/Spawn Host Card Default 1`] = `
+
+
+ Persistent DNS Name +
+
+ + mohamed-khelif-abc.workstations.build.10gen.cc + +
+
diff --git a/src/pages/spawn/spawnVolume/SpawnVolumeModal.test.tsx b/src/pages/spawn/spawnVolume/SpawnVolumeModal.test.tsx index 6468632b5c..77f0c0f29f 100644 --- a/src/pages/spawn/spawnVolume/SpawnVolumeModal.test.tsx +++ b/src/pages/spawn/spawnVolume/SpawnVolumeModal.test.tsx @@ -247,6 +247,7 @@ const myHostsMock: ApolloMock = { }, ], noExpiration: false, + persistentDnsName: "", provider: "ec2-ondemand", status: "running", startedBy: "arst.arst", @@ -334,6 +335,7 @@ const myHostsMock: ApolloMock = { }, ], noExpiration: false, + persistentDnsName: "", provider: "ec2-ondemand", status: "running", startedBy: "asrt.arsts",