Skip to content

Commit

Permalink
Show compatibility promise on setup page
Browse files Browse the repository at this point in the history
  • Loading branch information
gzdunek committed Sep 18, 2023
1 parent f0a570b commit bfacfa0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,32 @@ export default {

export function Default() {
const cluster = makeRootCluster();
const appContext = new MockAppContext();
const appContext = new MockAppContext({ appVersion: cluster.serverVersion });
appContext.clustersService.state.clusters.set(cluster.uri, cluster);
appContext.workspacesService.setState(draftState => {
draftState.rootClusterUri = cluster.uri;
draftState.workspaces[cluster.uri] = {
localClusterUri: cluster.uri,
documents: [],
location: undefined,
accessRequests: undefined,
};
});

return (
<MockAppContextProvider appContext={appContext}>
<MockWorkspaceContextProvider rootClusterUri={cluster.uri}>
<ConnectMyComputerContextProvider rootClusterUri={cluster.uri}>
<DocumentConnectMyComputerSetup />
</ConnectMyComputerContextProvider>
</MockWorkspaceContextProvider>
</MockAppContextProvider>
);
}

export function NonCompatibleAgent() {
const cluster = makeRootCluster();
const appContext = new MockAppContext({ appVersion: '3.0.0' });
appContext.clustersService.state.clusters.set(cluster.uri, cluster);
appContext.workspacesService.setState(draftState => {
draftState.rootClusterUri = cluster.uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ describe('connectMyComputerSetup', () => {
},
}),
});
const appContext = new MockAppContext({});
const appContext = new MockAppContext({
appVersion: cluster.serverVersion,
});
appContext.clustersService.state.clusters.set(cluster.uri, cluster);
appContext.workspacesService.setState(draftState => {
draftState.rootClusterUri = cluster.uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

import React, { useCallback, useEffect, useRef, useState } from 'react';
import styled from 'styled-components';
import { Box, ButtonPrimary, Flex, Text } from 'design';
import { makeEmptyAttempt, useAsync } from 'shared/hooks/useAsync';
import { wait } from 'shared/utils/wait';
Expand All @@ -34,6 +35,7 @@ import { RootClusterUri } from 'teleterm/ui/uri';

import { useAgentProperties } from '../useAgentProperties';
import { Logs } from '../Logs';
import { CompatibilityError } from '../CompatibilityPromise';

const logger = new Logger('DocumentConnectMyComputerSetup');

Expand All @@ -60,9 +62,16 @@ export function DocumentConnectMyComputerSetup() {
function Information(props: { onSetUpAgentClick(): void }) {
const { systemUsername, hostname, roleName, clusterName } =
useAgentProperties();
const { isNonCompatibleAgent } = useConnectMyComputerContext();

return (
<>
{isNonCompatibleAgent && (
<>
<CompatibilityError />
<Separator mt={3} mb={2} />
</>
)}
<Text>
The setup process will download and launch the Teleport agent, making
your computer available in the <strong>{clusterName}</strong> cluster as{' '}
Expand All @@ -84,6 +93,7 @@ function Information(props: { onSetUpAgentClick(): void }) {
css={`
display: block;
`}
disabled={isNonCompatibleAgent}
onClick={props.onSetUpAgentClick}
>
Connect
Expand Down Expand Up @@ -381,3 +391,8 @@ function StandardError(props: {
function isAccessDeniedError(error: Error): boolean {
return (error.message as string)?.includes('access denied');
}

const Separator = styled(Box)`
background: ${props => props.theme.colors.spotBackground[2]};
height: 1px;
`;

0 comments on commit bfacfa0

Please sign in to comment.