PromucFlow_constructor/app/client/src/pages/setup/DetailsForm.tsx
Aman Agarwal 5daaf98452
fix: updated the design for the admin users (#29712)
## Description
This PR updates the design of the admin users UI for profiling questions
to newer version. Below are the list of changes introduced in this PR :
- Deprecated `role` property for the user
- Updated components to reuse the similar UI
- Updated the background image for the admin setup screen
- before <img width="1325" alt="Screenshot 2023-12-21 at 10 29 52 PM"
src="https://github.com/appsmithorg/appsmith/assets/7565635/31cc44b6-4534-4a6a-a5e4-1e84b2d5705c">


- after <img width="1295" alt="Screenshot 2023-12-21 at 10 51 58 PM"
src="https://github.com/appsmithorg/appsmith/assets/7565635/c4181ded-ec7d-4b68-8b3c-3d0699d00c9c">


- Changed the profiling questions for the admin second page while
setting up the instance
- before <img width="1273" alt="Screenshot 2023-12-21 at 10 30 16 PM"
src="https://github.com/appsmithorg/appsmith/assets/7565635/6f7c5c8c-7f9f-470b-bb2e-3e94b1a741fc">

- after <img width="1311" alt="Screenshot 2023-12-21 at 10 51 48 PM"
src="https://github.com/appsmithorg/appsmith/assets/7565635/355c4123-a686-4423-a312-5e67c1c39c13">


#### PR fixes following issue(s)
Fixes #29692
> if no issue exists, please create an issue and ask the maintainers
about this first
>
>
#### Media
> A video or a GIF is preferred. when using Loom, don’t embed because it
looks like it’s a GIF. instead, just link to the video
>
>
#### Type of change
> Please delete options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- Chore (housekeeping or task changes that don't impact user perception)
- This change requires a documentation update
>
>
>
## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new `UserWelcomeScreen` component to enhance the user
onboarding experience.
  - Added a proficiency level selection to the user setup process.
  - Updated the use case selection options for a more tailored setup.

- **Bug Fixes**
- Fixed issues with form input handling for proficiency and use case
selections.

- **Refactor**
- Streamlined the setup process by removing role selection and custom
use case input.
  - Refined the user interface elements related to the setup forms.

- **Documentation**
  - Updated constant messages to align with the new setup flow.

- **Style**
- Implemented new styles for the `WelcomeBackground` and its components
to improve visual appeal.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2023-12-25 17:54:46 +05:30

217 lines
6.6 KiB
TypeScript

import React, { useEffect } from "react";
import styled from "styled-components";
import { Field } from "redux-form";
import { FormBodyWrapper } from "./common";
import {
createMessage,
WELCOME_FORM_EMAIL_ID,
WELCOME_FORM_FIRST_NAME,
WELCOME_FORM_LAST_NAME,
WELCOME_FORM_CREATE_PASSWORD,
WELCOME_FORM_VERIFY_PASSWORD,
CONTINUE,
ONBOARDING_STATUS_GET_STARTED,
PRODUCT_UPDATES_CONFIRMATION_LABEL,
WELCOME_FORM_NON_SUPER_USER_USE_CASE,
WELCOME_FORM_NON_SUPER_USER_PROFICIENCY_LEVEL,
} from "@appsmith/constants/messages";
import FormTextField from "components/utils/ReduxFormTextField";
import type { FormErrors, InjectedFormProps } from "redux-form";
import { FormGroup } from "design-system-old";
import { Button, Checkbox } from "design-system";
import { proficiencyOptions, useCaseOptions } from "./constants";
import { isAirgapped } from "@appsmith/utils/airgapHelpers";
import { setFirstTimeUserOnboardingTelemetryCalloutVisibility } from "utils/storage";
import RadioButtonGroup from "components/editorComponents/RadioButtonGroup";
import { Space } from "./NonSuperUserProfilingQuestions";
export interface DetailsFormValues {
firstName?: string;
lastName?: string;
email?: string;
password?: string;
verifyPassword?: string;
proficiency?: string;
useCase?: string;
}
export type SetupFormProps = DetailsFormValues & {
formSyncErrors?: FormErrors<string, string>;
} & InjectedFormProps<
DetailsFormValues,
{
formSyncErrors?: FormErrors<string, string>;
}
>;
const DetailsFormWrapper = styled.div`
width: 100%;
position: relative;
`;
const StyledFormBodyWrapper = styled(FormBodyWrapper)``;
const StyledTabIndicatorWrapper = styled.div`
display: flex;
`;
const StyledTabIndicator = styled.div<{ isFirstPage?: boolean }>`
width: 48px;
height: 3px;
margin: 0 6px 0 0;
background-color: ${(props) =>
props.isFirstPage
? `var(--ads-v2-color-bg-emphasis);`
: `var(--ads-v2-color-bg-brand);`};
`;
const StyledFormGroup = styled(FormGroup)`
&& > .bp3-label {
color: var(--ads-v2-color-fg);
}
`;
const ButtonWrapper = styled.div`
display: flex;
margin-top: ${(props) => props.theme.spaces[11]}px;
gap: ${(props) => props.theme.spaces[4]}px;
`;
export default function DetailsForm(
props: SetupFormProps & { isFirstPage: boolean } & {
toggleFormPage: () => void;
},
) {
const ref = React.createRef<HTMLDivElement>();
useEffect(() => {
const setTelemetryVisibleFalse = async () => {
await setFirstTimeUserOnboardingTelemetryCalloutVisibility(false);
};
setTelemetryVisibleFalse();
}, []);
return (
<DetailsFormWrapper ref={ref}>
<StyledTabIndicatorWrapper>
<StyledTabIndicator />
<StyledTabIndicator isFirstPage={props.isFirstPage} />
</StyledTabIndicatorWrapper>
<StyledFormBodyWrapper>
<div
className={props.isFirstPage ? "block" : "hidden"}
data-testid="formPage"
>
<div className="flex flex-row justify-between w-100">
<StyledFormGroup className="!w-52 t--welcome-form-first-name">
<FormTextField
autoFocus
data-testid="firstName"
label={createMessage(WELCOME_FORM_FIRST_NAME)}
name="firstName"
placeholder="John"
type="text"
/>
</StyledFormGroup>
<StyledFormGroup className="!w-52 t--welcome-form-last-name">
<FormTextField
data-testid="lastName"
label={createMessage(WELCOME_FORM_LAST_NAME)}
name="lastName"
placeholder="Doe"
type="text"
/>
</StyledFormGroup>
</div>
<StyledFormGroup className="t--welcome-form-email">
<FormTextField
data-testid="email"
label={createMessage(WELCOME_FORM_EMAIL_ID)}
name="email"
placeholder="How can we reach you?"
type="email"
/>
</StyledFormGroup>
<StyledFormGroup className="t--welcome-form-password">
<FormTextField
data-testid="password"
label={createMessage(WELCOME_FORM_CREATE_PASSWORD)}
name="password"
placeholder="Make it strong!"
type="password"
/>
</StyledFormGroup>
<StyledFormGroup className="t--welcome-form-verify-password">
<FormTextField
data-testid="verifyPassword"
label={createMessage(WELCOME_FORM_VERIFY_PASSWORD)}
name="verifyPassword"
placeholder="Type correctly"
type="password"
/>
</StyledFormGroup>
</div>
{!props.isFirstPage && (
<div>
<Field
component={RadioButtonGroup}
label={createMessage(
WELCOME_FORM_NON_SUPER_USER_PROFICIENCY_LEVEL,
)}
name="proficiency"
options={proficiencyOptions}
showSubtitle
testid="t--user-proficiency"
/>
<Space />
<Field
component={RadioButtonGroup}
label={createMessage(WELCOME_FORM_NON_SUPER_USER_USE_CASE)}
name="useCase"
options={useCaseOptions}
testid="t--user-use-case"
/>
<Space style={{ marginBottom: "var(--ads-spaces-3)" }} />
{!isAirgapped() && (
<Checkbox defaultSelected name="signupForNewsletter" value="true">
{createMessage(PRODUCT_UPDATES_CONFIRMATION_LABEL)}
</Checkbox>
)}
</div>
)}
{props.isFirstPage && (
<ButtonWrapper>
<Button
className="t--welcome-form-continue-button w-100"
isDisabled={props.invalid}
kind="primary"
onClick={() => {
props.toggleFormPage();
}}
size="md"
type="button"
>
{createMessage(CONTINUE)}
</Button>
</ButtonWrapper>
)}
{!props.isFirstPage && (
<ButtonWrapper>
<Button
className="t--welcome-form-submit-button w-100"
isDisabled={props.invalid}
kind="primary"
size="md"
type="submit"
>
{createMessage(ONBOARDING_STATUS_GET_STARTED)}
</Button>
</ButtonWrapper>
)}
</StyledFormBodyWrapper>
</DetailsFormWrapper>
);
}