(joinToken);
@@ -92,7 +206,10 @@ export function DownloadScript(props: AgentStepProps) {
if (active) {
const id = window.setTimeout(() => setShowHint(true), SHOW_HINT_TIMEOUT);
- return () => window.clearTimeout(id);
+ return () => {
+ window.clearTimeout(id);
+ clearCachedJoinTokenResult([ResourceKind.Server]);
+ };
}
}, [active]);
@@ -153,17 +270,22 @@ export function DownloadScript(props: AgentStepProps) {
return (
<>
-
-
- Install and configure the Teleport Service
-
- Run the following command on the server you want to add.
-
-
-
- {hint}
+ {joinToken && (
+ <>
+
+
+ Step 2
+
+ Run the following command on the server you want to add
+
+
+
+
+ {hint}
+ >
+ )}
{
- return (
- <>
-
-
- Install and configure the Teleport Service.
-
- Run the following command on the server you want to add.
-
- {children}
-
- >
- );
-};
-
function createBashCommand(tokenId: string) {
return `sudo bash -c "$(curl -fsSL ${cfg.getNodeScriptUrl(tokenId)})"`;
}
diff --git a/web/packages/teleport/src/Discover/Shared/LabelsCreater/LabelsCreater.tsx b/web/packages/teleport/src/Discover/Shared/LabelsCreater/LabelsCreater.tsx
index dbf829e911fdd..1e733540d3c84 100644
--- a/web/packages/teleport/src/Discover/Shared/LabelsCreater/LabelsCreater.tsx
+++ b/web/packages/teleport/src/Discover/Shared/LabelsCreater/LabelsCreater.tsx
@@ -189,7 +189,7 @@ export function LabelsCreater({
})}
{
active: boolean;
start: (tokenOrTerm: JoinToken | string) => void;
result: T | null;
+ stop: () => void;
}
const pingTeleportContext =
@@ -117,6 +118,7 @@ export function PingTeleportProvider(props: {
active,
start,
result,
+ stop: () => setActive(false),
}}
>
{props.children}
@@ -137,6 +139,8 @@ export function usePingTeleport(tokenOrTerm: JoinToken | string) {
if (!ctx.active && !ctx.result) {
ctx.start(tokenOrTerm);
}
+
+ return () => ctx.stop();
}, []);
return ctx;
diff --git a/web/packages/teleport/src/Discover/Shared/useJoinTokenSuspender.ts b/web/packages/teleport/src/Discover/Shared/useJoinTokenSuspender.ts
index 18e7f9e3f007c..f82c9d4d64a6d 100644
--- a/web/packages/teleport/src/Discover/Shared/useJoinTokenSuspender.ts
+++ b/web/packages/teleport/src/Discover/Shared/useJoinTokenSuspender.ts
@@ -41,11 +41,25 @@ export function clearCachedJoinTokenResult(resourceKinds: ResourceKind[]) {
joinTokenCache.delete(resourceKinds.sort().join());
}
-export function useJoinTokenSuspender(
- resourceKinds: ResourceKind[],
- suggestedAgentMatcherLabels: ResourceLabel[] = [],
- joinMethod: JoinMethod = 'token'
-): {
+export function useJoinTokenSuspender({
+ resourceKinds,
+ suggestedAgentMatcherLabels = [],
+ joinMethod = 'token',
+ suggestedLabels = [],
+}: {
+ resourceKinds: ResourceKind[];
+ /**
+ * labels used for the agent that will be created
+ * using a join token (eg: db agent)
+ */
+ suggestedAgentMatcherLabels?: ResourceLabel[];
+ joinMethod?: JoinMethod;
+ /**
+ * labels for a non-agent resource that will be created
+ * using a join token (currently only can be applied to server resource kind).
+ */
+ suggestedLabels?: ResourceLabel[];
+}): {
joinToken: JoinToken;
reloadJoinToken: () => void;
} {
@@ -68,6 +82,7 @@ export function useJoinTokenSuspender(
roles: resourceKinds.map(resourceKindToJoinRole),
method: joinMethod,
suggestedAgentMatcherLabels,
+ suggestedLabels,
},
abortController.signal
)