-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: git tag - ui components for tagging release #39508
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| export const OPS_MODAL = { | ||
| TAB_RELEASE: "RELEASE", | ||
| }; | ||
|
|
||
| export const TAB_RELEASE = { | ||
| TITLE: "Release version", | ||
| RELEASE_BTN: "Release", | ||
| }; | ||
|
|
||
| export const RELEASE_VERSION_RADIO_GROUP = { | ||
| TITLE: "Version", | ||
| LAST_RELEASED: "Last released", | ||
| }; | ||
|
|
||
| export const RELEASE_NOTES_INPUT = { | ||
| TITLE: "Release notes", | ||
| PLACEHOLDER: "Your release notes here", | ||
| }; |
94 changes: 94 additions & 0 deletions
94
app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.test.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,94 @@ | ||
| import React from "react"; | ||
| import { render } from "@testing-library/react"; | ||
| import LatestCommitInfoView from "./LatestCommitInfoView"; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| describe("LatestCommitInfoView", () => { | ||
| it("renders correctly with all props", () => { | ||
| const { getByText } = render( | ||
| <LatestCommitInfoView | ||
| authorName="John Doe" | ||
| committedAt="2025-03-01" | ||
| hash="abc123" | ||
| message="Initial commit" | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText("Initial commit")).toBeInTheDocument(); | ||
| expect(getByText("John Doe committed 2025-03-01")).toBeInTheDocument(); | ||
| expect(getByText("abc123")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders correctly with null authorName", () => { | ||
| const { getByText } = render( | ||
| <LatestCommitInfoView | ||
| authorName={null} | ||
| committedAt="2025-03-01" | ||
| hash="abc123" | ||
| message="Initial commit" | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText("Initial commit")).toBeInTheDocument(); | ||
| expect(getByText("- committed 2025-03-01")).toBeInTheDocument(); | ||
| expect(getByText("abc123")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders correctly with null committedAt", () => { | ||
| const { getByText } = render( | ||
| <LatestCommitInfoView | ||
| authorName="John Doe" | ||
| committedAt={null} | ||
| hash="abc123" | ||
| message="Initial commit" | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText("Initial commit")).toBeInTheDocument(); | ||
| expect(getByText("John Doe committed -")).toBeInTheDocument(); | ||
| expect(getByText("abc123")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders correctly with null hash", () => { | ||
| const { getByText } = render( | ||
| <LatestCommitInfoView | ||
| authorName="John Doe" | ||
| committedAt="2025-03-01" | ||
| hash={null} | ||
| message="Initial commit" | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText("Initial commit")).toBeInTheDocument(); | ||
| expect(getByText("John Doe committed 2025-03-01")).toBeInTheDocument(); | ||
| expect(getByText("-")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders correctly with null message", () => { | ||
| const { getByText } = render( | ||
| <LatestCommitInfoView | ||
| authorName="John Doe" | ||
| committedAt="2025-03-01" | ||
| hash="abc123" | ||
| message={null} | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText("John Doe committed 2025-03-01")).toBeInTheDocument(); | ||
| expect(getByText("abc123")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders correctly with all null props", () => { | ||
| const { getByText } = render( | ||
| <LatestCommitInfoView | ||
| authorName={null} | ||
| committedAt={null} | ||
| hash={null} | ||
| message={null} | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText("- committed -")).toBeInTheDocument(); | ||
| expect(getByText("-")).toBeInTheDocument(); | ||
| }); | ||
| }); |
41 changes: 41 additions & 0 deletions
41
app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.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,41 @@ | ||
| import { Flex, Icon, Text } from "@appsmith/ads"; | ||
| import React from "react"; | ||
| import styled from "styled-components"; | ||
|
|
||
| const Container = styled(Flex)` | ||
| border-radius: 4px; | ||
| background-color: var(--ads-v2-color-gray-0); | ||
| `; | ||
|
|
||
| interface LatestCommitInfoViewProps { | ||
| authorName: string | null; | ||
| committedAt: string | null; | ||
| hash: string | null; | ||
| message: string | null; | ||
| } | ||
|
|
||
| function LatestCommitInfoView({ | ||
| authorName = null, | ||
| committedAt = null, | ||
| hash = null, | ||
| message = null, | ||
| }: LatestCommitInfoViewProps) { | ||
| return ( | ||
| <Container marginBottom="spaces-4" padding="spaces-3"> | ||
| <Flex flex={1} flexDirection="column" gap="spaces-3"> | ||
| <Text renderAs="p">{message}</Text> | ||
| <Text kind="body-s" renderAs="p"> | ||
| {authorName ?? "-"} committed {committedAt ?? "-"} | ||
| </Text> | ||
| </Flex> | ||
| <Flex alignItems="center" justifyContent="center"> | ||
| <Flex gap="spaces-2"> | ||
| <Icon name="git-commit" size="md" /> | ||
| <Text renderAs="p">{hash ?? "-"}</Text> | ||
| </Flex> | ||
| </Flex> | ||
| </Container> | ||
| ); | ||
| } | ||
|
|
||
| export default LatestCommitInfoView; |
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,18 @@ | ||
| import React from "react"; | ||
| import LatestCommitInfoView from "./LatestCommitInfoView"; | ||
| import useLatestCommit from "git/hooks/useLatestCommit"; | ||
|
|
||
| function LatestCommitInfo() { | ||
| const { latestCommit } = useLatestCommit(); | ||
|
|
||
| return ( | ||
| <LatestCommitInfoView | ||
| authorName={latestCommit?.authorName ?? null} | ||
| committedAt={latestCommit?.committedAt ?? null} | ||
| hash={latestCommit?.hash ?? null} | ||
| message={latestCommit?.message ?? null} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default LatestCommitInfo; |
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,60 @@ | ||
| import { Button, ModalBody, ModalFooter, Text } from "@appsmith/ads"; | ||
| import LatestCommitInfo from "git/components/LatestCommitInfo"; | ||
| import ReleaseNotesInput from "git/components/ReleaseNotesInput"; | ||
| import ReleaseVersionRadioGroup from "git/components/ReleaseVersionRadioGroup"; | ||
| import { TAB_RELEASE } from "git/ee/constants/messages"; | ||
| import React, { useCallback, useState } from "react"; | ||
| import styled from "styled-components"; | ||
|
|
||
| const Container = styled.div` | ||
| min-height: 360px; | ||
| overflow: unset; | ||
| padding-bottom: 4px; | ||
| `; | ||
|
|
||
| const TabTitle = styled(Text)` | ||
| margin-bottom: 12px; | ||
| color: var(--ads-v2-color-fg-emphasis); | ||
| `; | ||
|
|
||
| const StyledModalFooter = styled(ModalFooter)` | ||
| min-height: 52px; | ||
| `; | ||
|
|
||
| function TabRelease() { | ||
| const [releaseVersion, setReleaseVersion] = useState<string | null>(null); | ||
| const [releaseNotes, setReleaseNotes] = useState<string | null>(null); | ||
|
|
||
| const isReleaseDisabled = !releaseVersion || !releaseNotes; | ||
|
|
||
| const handleClickOnRelease = useCallback(() => {}, []); | ||
|
|
||
| return ( | ||
| <> | ||
| <ModalBody> | ||
| <Container> | ||
| <TabTitle kind="heading-s" renderAs="p"> | ||
| {TAB_RELEASE.TITLE} | ||
| </TabTitle> | ||
| <LatestCommitInfo /> | ||
| <ReleaseVersionRadioGroup onVersionChange={setReleaseVersion} /> | ||
| <ReleaseNotesInput | ||
| onTextChange={setReleaseNotes} | ||
| text={releaseNotes} | ||
| /> | ||
| </Container> | ||
| </ModalBody> | ||
| <StyledModalFooter> | ||
| <Button | ||
| isDisabled={isReleaseDisabled} | ||
| onClick={handleClickOnRelease} | ||
| size="md" | ||
| > | ||
| {TAB_RELEASE.RELEASE_BTN} | ||
| </Button> | ||
| </StyledModalFooter> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default TabRelease; | ||
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,32 @@ | ||
| import React from "react"; | ||
| import { Flex, Input } from "@appsmith/ads"; | ||
| import { RELEASE_NOTES_INPUT } from "git/ee/constants/messages"; | ||
brayn003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { noop } from "lodash"; | ||
|
|
||
| interface ReleaseNotesInputProps { | ||
| onTextChange: (text: string | null) => void; | ||
| text: string | null; | ||
| } | ||
|
|
||
| function ReleaseNotesInput({ | ||
| onTextChange = noop, | ||
| text = null, | ||
| }: ReleaseNotesInputProps) { | ||
| return ( | ||
| <Flex flexDirection={"column"}> | ||
| <Input | ||
| autoFocus | ||
| data-testid="t--git-release-notes-input" | ||
| label={RELEASE_NOTES_INPUT.TITLE} | ||
| onChange={onTextChange} | ||
brayn003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| placeholder={RELEASE_NOTES_INPUT.PLACEHOLDER} | ||
| renderAs="textarea" | ||
| size="md" | ||
| type="text" | ||
| value={text ?? undefined} | ||
| /> | ||
| </Flex> | ||
| ); | ||
| } | ||
|
|
||
| export default ReleaseNotesInput; | ||
72 changes: 72 additions & 0 deletions
72
app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.test.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 React from "react"; | ||
| import { render, fireEvent } from "@testing-library/react"; | ||
| import ReleaseVersionRadioGroupView from "./ReleaseVersionRadioGroupView"; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| describe("ReleaseVersionRadioGroupView", () => { | ||
| const mockOnVersionChange = jest.fn(); | ||
|
|
||
| const renderComponent = (props = {}) => { | ||
| return render( | ||
| <ReleaseVersionRadioGroupView | ||
| currentVersion="1.0.0" | ||
| onVersionChange={mockOnVersionChange} | ||
| releasedAt="2023-01-01" | ||
| {...props} | ||
| />, | ||
| ); | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| mockOnVersionChange.mockClear(); | ||
| }); | ||
|
|
||
| it("should render correctly with initial props", () => { | ||
| const { getByRole, getByTestId } = renderComponent(); | ||
|
|
||
| expect(getByTestId("t--git-release-version-title").textContent).toBe( | ||
| "Version", | ||
| ); | ||
| expect(getByTestId("t--git-release-next-version").textContent).toBe( | ||
| "1.0.1", | ||
| ); | ||
| expect(getByTestId("t--git-release-released-at").textContent).toBe( | ||
| "Last released: 1.0.0 (2023-01-01)", | ||
| ); | ||
| expect(getByRole("radio", { name: /patch/i })).toBeChecked(); | ||
| }); | ||
|
|
||
| it("should change version when a different radio button is selected", () => { | ||
| const { getByRole, getByTestId } = renderComponent(); | ||
|
|
||
| fireEvent.click(getByRole("radio", { name: /minor/i })); | ||
| expect(getByTestId("t--git-release-next-version").textContent).toBe( | ||
| "1.1.0", | ||
| ); | ||
| fireEvent.click(getByRole("radio", { name: /major/i })); | ||
| expect(getByTestId("t--git-release-next-version").textContent).toBe( | ||
| "2.0.0", | ||
| ); | ||
| }); | ||
|
|
||
| it("should call onVersionChange with the correct version", () => { | ||
| const { getByRole } = renderComponent(); | ||
|
|
||
| expect(mockOnVersionChange).toHaveBeenCalledWith("1.0.1"); // initial call with patch version | ||
| fireEvent.click(getByRole("radio", { name: /minor/i })); | ||
| expect(mockOnVersionChange).toHaveBeenCalledWith("1.1.0"); | ||
| fireEvent.click(getByRole("radio", { name: /major/i })); | ||
| expect(mockOnVersionChange).toHaveBeenCalledWith("2.0.0"); | ||
| }); | ||
|
|
||
| it("should handle null values for currentVersion and releasedAt", () => { | ||
| const { getByTestId } = renderComponent({ | ||
| currentVersion: null, | ||
| releasedAt: null, | ||
| }); | ||
|
|
||
| expect(getByTestId("t--git-release-released-at").textContent).toBe( | ||
| "Last released: - (-)", | ||
| ); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.