Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-radhakrishnan committed Sep 22, 2022
1 parent d12e162 commit bac61e0
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 330 deletions.
Expand Up @@ -202,9 +202,7 @@
import com.linkedin.datahub.graphql.resolvers.type.PlatformSchemaUnionTypeResolver;
import com.linkedin.datahub.graphql.resolvers.type.ResultsTypeResolver;
import com.linkedin.datahub.graphql.resolvers.type.TimeSeriesAspectInterfaceTypeResolver;
import com.linkedin.datahub.graphql.resolvers.user.CreateNativeUserInviteTokenResolver;
import com.linkedin.datahub.graphql.resolvers.user.CreateNativeUserResetTokenResolver;
import com.linkedin.datahub.graphql.resolvers.user.GetNativeUserInviteTokenResolver;
import com.linkedin.datahub.graphql.resolvers.user.ListUsersResolver;
import com.linkedin.datahub.graphql.resolvers.user.RemoveUserResolver;
import com.linkedin.datahub.graphql.resolvers.user.UpdateUserStatusResolver;
Expand Down Expand Up @@ -674,7 +672,6 @@ private void configureQueryResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("getRootGlossaryTerms", new GetRootGlossaryTermsResolver(this.entityClient))
.dataFetcher("getRootGlossaryNodes", new GetRootGlossaryNodesResolver(this.entityClient))
.dataFetcher("entityExists", new EntityExistsResolver(this.entityService))
.dataFetcher("getNativeUserInviteToken", new GetNativeUserInviteTokenResolver(this.inviteTokenService))
.dataFetcher("entity", getEntityResolver())
.dataFetcher("entities", getEntitiesResolver())
.dataFetcher("listRoles", new ListRolesResolver(this.entityClient))
Expand Down Expand Up @@ -794,8 +791,6 @@ private void configureMutationResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("updateName", new UpdateNameResolver(entityService))
.dataFetcher("addRelatedTerms", new AddRelatedTermsResolver(this.entityService))
.dataFetcher("removeRelatedTerms", new RemoveRelatedTermsResolver(this.entityService))
.dataFetcher("createNativeUserInviteToken",
new CreateNativeUserInviteTokenResolver(this.inviteTokenService))
.dataFetcher("createNativeUserResetToken", new CreateNativeUserResetTokenResolver(this.nativeUserService))
.dataFetcher("batchUpdateSoftDeleted", new BatchUpdateSoftDeletedResolver(this.entityService))
.dataFetcher("updateUserSetting", new UpdateUserSettingResolver(this.entityService))
Expand Down

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions datahub-graphql-core/src/main/resources/entity.graphql
Expand Up @@ -164,11 +164,6 @@ type Query {
"""
entityExists(urn: String!): Boolean

"""
Gets the current invite token. If the optional regenerate param is set to true, generate a new invite token.
"""
getNativeUserInviteToken: InviteToken @deprecated(reason: "Use getInviteToken instead")

"""
Gets an entity based on its urn
"""
Expand Down Expand Up @@ -494,11 +489,6 @@ type Mutation {
"""
removeRelatedTerms(input: RelatedTermsInput!): Boolean

"""
Generates an invite token that can be shared with prospective users to create their accounts.
"""
createNativeUserInviteToken: InviteToken @deprecated(reason: "Use createInviteToken instead")

"""
Generates a token that can be shared with existing native users to reset their credentials.
"""
Expand Down

This file was deleted.

This file was deleted.

26 changes: 15 additions & 11 deletions datahub-web-react/src/app/auth/SignUp.tsx
@@ -1,9 +1,10 @@
import React, { useCallback, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { Input, Button, Form, message, Image, Select } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import { useReactiveVar } from '@apollo/client';
import styled, { useTheme } from 'styled-components/macro';
import { Redirect } from 'react-router';
// import { Redirect } from 'react-router';
import { useHistory } from 'react-router-dom';
import styles from './login.module.css';
import { Message } from '../shared/Message';
import { isLoggedInVar } from './checkAuthStatus';
Expand Down Expand Up @@ -57,6 +58,7 @@ const TitleSelector = styled(Select)`
export type SignUpProps = Record<string, never>;

export const SignUp: React.VFC<SignUpProps> = () => {
const history = useHistory();
const isLoggedIn = useReactiveVar(isLoggedInVar);
const inviteToken = useGetInviteTokenFromUrlParams();

Expand All @@ -66,7 +68,7 @@ export const SignUp: React.VFC<SignUpProps> = () => {
const { refreshContext } = useAppConfig();

const [acceptRoleMutation] = useAcceptRoleMutation();
const acceptRole = useCallback(() => {
const acceptRole = () => {
acceptRoleMutation({
variables: {
input: {
Expand All @@ -89,7 +91,7 @@ export const SignUp: React.VFC<SignUpProps> = () => {
duration: 3,
});
});
}, [acceptRoleMutation, inviteToken]);
};

const handleSignUp = useCallback(
(values: FormValues) => {
Expand All @@ -114,7 +116,6 @@ export const SignUp: React.VFC<SignUpProps> = () => {
}
isLoggedInVar(true);
refreshContext();
acceptRole();
analytics.event({ type: EventType.SignUpEvent, title: values.title });
return Promise.resolve();
})
Expand All @@ -123,12 +124,15 @@ export const SignUp: React.VFC<SignUpProps> = () => {
})
.finally(() => setLoading(false));
},
[refreshContext, inviteToken, acceptRole],
[refreshContext, inviteToken],
);

if (isLoggedIn && !loading) {
return <Redirect to={`${PageRoutes.ROOT}`} />;
}
useEffect(() => {
if (isLoggedIn && !loading) {
acceptRole();
history.push(PageRoutes.ROOT);
}
});

return (
<div className={styles.login_page}>
Expand All @@ -140,10 +144,10 @@ export const SignUp: React.VFC<SignUpProps> = () => {
{loading && <Message type="loading" content="Signing up..." />}
<Form onFinish={handleSignUp} layout="vertical">
<Form.Item
rules={[{ required: true, message: 'Please fill in your email!' }]}
rules={[{ required: true, message: 'Please fill in your username!' }]}
name="email"
// eslint-disable-next-line jsx-a11y/label-has-associated-control
label={<label style={{ color: 'white' }}>Email</label>}
label={<label style={{ color: 'white' }}>Username</label>}
>
<FormInput prefix={<UserOutlined />} data-testid="email" />
</Form.Item>
Expand Down

0 comments on commit bac61e0

Please sign in to comment.