Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
} from "pages/Editor/Explorer/ExplorerIcons";
import { getAssetUrl } from "ee/utils/airgapHelpers";
import { ENTITY_TYPE } from "ee/entities/DataTree/types";
import { ENTITY_TYPE as DEBUGGER_ENTITY_TYPE } from "ee/entities/AppsmithConsole/utils";
import { Icon } from "@appsmith/ads";

type IconProps = LogItemProps & {
pluginImages: Record<string, string>;
Expand Down Expand Up @@ -47,4 +49,7 @@ export const getIconForEntity: IconEntityMapper = {

return <img alt="icon" />;
},
[DEBUGGER_ENTITY_TYPE.GIT]: () => {
return <Icon name="git-repository" />;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import DatasourceLink from "components/editorComponents/Debugger/DataSourceLink"
import WidgetLink from "components/editorComponents/Debugger/WidgetLink";
import JSCollectionLink from "components/editorComponents/Debugger/JSCollectionLink";
import { ENTITY_TYPE } from "ee/entities/AppsmithConsole/utils";
import GitEntityLink from "components/editorComponents/Debugger/GitEntityLink";

export const entityTypeLinkMap = {
[ENTITY_TYPE.WIDGET]: WidgetLink,
[ENTITY_TYPE.ACTION]: ActionLink,
[ENTITY_TYPE.DATASOURCE]: DatasourceLink,
[ENTITY_TYPE.JSACTION]: JSCollectionLink,
[ENTITY_TYPE.GIT]: GitEntityLink,
};
8 changes: 8 additions & 0 deletions app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,14 @@ export const GIT_AUTHOR = () => "Git author";
export const DISCONNECT_GIT = () => "Disconnect Git";
export const DISCONNECT_GIT_MESSAGE = () =>
"This is irreversible. If you wish to reconnect, you will have to connect a new empty repository.";
export const GENERATE_DEPLOY_KEY_TITLE = () => "Deploy key";
export const GENERATE_DEPLOY_KEY_MESSAGE = () =>
"Generate a new deploy key. Then, add the new key to your Git repository to restore this app’s connection.";
export const GENERATE_DEPLOY_KEY_BTN = () => "Generate deploy key";
export const GENERATE_DEPLOY_KEY_MODAL_TITLE = () => "Generate deploy key";
export const GENERATE_DEPLOY_KEY_MODAL_WAIT_TEXT = () => "Saving deploy key...";
export const INVALID_DEPLOY_KEY_WARNING = () =>
"Your current deploy key may be invalid or outdated. Try generating a new key below and adding it to your Git repository.";
export const AUTOCOMMIT = () => "Auto - commit";
export const AUTOCOMMIT_MESSAGE = () =>
"Enable/disable auto migrations from Appsmith.";
Expand Down
1 change: 1 addition & 0 deletions app/client/src/ce/entities/AppsmithConsole/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum ENTITY_TYPE {
DATASOURCE = "DATASOURCE",
WIDGET = "WIDGET",
JSACTION = "JSACTION",
GIT = "GIT",
}

export enum PLATFORM_ERROR {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { DebuggerEntityLink, type EntityLinkProps } from "./DebuggerEntityLink";
import { useCallback } from "react";
import useSettings from "git/hooks/useSettings";
import { GitSettingsTab } from "git/constants/enums";

export default function GitEntityLink(props: EntityLinkProps) {
const { toggleSettingsModal } = useSettings();

const onClick = useCallback(() => {
toggleSettingsModal(true, GitSettingsTab.General);
}, [toggleSettingsModal]);

return (
<DebuggerEntityLink
entityType={props.type}
name={props.name}
onClick={onClick}
uiComponent={props.uiComponent}
/>
);
}
1 change: 1 addition & 0 deletions app/client/src/entities/AppsmithConsole/logtype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum LOG_TYPE {
CYCLIC_DEPENDENCY_ERROR,
LINT_ERROR,
MISSING_MODULE,
INVALID_GIT_DEPLOY_KEY,
}

export default LOG_TYPE;
2 changes: 2 additions & 0 deletions app/client/src/git/ce/components/GitModals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import OpsModal from "git/components/OpsModal";
import RepoLimitErrorModal from "git/components/RepoLimitErrorModal";
import SettingsModal from "git/components/SettingsModal";
import React from "react";
import GenerateDeployKeyModal from "git/components/GenerateDeployKeyModal";

function GitModals() {
return (
Expand All @@ -19,6 +20,7 @@ function GitModals() {
<DisconnectModal />
<DisableAutocommitModal />
<ConflictErrorModal />
<GenerateDeployKeyModal />
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
WellContainer,
WellTitle,
WellTitleContainer,
} from "./common";
} from "../../common/GitUIComponents";
import {
Callout,
Checkbox,
Expand All @@ -20,7 +20,7 @@ import {
Text,
} from "@appsmith/ads";
import styled from "styled-components";
import { GIT_DEMO_GIF, GIT_PROVIDERS } from "./constants";
import { GIT_DEMO_GIF, GIT_PROVIDERS } from "../../common/constants";
import noop from "lodash/noop";
import {
CHOOSE_A_GIT_PROVIDER_STEP,
Expand All @@ -33,7 +33,7 @@ import {
createMessage,
} from "ee/constants/messages";
import log from "loglevel";
import type { ConnectFormDataState, GitProvider } from "./types";
import type { ConnectFormDataState, GitProvider } from "../../common/types";
import { useIsMobileDevice } from "utils/hooks/useDeviceDetect";

const WellInnerContainer = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { isValidGitRemoteUrl } from "../../utils";
import GenerateSSH from "./GenerateSSH";
import "@testing-library/jest-dom";
import type { GitProvider } from "./types";
import type { GitProvider } from "../../common/types";

jest.mock("../../utils", () => ({
isValidGitRemoteUrl: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
WellText,
WellTitle,
WellTitleContainer,
} from "./common";
} from "../../common/GitUIComponents";
import {
Button,
Collapsible,
Expand All @@ -29,10 +29,10 @@ import {
REMOTE_URL_INPUT_LABEL,
createMessage,
} from "ee/constants/messages";
import { GIT_DEMO_GIF } from "./constants";
import { GIT_DEMO_GIF } from "../../common/constants";
import { isValidGitRemoteUrl } from "../../utils";
import type { GitApiError } from "git/store/types";
import type { GitProvider } from "./types";
import type { GitProvider } from "../../common/types";

interface GenerateSSHState {
gitProvider?: GitProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useCallback, useEffect, useState } from "react";
import styled from "styled-components";

import AddDeployKey from "./AddDeployKey";
import AddDeployKey from "git/components/common/AddDeployKey";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import ChooseGitProvider from "./ChooseGitProvider";
import GenerateSSH from "./GenerateSSH";
import Steps from "./Steps";
import Statusbar from "../../Statusbar";
import { Button, ModalBody, ModalFooter, ModalHeader } from "@appsmith/ads";
import { GIT_CONNECT_STEPS } from "./constants";
import { GIT_CONNECT_STEPS } from "../../common/constants";
import { isValidGitRemoteUrl } from "../../utils";
import type { ConnectRequestParams } from "git/requests/connectRequest.types";
import noop from "lodash/noop";
import type { GitApiError } from "git/store/types";
import type { ConnectFormDataState } from "./types";
import type { ConnectFormDataState } from "../../common/types";
import type { GitImportRequestParams } from "git/requests/gitImportRequest.types";
import { GitErrorCodes } from "git/constants/enums";
import { CONNECT_GIT, IMPORT_GIT } from "git/ee/constants/messages";
Expand Down
32 changes: 30 additions & 2 deletions app/client/src/git/components/DangerZone/DangerZoneView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
DANGER_ZONE,
DISCONNECT_GIT,
DISCONNECT_GIT_MESSAGE,
GENERATE_DEPLOY_KEY_BTN,
GENERATE_DEPLOY_KEY_MESSAGE,
GENERATE_DEPLOY_KEY_TITLE,
createMessage,
} from "ee/constants/messages";
import { Button, Divider, Text } from "@appsmith/ads";
Expand Down Expand Up @@ -57,6 +60,7 @@ interface DangerZoneViewProps {
isToggleAutocommitLoading: boolean;
isAutocommitEnabled: boolean;
isFetchMetadataLoading: boolean;
toggleGenerateSSHKeyModal: (open: boolean) => void;
openDisconnectModal: () => void;
toggleAutocommit: () => void;
toggleDisableAutocommitModal: (open: boolean) => void;
Expand All @@ -75,6 +79,7 @@ function DangerZoneView({
openDisconnectModal = noop,
toggleAutocommit = noop,
toggleDisableAutocommitModal = noop,
toggleGenerateSSHKeyModal = noop,
toggleSettingsModal = noop,
}: DangerZoneViewProps) {
const handleDisconnect = useCallback(() => {
Expand All @@ -100,9 +105,13 @@ function DangerZoneView({
toggleSettingsModal,
]);

const handleOpenGenerateDeployKeyModal = useCallback(() => {
toggleSettingsModal(false);
toggleGenerateSSHKeyModal(true);
}, [toggleGenerateSSHKeyModal, toggleSettingsModal]);

const showAutoCommit = isManageAutocommitPermitted;
const showDisconnect = isConnectPermitted;
const showDivider = showAutoCommit && showDisconnect;

return (
<Container>
Expand Down Expand Up @@ -133,7 +142,26 @@ function DangerZoneView({
</Button>
</BodyContainer>
)}
{showDivider && <StyledDivider />}
{showAutoCommit && <StyledDivider />}
<BodyContainer>
<BodyInnerContainer>
<Text kind="heading-xs" renderAs="p">
{createMessage(GENERATE_DEPLOY_KEY_TITLE)}
</Text>
<Text renderAs="p">
{createMessage(GENERATE_DEPLOY_KEY_MESSAGE)}
</Text>
</BodyInnerContainer>
<Button
data-testid="t--git-generate-deploy-key-btn"
kind="error"
onClick={handleOpenGenerateDeployKeyModal}
size="md"
>
{createMessage(GENERATE_DEPLOY_KEY_BTN)}
</Button>
</BodyContainer>
{showDisconnect && <StyledDivider />}
{showDisconnect && (
<BodyContainer>
<BodyInnerContainer>
Expand Down
3 changes: 3 additions & 0 deletions app/client/src/git/components/DangerZone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useCallback } from "react";
import DangerZoneView from "./DangerZoneView";
import useMetadata from "git/hooks/useMetadata";
import { useGitContext } from "../GitContextProvider";
import useGenerateDeployKey from "git/hooks/useGenerateDeployKey";

function DangerZone() {
const {
Expand All @@ -20,6 +21,7 @@ function DangerZone() {
toggleAutocommit,
toggleAutocommitDisableModal,
} = useAutocommit();
const { toggleGenerateSSHKeyModal } = useGenerateDeployKey();
const { toggleSettingsModal } = useSettings();
const { isFetchMetadataLoading } = useMetadata();

Expand All @@ -40,6 +42,7 @@ function DangerZone() {
openDisconnectModal={handleOpenDisconnectModal}
toggleAutocommit={toggleAutocommit}
toggleDisableAutocommitModal={toggleAutocommitDisableModal}
toggleGenerateSSHKeyModal={toggleGenerateSSHKeyModal}
toggleSettingsModal={toggleSettingsModal}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React from "react";
import {
Button,
Flex,
Modal,
ModalBody,
ModalFooter,
ModalHeader,
} from "@appsmith/ads";
import {
GENERATE_DEPLOY_KEY_MODAL_TITLE,
GENERATE_DEPLOY_KEY_MODAL_WAIT_TEXT,
createMessage,
} from "ee/constants/messages";
import { StyledModalContent } from "git/components/common/GitUIComponents";
import styled from "styled-components";
import AddDeployKey from "git/components/common/AddDeployKey";
import type { ConnectFormDataState } from "git/components/common/types";
import type { GitApiError } from "git/store/types";
import Statusbar from "../Statusbar";

interface GenerateDeployKeyModalViewProps {
error: GitApiError | null;
formData: ConnectFormDataState;
isModalOpen: boolean;
isSSHKeyLoading: boolean;
onChange: (args: Partial<ConnectFormDataState>) => void;
onFetchSSHKey: () => void;
onGenerateSSHKey: (keyType: string) => void;
onModalOpenChange: (open: boolean) => void;
sshPublicKey: string | null;
onUpdateGeneratedSSHKey: () => void;
isUpdateGeneratedSSHKeyLoading: boolean;
}

const OFFSET = 200;
const OUTER_PADDING = 32;
const FOOTER = 56;
const HEADER = 44;

const StyledModalBody = styled(ModalBody)`
flex: 1;
overflow-y: initial;
display: flex;
flex-direction: column;
max-height: calc(
100vh - ${OFFSET}px - ${OUTER_PADDING}px - ${FOOTER}px - ${HEADER}px
);
`;

function GenerateDeployKeyModalView({
error,
formData,
isModalOpen,
isSSHKeyLoading,
isUpdateGeneratedSSHKeyLoading,
onChange,
onFetchSSHKey,
onGenerateSSHKey,
onModalOpenChange,
onUpdateGeneratedSSHKey,
sshPublicKey,
}: GenerateDeployKeyModalViewProps) {
const isSubmitLoading = false; // This modal doesn't have submit functionality

return (
<Modal onOpenChange={onModalOpenChange} open={isModalOpen}>
<StyledModalContent>
<ModalHeader>
{createMessage(GENERATE_DEPLOY_KEY_MODAL_TITLE)}
</ModalHeader>
<StyledModalBody>
<AddDeployKey
error={error}
isSSHKeyLoading={isSSHKeyLoading}
isSubmitLoading={isSubmitLoading}
onChange={onChange}
onFetchSSHKey={onFetchSSHKey}
onGenerateSSHKey={onGenerateSSHKey}
sshPublicKey={sshPublicKey}
value={formData}
/>
</StyledModalBody>
<ModalFooter>
<Flex
alignItems="center"
flex={1}
flexDirection="row-reverse"
justifyContent="space-between"
>
<Button
data-testid="t--git-generate-deploy-key-finish-btn"
isDisabled={!formData.isAddedDeployKey}
isLoading={isUpdateGeneratedSSHKeyLoading}
onClick={onUpdateGeneratedSSHKey}
size="md"
>
Finish
</Button>
{isUpdateGeneratedSSHKeyLoading && (
<Statusbar
completed={!isUpdateGeneratedSSHKeyLoading}
message={createMessage(GENERATE_DEPLOY_KEY_MODAL_WAIT_TEXT)}
/>
)}
</Flex>
</ModalFooter>
</StyledModalContent>
</Modal>
);
}

export default GenerateDeployKeyModalView;
Loading