diff --git a/app/client/src/components/ads/Dropdown.tsx b/app/client/src/components/ads/Dropdown.tsx index 46bfeaff67..e899b4210b 100644 --- a/app/client/src/components/ads/Dropdown.tsx +++ b/app/client/src/components/ads/Dropdown.tsx @@ -9,6 +9,8 @@ import SearchComponent from "components/designSystems/appsmith/SearchComponent"; import { Colors } from "constants/Colors"; import Spinner from "./Spinner"; +export type DropdownOnSelect = (value?: string, dropdownOption?: any) => void; + export type DropdownOption = { label?: string; value?: string; @@ -19,7 +21,7 @@ export type DropdownOption = { subText?: string; iconSize?: IconSize; iconColor?: string; - onSelect?: (value?: string, dropdownOption?: any) => void; + onSelect?: DropdownOnSelect; data?: any; }; export interface DropdownSearchProps { @@ -48,7 +50,7 @@ export type DropdownProps = CommonComponentProps & DropdownSearchProps & { options: DropdownOption[]; selected: DropdownOption; - onSelect?: (value?: string, dropdownOption?: any) => void; + onSelect?: DropdownOnSelect; width?: string; height?: string; showLabelOnly?: boolean; diff --git a/app/client/src/constants/messages.ts b/app/client/src/constants/messages.ts index 27e0a3ecba..05ef000386 100644 --- a/app/client/src/constants/messages.ts +++ b/app/client/src/constants/messages.ts @@ -429,3 +429,11 @@ export const CONNECT_TO_GIT = () => "Connect to Git"; export const CONNECT_TO_GIT_SUBTITLE = () => "Choose an existing empty repository to host your project and keep it in sync"; export const REMOTE_URL_VIA = () => "REMOTE URL VIA"; + +export const USER_PROFILE_SETTINGS_TITLE = () => "User Settings"; + +export const AUTHOR_NAME = () => "AUTHOR NAME"; +export const AUTHOR_EMAIL = () => "AUTHOR EMAIL"; +export const SELECT_SSH_KEY = () => "SELECT SSH KEY"; +export const USER_NAME = () => "USER NAME"; +export const USER_PASSWORD = () => "PASSWORD"; diff --git a/app/client/src/pages/Editor/gitSync/GitConnection.tsx b/app/client/src/pages/Editor/gitSync/GitConnection.tsx index 29026b5b79..e68e488cb7 100644 --- a/app/client/src/pages/Editor/gitSync/GitConnection.tsx +++ b/app/client/src/pages/Editor/gitSync/GitConnection.tsx @@ -1,17 +1,21 @@ -import React from "react"; -import { Subtitle, Title } from "./components/StyledComponents"; +import React, { useState } from "react"; +import { Subtitle, Title, Space } from "./components/StyledComponents"; import { CONNECT_TO_GIT, CONNECT_TO_GIT_SUBTITLE, REMOTE_URL_VIA, createMessage, } from "constants/messages"; -import AuthTypeDropdown from "./components/AuthTypeDropdown"; +import OptionSelector from "./components/OptionSelector"; import styled from "styled-components"; import { getTypographyByKey } from "constants/DefaultTheme"; import TextInput from "components/ads/TextInput"; import { ReactComponent as CheckIcon } from "assets/icons/ads/check.svg"; import { ReactComponent as LinkIcon } from "assets/icons/ads/link_2.svg"; +import UserGitProfileSettings from "./components/UserGitProfileSettings"; +import { DropdownOption } from "components/ads/Dropdown"; +import { AUTH_TYPE_OPTIONS } from "./constants"; +import { DropdownOnSelect } from "../../../components/ads/Dropdown"; const UrlOptionContainer = styled.div` ${(props) => getTypographyByKey(props, "h6")}; @@ -37,14 +41,26 @@ const UrlContainer = styled.div` align-items: center; `; -function GitConection() { +function GitConnection() { + const [selectedAuthType, setSelectedAuthType] = useState( + AUTH_TYPE_OPTIONS[0], + ); + + const onSelectAuthType: DropdownOnSelect = (value, dropdownOption) => { + setSelectedAuthType(dropdownOption); + }; + return ( <> {createMessage(CONNECT_TO_GIT)} {createMessage(CONNECT_TO_GIT_SUBTITLE)} {`${createMessage(REMOTE_URL_VIA)} `} - + + + ); } -export default GitConection; +export default GitConnection; diff --git a/app/client/src/pages/Editor/gitSync/GitSyncModal.tsx b/app/client/src/pages/Editor/gitSync/GitSyncModal.tsx index 8742c7d72d..bf06a60d00 100644 --- a/app/client/src/pages/Editor/gitSync/GitSyncModal.tsx +++ b/app/client/src/pages/Editor/gitSync/GitSyncModal.tsx @@ -17,12 +17,16 @@ const Container = styled.div` width: 100%; display: flex; position: relative; + overflow-y: hidden; `; const BodyContainer = styled.div` flex: 3; padding-left: ${(props) => props.theme.spaces[12]}px; padding-top: ${(props) => props.theme.spaces[13]}px; + padding-bottom: ${(props) => props.theme.spaces[13]}px; + overflow-y: auto; + height: 100%; `; const MenuContainer = styled.div` diff --git a/app/client/src/pages/Editor/gitSync/components/AuthTypeDropdown.tsx b/app/client/src/pages/Editor/gitSync/components/OptionSelector.tsx similarity index 68% rename from app/client/src/pages/Editor/gitSync/components/AuthTypeDropdown.tsx rename to app/client/src/pages/Editor/gitSync/components/OptionSelector.tsx index ba3de5023d..26a75a76e6 100644 --- a/app/client/src/pages/Editor/gitSync/components/AuthTypeDropdown.tsx +++ b/app/client/src/pages/Editor/gitSync/components/OptionSelector.tsx @@ -7,7 +7,8 @@ import Dropdown, { import { ReactComponent as ChevronDown } from "assets/icons/ads/chevron-down.svg"; import { Colors } from "constants/Colors"; import styled from "styled-components"; -import { AuthTypeOptions } from "../constants"; +import { DropdownOption } from "components/ads/Dropdown"; +import { Classes as GitSyncClasses } from "pages/Editor/gitSync/constants"; const SelectedValueNodeContainer = styled.div` color: ${Colors.CRUSTA}; @@ -37,15 +38,22 @@ const DropdownContainer = styled.div` } `; -function SelectAuthType() { +type OptionSelectorProps = { + options: DropdownOption[]; + selected: DropdownOption; + onSelect?: (value?: string, dropdownOption?: any) => void; +}; + +function OptionSelector({ onSelect, options, selected }: OptionSelectorProps) { return ( - + @@ -53,4 +61,4 @@ function SelectAuthType() { ); } -export default SelectAuthType; +export default OptionSelector; diff --git a/app/client/src/pages/Editor/gitSync/components/StyledComponents.tsx b/app/client/src/pages/Editor/gitSync/components/StyledComponents.tsx index a9742a7060..1fd7d209ae 100644 --- a/app/client/src/pages/Editor/gitSync/components/StyledComponents.tsx +++ b/app/client/src/pages/Editor/gitSync/components/StyledComponents.tsx @@ -8,3 +8,10 @@ export const Title = styled.h1` export const Subtitle = styled.p` ${(props) => getTypographyByKey(props, "p3")}; `; + +export const Space = styled.div<{ size: number; horizontal?: boolean }>` + margin: ${(props) => + props.horizontal + ? `0px ${props.theme.spaces[props.size]}px ` + : `${props.theme.spaces[props.size]}px 0px`}; +`; diff --git a/app/client/src/pages/Editor/gitSync/components/UserGitProfileSettings/index.tsx b/app/client/src/pages/Editor/gitSync/components/UserGitProfileSettings/index.tsx new file mode 100644 index 0000000000..fe6ef26d69 --- /dev/null +++ b/app/client/src/pages/Editor/gitSync/components/UserGitProfileSettings/index.tsx @@ -0,0 +1,172 @@ +import React from "react"; +import { Title, Space } from "../StyledComponents"; +import { + SELECT_SSH_KEY, + createMessage, + USER_PROFILE_SETTINGS_TITLE, + AUTHOR_NAME, + AUTHOR_EMAIL, +} from "constants/messages"; +import OptionSelector from "../OptionSelector"; +import styled from "styled-components"; +import { getTypographyByKey } from "constants/DefaultTheme"; +import TextInput from "components/ads/TextInput"; +import { AUTH_TYPE, Classes as GitSyncClasses } from "../../constants"; +import { USER_NAME, USER_PASSWORD } from "../../../../../constants/messages"; +import Dropdown from "components/ads/Dropdown"; +import Text, { TextType } from "../../../../../components/ads/Text"; + +// Mock Data +const HTTPS_PROFILE_OPTIONS = [{ label: "PROFILE 1" }, { label: "PROFILE 2" }]; + +const SSH_PROFILE_OPTION = [{ label: "PROFILE 1" }, { label: "PROFILE 2" }]; + +// +const LabelContainer = styled.div` + ${(props) => getTypographyByKey(props, "h6")}; + display: flex; + align-items: center; + margin-bottom: 8px; +`; + +const InputContainer = styled.div` + width: 70%; + display: flex; + align-items: center; +`; + +const TitleWrapper = styled.div` + display: flex; + flex-direction: row; + + .${GitSyncClasses.OPTION_SELECTOR_WRAPPER} { + display: flex; + align-items: center; + padding-top: 5px; + } +`; + +const OptionWrapper = styled.div<{ + selected: boolean; +}>` + padding: ${(props) => props.theme.spaces[2] + 1}px + ${(props) => props.theme.spaces[5]}px; + cursor: pointer; + display: flex; + align-items: center; + + background-color: ${(props) => + props.selected ? props.theme.colors.propertyPane.dropdownSelectBg : null}; +`; + +// Child component +type AuthConfigProps = { + authType: string; +}; + +function AuthConfig({ authType }: AuthConfigProps) { + switch (authType) { + case AUTH_TYPE.SSH: + return ( + <> + + {createMessage(SELECT_SSH_KEY)} + + + { + // + }} + // optionWidth="100%" + options={SSH_PROFILE_OPTION} + renderOption={({ + isSelectedNode, + option, + optionClickHandler, + }) => ( + + optionClickHandler && optionClickHandler(option) + } + selected={!!isSelectedNode} + > + {option.label} + + )} + selected={{}} + showLabelOnly + width="100%" + /> + + + ); + case AUTH_TYPE.HTTPS: + return ( + <> + + {createMessage(USER_NAME)} + + + + + + + + + {createMessage(USER_PASSWORD)} + + + + + + ); + default: + return null; + } +} + +// Component +type UserGitProfileSettingsProps = { + authType: string; +}; + +function UserGitProfileSettings({ authType }: UserGitProfileSettingsProps) { + return ( + <> + + {createMessage(USER_PROFILE_SETTINGS_TITLE)} + {authType === AUTH_TYPE.HTTPS ? ( + + ) : null} + + + + + + + + + + {createMessage(AUTHOR_NAME)} + + + + + + + + + {createMessage(AUTHOR_EMAIL)} + + + + + + ); +} + +export default UserGitProfileSettings; diff --git a/app/client/src/pages/Editor/gitSync/constants.ts b/app/client/src/pages/Editor/gitSync/constants.ts index 649cbe162f..38ac7cdb9d 100644 --- a/app/client/src/pages/Editor/gitSync/constants.ts +++ b/app/client/src/pages/Editor/gitSync/constants.ts @@ -39,10 +39,16 @@ export const MENU_ITEMS: TabProp[] = [ }, ]; -export const AuthTypeOptions = [ - { label: "SSH", value: "SSH" }, - { label: "HTTPS", value: "HTTPS" }, +export enum AUTH_TYPE { + SSH = "SSH", + HTTPS = "HTTPS", +} + +export const AUTH_TYPE_OPTIONS = [ + { label: AUTH_TYPE.SSH, value: AUTH_TYPE.SSH }, + { label: AUTH_TYPE.HTTPS, value: AUTH_TYPE.HTTPS }, ]; export const Classes = { GIT_SYNC_MODAL: "git-sync-modal", + OPTION_SELECTOR_WRAPPER: "option-wrapper", };