Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEOS-1254: update onboarding flow #2352

Merged
merged 20 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
580 changes: 298 additions & 282 deletions backend/gen/go/protos/mgmt/v1alpha1/user_account.pb.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions backend/protos/mgmt/v1alpha1/user_account.proto
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,15 @@ message SetAccountOnboardingConfigResponse {
}

message AccountOnboardingConfig {
// @deprecated - use has_completed_onboarding
bool has_created_source_connection = 1;
// @deprecated - use has_completed_onboarding
bool has_created_destination_connection = 2;
// @deprecated - use has_completed_onboarding
bool has_created_job = 3;
// @deprecated - use has_completed_onboarding
bool has_invited_members = 4;
bool has_completed_onboarding = 5;
}

message GetAccountStatusRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ func (s *IntegrationTestSuite) Test_UserAccountService_GetAccountOnboardingConfi
onboardingConfig := resp.Msg.GetConfig()
require.NotNil(s.T(), onboardingConfig)

require.False(s.T(), onboardingConfig.GetHasCreatedSourceConnection())
require.False(s.T(), onboardingConfig.GetHasCreatedDestinationConnection())
require.False(s.T(), onboardingConfig.GetHasCreatedJob())
require.False(s.T(), onboardingConfig.GetHasInvitedMembers())
require.False(s.T(), onboardingConfig.GetHasCompletedOnboarding())
}

func (s *IntegrationTestSuite) Test_UserAccountService_GetAccountOnboardingConfig_NoAccount() {
Expand All @@ -62,32 +59,23 @@ func (s *IntegrationTestSuite) Test_UserAccountService_SetAccountOnboardingConfi
onboardingConfig := resp.Msg.GetConfig()
require.NotNil(s.T(), onboardingConfig)

require.False(s.T(), onboardingConfig.GetHasCreatedSourceConnection())
require.False(s.T(), onboardingConfig.GetHasCreatedDestinationConnection())
require.False(s.T(), onboardingConfig.GetHasCreatedJob())
require.False(s.T(), onboardingConfig.GetHasInvitedMembers())
require.False(s.T(), onboardingConfig.GetHasCompletedOnboarding())
}

func (s *IntegrationTestSuite) Test_UserAccountService_SetAccountOnboardingConfig() {
accountId := s.createPersonalAccount(s.ctx, s.unauthdClients.users)

resp, err := s.unauthdClients.users.SetAccountOnboardingConfig(s.ctx, connect.NewRequest(&mgmtv1alpha1.SetAccountOnboardingConfigRequest{
AccountId: accountId, Config: &mgmtv1alpha1.AccountOnboardingConfig{
HasCreatedSourceConnection: true,
HasCreatedDestinationConnection: true,
HasCreatedJob: true,
HasInvitedMembers: true,
HasCompletedOnboarding: true,
}},
))
requireNoErrResp(s.T(), resp, err)

onboardingConfig := resp.Msg.GetConfig()
require.NotNil(s.T(), onboardingConfig)

require.True(s.T(), onboardingConfig.GetHasCreatedSourceConnection())
require.True(s.T(), onboardingConfig.GetHasCreatedDestinationConnection())
require.True(s.T(), onboardingConfig.GetHasCreatedJob())
require.True(s.T(), onboardingConfig.GetHasInvitedMembers())
require.True(s.T(), onboardingConfig.GetHasCompletedOnboarding())
}

var (
Expand Down
15 changes: 3 additions & 12 deletions backend/sql/postgresql/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -1776,24 +1776,15 @@ func (r *RetryPolicy) FromDto(dto *mgmtv1alpha1.RetryPolicy) {
}

type AccountOnboardingConfig struct {
HasCreatedSourceConnection bool `json:"hasCreatedSourceConnection"`
HasCreatedDestinationConnection bool `json:"hasCreatedDestinationConnection"`
HasCreatedJob bool `json:"hasCreatedJob"`
HasInvitedMembers bool `json:"hasInvitedMembers"`
HasCompletedOnboarding bool `json:"hasCompletedOnboarding"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine and shouldnt be a breaking change, however it may be worth thinking through the idea that if someone has already completed this v1 of onboarding, we it could be worth somehow marking this new one as true automatically.

We could also say fuck that are just require everyone see the new onboarding guide to keep it simple too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise these DTO updates are just fine because the old properties will default to false if unspecified.

}

func (t *AccountOnboardingConfig) ToDto() *mgmtv1alpha1.AccountOnboardingConfig {
return &mgmtv1alpha1.AccountOnboardingConfig{
HasCreatedSourceConnection: t.HasCreatedSourceConnection,
HasCreatedDestinationConnection: t.HasCreatedDestinationConnection,
HasCreatedJob: t.HasCreatedJob,
HasInvitedMembers: t.HasInvitedMembers,
HasCompletedOnboarding: t.HasCompletedOnboarding,
}
}

func (t *AccountOnboardingConfig) FromDto(dto *mgmtv1alpha1.AccountOnboardingConfig) {
t.HasCreatedSourceConnection = dto.GetHasCreatedSourceConnection()
t.HasCreatedDestinationConnection = dto.GetHasCreatedDestinationConnection()
t.HasCreatedJob = dto.GetHasCreatedJob()
t.HasInvitedMembers = dto.GetHasInvitedMembers()
t.HasCompletedOnboarding = dto.GetHasCompletedOnboarding()
}
18 changes: 15 additions & 3 deletions docs/protos/data/proto_docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -13757,7 +13757,7 @@
"fields": [
{
"name": "has_created_source_connection",
"description": "",
"description": "@deprecated - use has_completed_onboarding",
"label": "",
"type": "bool",
"longType": "bool",
Expand All @@ -13769,7 +13769,7 @@
},
{
"name": "has_created_destination_connection",
"description": "",
"description": "@deprecated - use has_completed_onboarding",
"label": "",
"type": "bool",
"longType": "bool",
Expand All @@ -13781,7 +13781,7 @@
},
{
"name": "has_created_job",
"description": "",
"description": "@deprecated - use has_completed_onboarding",
"label": "",
"type": "bool",
"longType": "bool",
Expand All @@ -13793,6 +13793,18 @@
},
{
"name": "has_invited_members",
"description": "@deprecated - use has_completed_onboarding",
"label": "",
"type": "bool",
"longType": "bool",
"fullType": "bool",
"ismap": false,
"isoneof": false,
"oneofdecl": "",
"defaultValue": ""
},
{
"name": "has_completed_onboarding",
"description": "",
"label": "",
"type": "bool",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ButtonText from '@/components/ButtonText';
import { PasswordInput } from '@/components/PasswordComponent';
import Spinner from '@/components/Spinner';
import RequiredLabel from '@/components/labels/RequiredLabel';
import { buildAccountOnboardingConfig } from '@/components/onboarding-checklist/OnboardingChecklist';
import { useAccount } from '@/components/providers/account-provider';
import SkeletonForm from '@/components/skeleton/SkeletonForm';
import SwitchCard from '@/components/switches/SwitchCard';
Expand All @@ -25,22 +24,13 @@ import {
AWS_FORM_SCHEMA,
CreateConnectionFormContext,
} from '@/yup-validations/connections';
import {
createConnectQueryKey,
useMutation,
useQuery,
} from '@connectrpc/connect-query';
import { createConnectQueryKey, useMutation } from '@connectrpc/connect-query';
import { yupResolver } from '@hookform/resolvers/yup';
import {
GetAccountOnboardingConfigResponse,
GetConnectionResponse,
} from '@neosync/sdk';
import { GetConnectionResponse } from '@neosync/sdk';
import {
createConnection,
getAccountOnboardingConfig,
getConnection,
isConnectionNameAvailable,
setAccountOnboardingConfig,
} from '@neosync/sdk/connectquery';
import { useQueryClient } from '@tanstack/react-query';
import { useRouter, useSearchParams } from 'next/navigation';
Expand All @@ -55,16 +45,7 @@ export default function AwsS3Form() {
const { account } = useAccount();
const sourceConnId = searchParams.get('sourceId');
const [isLoading, setIsLoading] = useState<boolean>();

const { data: onboardingData } = useQuery(
getAccountOnboardingConfig,
{ accountId: account?.id ?? '' },
{ enabled: !!account?.id }
);
const queryclient = useQueryClient();
const { mutateAsync: setOnboardingConfigAsync } = useMutation(
setAccountOnboardingConfig
);
const { mutateAsync: isConnectionNameAvailableAsync } = useMutation(
isConnectionNameAvailable
);
Expand Down Expand Up @@ -96,63 +77,6 @@ export default function AwsS3Form() {
connectionConfig: buildConnectionConfigAwsS3(values),
});

// updates the onboarding data
if (
onboardingData?.config?.hasCreatedSourceConnection &&
!onboardingData?.config.hasCreatedDestinationConnection
) {
try {
const resp = await setOnboardingConfigAsync({
accountId: account.id,
config: buildAccountOnboardingConfig({
hasCreatedSourceConnection:
onboardingData.config.hasCreatedSourceConnection,
hasCreatedDestinationConnection: true,
hasCreatedJob: onboardingData.config.hasCreatedJob,
hasInvitedMembers: onboardingData.config.hasInvitedMembers,
}),
});
queryclient.setQueryData(
createConnectQueryKey(getAccountOnboardingConfig, {
accountId: account.id,
}),
new GetAccountOnboardingConfigResponse({
config: resp.config,
})
);
} catch (e) {
toast.error('Unable to update onboarding status!', {
description: getErrorMessage(e),
});
}
} else {
try {
const resp = await setOnboardingConfigAsync({
accountId: account.id,
config: buildAccountOnboardingConfig({
hasCreatedSourceConnection: true,
hasCreatedDestinationConnection:
onboardingData?.config?.hasCreatedSourceConnection ?? true,
hasCreatedJob: onboardingData?.config?.hasCreatedJob ?? true,
hasInvitedMembers:
onboardingData?.config?.hasInvitedMembers ?? true,
}),
});
queryclient.setQueryData(
createConnectQueryKey(getAccountOnboardingConfig, {
accountId: account.id,
}),
new GetAccountOnboardingConfigResponse({
config: resp.config,
})
);
} catch (e) {
toast.error('Unable to update onboarding status!', {
description: getErrorMessage(e),
});
}
}

const returnTo = searchParams.get('returnTo');
if (returnTo) {
router.push(returnTo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ButtonText from '@/components/ButtonText';
import { PasswordInput } from '@/components/PasswordComponent';
import Spinner from '@/components/Spinner';
import RequiredLabel from '@/components/labels/RequiredLabel';
import { buildAccountOnboardingConfig } from '@/components/onboarding-checklist/OnboardingChecklist';
import PermissionsDialog from '@/components/permissions/PermissionsDialog';
import { useAccount } from '@/components/providers/account-provider';
import SkeletonForm from '@/components/skeleton/SkeletonForm';
Expand Down Expand Up @@ -32,24 +31,17 @@ import {
CreateConnectionFormContext,
DynamoDbFormValues,
} from '@/yup-validations/connections';
import {
createConnectQueryKey,
useMutation,
useQuery,
} from '@connectrpc/connect-query';
import { createConnectQueryKey, useMutation } from '@connectrpc/connect-query';
import { yupResolver } from '@hookform/resolvers/yup';
import {
CheckConnectionConfigResponse,
GetAccountOnboardingConfigResponse,
GetConnectionResponse,
} from '@neosync/sdk';
import {
checkConnectionConfig,
createConnection,
getAccountOnboardingConfig,
getConnection,
isConnectionNameAvailable,
setAccountOnboardingConfig,
} from '@neosync/sdk/connectquery';
import { ExclamationTriangleIcon } from '@radix-ui/react-icons';
import { useQueryClient } from '@tanstack/react-query';
Expand All @@ -66,15 +58,7 @@ export default function NewDynamoDBForm(): ReactElement {
const { data: systemAppConfig } = useGetSystemAppConfig();
const sourceConnId = searchParams.get('sourceId');
const [isLoading, setIsLoading] = useState<boolean>();
const { data: onboardingData } = useQuery(
getAccountOnboardingConfig,
{ accountId: account?.id ?? '' },
{ enabled: !!account?.id }
);
const queryclient = useQueryClient();
const { mutateAsync: setOnboardingConfigAsync } = useMutation(
setAccountOnboardingConfig
);
const { mutateAsync: isConnectionNameAvailableAsync } = useMutation(
isConnectionNameAvailable
);
Expand Down Expand Up @@ -178,36 +162,6 @@ export default function NewDynamoDBForm(): ReactElement {
posthog.capture('New Connection Created', { type: 'dynamodb' });
toast.success('Successfully created connection!');

// updates the onboarding data
try {
const resp = await setOnboardingConfigAsync({
accountId: account.id,
config: buildAccountOnboardingConfig({
hasCreatedSourceConnection:
onboardingData?.config?.hasCreatedSourceConnection ?? true,
hasCreatedDestinationConnection:
onboardingData?.config?.hasCreatedDestinationConnection ??
onboardingData?.config?.hasCreatedSourceConnection ??
false,
hasCreatedJob: onboardingData?.config?.hasCreatedJob ?? false,
hasInvitedMembers:
onboardingData?.config?.hasInvitedMembers ?? false,
}),
});
queryclient.setQueryData(
createConnectQueryKey(getAccountOnboardingConfig, {
accountId: account.id,
}),
new GetAccountOnboardingConfigResponse({
config: resp.config,
})
);
} catch (e) {
toast.error('Unable to update onboarding status!', {
description: getErrorMessage(e),
});
}

const returnTo = searchParams.get('returnTo');
if (returnTo) {
router.push(returnTo);
Expand Down
Loading