-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: added import override CE #40462
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
44c644e
chore: adding override modal
2b05ddf
chore: adding functionality to import modal
6c53a10
chore: integrating override with import api
73ac3d7
chore: adding proper messaging
11abd6b
chore: minor fixes
8e3e342
chore: retain name while importing
91b03e0
chore: fixing build
84b16ad
ce changes
sondermanish 19e7e98
Merge remote-tracking branch 'origin/chore/git-import-override-1' int…
sondermanish d5435a2
chore: fixing error code
79ceda0
Merge branch 'chore/git-import-override-1' of github.com:appsmithorg/…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/client/src/git/components/ImportOverrideModal/ImportOverrideModalView.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { | ||
| Button, | ||
| Callout, | ||
| Modal, | ||
| ModalBody, | ||
| ModalContent, | ||
| ModalFooter, | ||
| ModalHeader, | ||
| Text, | ||
| } from "@appsmith/ads"; | ||
| import { IMPORT_OVERRIDE_MODAL } from "git/ee/constants/messages"; | ||
| import useMessage from "git/hooks/useMessage"; | ||
| import noop from "lodash/noop"; | ||
| import React, { useCallback } from "react"; | ||
| import styled from "styled-components"; | ||
|
|
||
| const StyledModalContent = styled(ModalContent)` | ||
| width: 640px; | ||
| `; | ||
|
|
||
| interface ImportOverrideModalViewProps { | ||
| artifactType?: string; | ||
| isOpen: boolean; | ||
| onOpenChange: (open: boolean) => void; | ||
| onImport: () => void; | ||
| } | ||
|
|
||
| function ImportOverrideModalView({ | ||
| artifactType = "artifact", | ||
| isOpen = false, | ||
| onImport = noop, | ||
| onOpenChange = noop, | ||
| }: ImportOverrideModalViewProps) { | ||
| const modalTitle = useMessage(IMPORT_OVERRIDE_MODAL.TITLE, { artifactType }); | ||
| const modalDescription = useMessage(IMPORT_OVERRIDE_MODAL.DESCRIPTION, { | ||
| artifactType, | ||
| }); | ||
| const ctaBtnText = useMessage(IMPORT_OVERRIDE_MODAL.OVERRIDE_BTN, { | ||
| artifactType, | ||
| }); | ||
|
brayn003 marked this conversation as resolved.
|
||
|
|
||
| const handleCancel = useCallback(() => { | ||
| onOpenChange(false); | ||
| }, [onOpenChange]); | ||
|
|
||
| const handleImport = useCallback(() => { | ||
| onImport(); | ||
| }, [onImport]); | ||
|
|
||
| return ( | ||
| <Modal onOpenChange={onOpenChange} open={isOpen}> | ||
| <StyledModalContent> | ||
| <ModalHeader>{modalTitle}</ModalHeader> | ||
| <ModalBody> | ||
| <Callout kind="warning"> | ||
| <Text>{modalDescription}</Text> | ||
| </Callout> | ||
| </ModalBody> | ||
| <ModalFooter> | ||
| <Button kind="secondary" onClick={handleCancel} size="md"> | ||
| {IMPORT_OVERRIDE_MODAL.CANCEL_BTN} | ||
| </Button> | ||
| <Button onClick={handleImport} size="md"> | ||
| {ctaBtnText} | ||
| </Button> | ||
| </ModalFooter> | ||
| </StyledModalContent> | ||
| </Modal> | ||
| ); | ||
| } | ||
|
|
||
| export default ImportOverrideModalView; | ||
38 changes: 38 additions & 0 deletions
38
app/client/src/git/components/ImportOverrideModal/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import React, { useCallback } from "react"; | ||
| import ImportOverrideModalView from "./ImportOverrideModalView"; | ||
| import useImport from "git/hooks/useImport"; | ||
|
|
||
| function ImportOverrideModal() { | ||
| const { | ||
| gitImport, | ||
| importOverrideParams, | ||
| isImportOverrideModalOpen, | ||
| resetImportOverrideParams, | ||
| } = useImport(); | ||
|
|
||
| const handleOpenChange = useCallback( | ||
| (open: boolean) => { | ||
| if (!open) { | ||
| resetImportOverrideParams(); | ||
| } | ||
| }, | ||
| [resetImportOverrideParams], | ||
| ); | ||
|
|
||
| const handleImport = useCallback(() => { | ||
| if (importOverrideParams) { | ||
| gitImport(importOverrideParams); | ||
| } | ||
| }, [gitImport, importOverrideParams]); | ||
|
|
||
| return ( | ||
| <ImportOverrideModalView | ||
| artifactType={"package"} | ||
| isOpen={isImportOverrideModalOpen} | ||
| onImport={handleImport} | ||
| onOpenChange={handleOpenChange} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default ImportOverrideModal; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { useMemo } from "react"; | ||
|
|
||
| export default function useMessage(msg: string, args: Record<string, string>) { | ||
| return useMemo(() => { | ||
| const msgWithArgs = msg.replace(/\{\{([^}]+)\}\}/g, (match, p1) => { | ||
| // p1 is the key from {{key}} in the message | ||
| return args[p1] || match; | ||
| }); | ||
|
|
||
| return msgWithArgs; | ||
| }, [msg, args]); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.