From c0ed0facbecf04ba23a4bd93d498d6b2b4701d8f Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Wed, 5 Mar 2025 17:28:45 +0100 Subject: [PATCH 01/12] chore: fixing contracts for pretag --- .../git/components/LatestCommitInfo/index.tsx | 12 +++--- .../TabReleaseView.tsx} | 18 +++++++-- .../components/OpsModal/TabRelease/index.tsx | 11 ++++++ .../ReleaseVersionRadioGroup/index.tsx | 8 ++-- app/client/src/git/hooks/useLatestCommit.ts | 29 -------------- app/client/src/git/hooks/usePretag.ts | 27 +++++++++++++ .../fetchLatestCommitRequest.types.ts | 13 ------- ...atestCommitRequest.ts => pretagRequest.ts} | 6 +-- .../src/git/requests/pretagRequest.types.ts | 17 +++++++++ .../store/actions/fetchLatestCommitActions.ts | 38 ------------------- .../src/git/store/actions/pretagActions.ts | 38 +++++++++++++++++++ app/client/src/git/store/gitArtifactSlice.ts | 14 +++---- .../src/git/store/helpers/initialState.ts | 10 ++--- .../store/selectors/gitArtifactSelectors.ts | 4 +- app/client/src/git/store/types.ts | 4 +- 15 files changed, 137 insertions(+), 112 deletions(-) rename app/client/src/git/components/OpsModal/{TabRelease.tsx => TabRelease/TabReleaseView.tsx} (81%) create mode 100644 app/client/src/git/components/OpsModal/TabRelease/index.tsx delete mode 100644 app/client/src/git/hooks/useLatestCommit.ts create mode 100644 app/client/src/git/hooks/usePretag.ts delete mode 100644 app/client/src/git/requests/fetchLatestCommitRequest.types.ts rename app/client/src/git/requests/{fetchLatestCommitRequest.ts => pretagRequest.ts} (68%) create mode 100644 app/client/src/git/requests/pretagRequest.types.ts delete mode 100644 app/client/src/git/store/actions/fetchLatestCommitActions.ts create mode 100644 app/client/src/git/store/actions/pretagActions.ts diff --git a/app/client/src/git/components/LatestCommitInfo/index.tsx b/app/client/src/git/components/LatestCommitInfo/index.tsx index ce04d0695e36..98d9215d3256 100644 --- a/app/client/src/git/components/LatestCommitInfo/index.tsx +++ b/app/client/src/git/components/LatestCommitInfo/index.tsx @@ -1,16 +1,16 @@ import React from "react"; import LatestCommitInfoView from "./LatestCommitInfoView"; -import useLatestCommit from "git/hooks/useLatestCommit"; +import usePretag from "git/hooks/usePretag"; function LatestCommitInfo() { - const { latestCommit } = useLatestCommit(); + const { pretagResponse } = usePretag(); return ( ); } diff --git a/app/client/src/git/components/OpsModal/TabRelease.tsx b/app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx similarity index 81% rename from app/client/src/git/components/OpsModal/TabRelease.tsx rename to app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx index b1ce504ac26e..e408edb249a1 100644 --- a/app/client/src/git/components/OpsModal/TabRelease.tsx +++ b/app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx @@ -3,7 +3,8 @@ 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 noop from "lodash/noop"; +import React, { useCallback, useEffect, useState } from "react"; import styled from "styled-components"; const Container = styled.div` @@ -21,12 +22,23 @@ const StyledModalFooter = styled(ModalFooter)` min-height: 52px; `; -function TabRelease() { +interface TabReleaseProps { + fetchPretag: () => void; +} + +function TabReleaseView({ fetchPretag = noop }: TabReleaseProps) { const [releaseVersion, setReleaseVersion] = useState(null); const [releaseNotes, setReleaseNotes] = useState(null); const isReleaseDisabled = !releaseVersion || !releaseNotes; + useEffect( + function fetchPretagOnInitEffect() { + fetchPretag(); + }, + [fetchPretag], + ); + const handleClickOnRelease = useCallback(() => {}, []); return ( @@ -57,4 +69,4 @@ function TabRelease() { ); } -export default TabRelease; +export default TabReleaseView; diff --git a/app/client/src/git/components/OpsModal/TabRelease/index.tsx b/app/client/src/git/components/OpsModal/TabRelease/index.tsx new file mode 100644 index 000000000000..a66dbddfd93e --- /dev/null +++ b/app/client/src/git/components/OpsModal/TabRelease/index.tsx @@ -0,0 +1,11 @@ +import React from "react"; +import TabReleaseView from "./TabReleaseView"; +import usePretag from "git/hooks/usePretag"; + +function TabRelease() { + const { fetchPretag } = usePretag(); + + return ; +} + +export default TabRelease; diff --git a/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx b/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx index a117dea1dc34..c51db5f2887b 100644 --- a/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx +++ b/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx @@ -1,7 +1,7 @@ import React from "react"; import ReleaseVersionRadioGroupView from "./ReleaseVersionRadioGroupView"; import noop from "lodash/noop"; -import useLatestCommit from "git/hooks/useLatestCommit"; +import usePretag from "git/hooks/usePretag"; interface ReleaseVersionRadioGroupProps { onVersionChange: (version: string | null) => void; @@ -10,13 +10,13 @@ interface ReleaseVersionRadioGroupProps { function ReleaseVersionRadioGroup({ onVersionChange = noop, }: ReleaseVersionRadioGroupProps) { - const { latestCommit } = useLatestCommit(); + const { pretagResponse } = usePretag(); return ( ); } diff --git a/app/client/src/git/hooks/useLatestCommit.ts b/app/client/src/git/hooks/useLatestCommit.ts deleted file mode 100644 index 2d96ece707de..000000000000 --- a/app/client/src/git/hooks/useLatestCommit.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { useGitContext } from "git/components/GitContextProvider"; -import useArtifactSelector from "./useArtifactSelector"; -import { selectLatestCommitState } from "git/store/selectors/gitArtifactSelectors"; -import { useDispatch } from "react-redux"; -import { gitArtifactActions } from "git/store/gitArtifactSlice"; -import { useCallback } from "react"; - -export default function useLatestCommit() { - const dispatch = useDispatch(); - const { artifact, artifactDef } = useGitContext(); - const artifactId = artifact?.id; - - const latestCommitState = useArtifactSelector(selectLatestCommitState); - - const fetchLatestCommit = useCallback(() => { - if (artifactDef && artifactId) { - dispatch( - gitArtifactActions.fetchLatestCommitInit({ artifactDef, artifactId }), - ); - } - }, [artifactDef, artifactId, dispatch]); - - return { - latestCommit: latestCommitState?.value ?? null, - isLatestCommitLoading: latestCommitState?.loading ?? false, - latestCommitError: latestCommitState?.error ?? null, - fetchLatestCommit, - }; -} diff --git a/app/client/src/git/hooks/usePretag.ts b/app/client/src/git/hooks/usePretag.ts new file mode 100644 index 000000000000..55805ecf9bd8 --- /dev/null +++ b/app/client/src/git/hooks/usePretag.ts @@ -0,0 +1,27 @@ +import { useGitContext } from "git/components/GitContextProvider"; +import useArtifactSelector from "./useArtifactSelector"; +import { useDispatch } from "react-redux"; +import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { useCallback } from "react"; +import { selectPretagState } from "git/store/selectors/gitArtifactSelectors"; + +export default function usePretag() { + const dispatch = useDispatch(); + const { artifact, artifactDef } = useGitContext(); + const artifactId = artifact?.id; + + const pretagState = useArtifactSelector(selectPretagState); + + const fetchPretag = useCallback(() => { + if (artifactDef && artifactId) { + dispatch(gitArtifactActions.pretagInit({ artifactDef, artifactId })); + } + }, [artifactDef, artifactId, dispatch]); + + return { + pretagResponse: pretagState?.value ?? null, + isPretagLoading: pretagState?.loading ?? false, + pretagError: pretagState?.error ?? null, + fetchPretag, + }; +} diff --git a/app/client/src/git/requests/fetchLatestCommitRequest.types.ts b/app/client/src/git/requests/fetchLatestCommitRequest.types.ts deleted file mode 100644 index 3a21cc31edcc..000000000000 --- a/app/client/src/git/requests/fetchLatestCommitRequest.types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { ApiResponse } from "api/types"; - -export interface FetchLatestCommitResponseData { - authorName: string; - committedAt: string; - hash: string; - message: string; - releaseTagName: string; - releasedAt: string; -} - -export type FetchLatestCommitResponse = - ApiResponse; diff --git a/app/client/src/git/requests/fetchLatestCommitRequest.ts b/app/client/src/git/requests/pretagRequest.ts similarity index 68% rename from app/client/src/git/requests/fetchLatestCommitRequest.ts rename to app/client/src/git/requests/pretagRequest.ts index e1c2fb150650..fca382ce49e2 100644 --- a/app/client/src/git/requests/fetchLatestCommitRequest.ts +++ b/app/client/src/git/requests/pretagRequest.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import type { AxiosPromise } from "axios"; import type { GitArtifactType } from "git/constants/enums"; -import type { FetchLatestCommitResponse } from "./fetchLatestCommitRequest.types"; +import type { PretagResponse } from "./pretagRequest.types"; import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; -export default async function fetchLatestCommitRequest( +export default async function pretagRequest( artifactType: GitArtifactType, branchedArtifactId: string, -): AxiosPromise { +): AxiosPromise { return Api.get( `${GIT_BASE_URL}/${artifactType}/${branchedArtifactId}/commit/latest`, ); diff --git a/app/client/src/git/requests/pretagRequest.types.ts b/app/client/src/git/requests/pretagRequest.types.ts new file mode 100644 index 000000000000..b6b6ce62fee3 --- /dev/null +++ b/app/client/src/git/requests/pretagRequest.types.ts @@ -0,0 +1,17 @@ +import type { ApiResponse } from "api/types"; + +export interface PretagResponseData { + author: { + name: string; + email: string; + }; + committedAt: string; + hash: string; + message: string; + + releaseTagName: string; + releasedAt: string; + isReleasable: boolean; +} + +export type PretagResponse = ApiResponse; diff --git a/app/client/src/git/store/actions/fetchLatestCommitActions.ts b/app/client/src/git/store/actions/fetchLatestCommitActions.ts deleted file mode 100644 index dfb842d657de..000000000000 --- a/app/client/src/git/store/actions/fetchLatestCommitActions.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { - GitArtifactErrorPayloadAction, - GitAsyncSuccessPayload, -} from "../types"; -import { createArtifactAction } from "../helpers/createArtifactAction"; -import type { FetchLatestCommitResponseData } from "git/requests/fetchLatestCommitRequest.types"; - -export interface FetchLatestCommitInitPayload { - artifactId: string; -} - -export const fetchLatestCommitInitAction = - createArtifactAction((state) => { - state.apiResponses.latestCommit.loading = true; - state.apiResponses.latestCommit.error = null; - - return state; - }); - -export const fetchLatestCommitSuccessAction = createArtifactAction< - GitAsyncSuccessPayload ->((state, action) => { - state.apiResponses.latestCommit.loading = false; - state.apiResponses.latestCommit.value = action.payload.responseData; - - return state; -}); - -export const fetchLatestCommitErrorAction = createArtifactAction( - (state, action: GitArtifactErrorPayloadAction) => { - const { error } = action.payload; - - state.apiResponses.latestCommit.loading = false; - state.apiResponses.latestCommit.error = error; - - return state; - }, -); diff --git a/app/client/src/git/store/actions/pretagActions.ts b/app/client/src/git/store/actions/pretagActions.ts new file mode 100644 index 000000000000..3c846a91b87f --- /dev/null +++ b/app/client/src/git/store/actions/pretagActions.ts @@ -0,0 +1,38 @@ +import type { + GitArtifactErrorPayloadAction, + GitAsyncSuccessPayload, +} from "../types"; +import { createArtifactAction } from "../helpers/createArtifactAction"; +import type { PretagResponseData } from "git/requests/pretagRequest.types"; + +export interface FetchLatestCommitInitPayload { + artifactId: string; +} + +export const pretagInitAction = + createArtifactAction((state) => { + state.apiResponses.pretag.loading = true; + state.apiResponses.pretag.error = null; + + return state; + }); + +export const pretagSuccessAction = createArtifactAction< + GitAsyncSuccessPayload +>((state, action) => { + state.apiResponses.pretag.loading = false; + state.apiResponses.pretag.value = action.payload.responseData; + + return state; +}); + +export const pretagErrorAction = createArtifactAction( + (state, action: GitArtifactErrorPayloadAction) => { + const { error } = action.payload; + + state.apiResponses.pretag.loading = false; + state.apiResponses.pretag.error = error; + + return state; + }, +); diff --git a/app/client/src/git/store/gitArtifactSlice.ts b/app/client/src/git/store/gitArtifactSlice.ts index f5bdcac8801f..10267ccbe7a7 100644 --- a/app/client/src/git/store/gitArtifactSlice.ts +++ b/app/client/src/git/store/gitArtifactSlice.ts @@ -142,10 +142,10 @@ import { updateCurrentBranchAction, } from "./actions/currentBranchActions"; import { - fetchLatestCommitErrorAction, - fetchLatestCommitInitAction, - fetchLatestCommitSuccessAction, -} from "./actions/fetchLatestCommitActions"; + pretagErrorAction, + pretagInitAction, + pretagSuccessAction, +} from "./actions/pretagActions"; const initialState: GitArtifactRootReduxState = {}; @@ -210,9 +210,9 @@ export const gitArtifactSlice = createSlice({ pullError: pullErrorAction, toggleOpsModal: toggleOpsModalAction, toggleConflictErrorModal: toggleConflictErrorModalAction, - fetchLatestCommitInit: fetchLatestCommitInitAction, - fetchLatestCommitSuccess: fetchLatestCommitSuccessAction, - fetchLatestCommitError: fetchLatestCommitErrorAction, + pretagInit: pretagInitAction, + pretagSuccess: pretagSuccessAction, + pretagError: pretagErrorAction, // branches fetchBranchesInit: fetchBranchesInitAction, diff --git a/app/client/src/git/store/helpers/initialState.ts b/app/client/src/git/store/helpers/initialState.ts index 1781a28342f7..8401a1ee96d9 100644 --- a/app/client/src/git/store/helpers/initialState.ts +++ b/app/client/src/git/store/helpers/initialState.ts @@ -52,11 +52,6 @@ const gitArtifactInitialAPIResponses: GitArtifactAPIResponsesReduxState = { loading: false, error: null, }, - latestCommit: { - value: null, - loading: false, - error: null, - }, pull: { loading: false, error: null, @@ -134,6 +129,11 @@ const gitArtifactInitialAPIResponses: GitArtifactAPIResponsesReduxState = { loading: false, error: null, }, + pretag: { + value: null, + loading: false, + error: null, + }, // EE ...gitArtifactAPIResponsesInitialStateExtended, }; diff --git a/app/client/src/git/store/selectors/gitArtifactSelectors.ts b/app/client/src/git/store/selectors/gitArtifactSelectors.ts index 6df75a63b210..6207823dff0a 100644 --- a/app/client/src/git/store/selectors/gitArtifactSelectors.ts +++ b/app/client/src/git/store/selectors/gitArtifactSelectors.ts @@ -88,10 +88,10 @@ export const selectCommitState = ( artifactDef: GitArtifactDef, ) => selectGitArtifact(state, artifactDef)?.apiResponses?.commit; -export const selectLatestCommitState = ( +export const selectPretagState = ( state: GitRootState, artifactDef: GitArtifactDef, -) => selectGitArtifact(state, artifactDef)?.apiResponses?.latestCommit; +) => selectGitArtifact(state, artifactDef)?.apiResponses?.pretag; export const selectDiscardState = ( state: GitRootState, diff --git a/app/client/src/git/store/types.ts b/app/client/src/git/store/types.ts index e62b7ec47990..2513d965b207 100644 --- a/app/client/src/git/store/types.ts +++ b/app/client/src/git/store/types.ts @@ -19,7 +19,7 @@ import type { import type { FetchGlobalSSHKeyResponseData } from "git/requests/fetchGlobalSSHKeyRequest.types"; import type { FetchRefsResponseData } from "git/requests/fetchRefsRequest.types"; import type { GitArtifactDef } from "git/types"; -import type { FetchLatestCommitResponseData } from "git/requests/fetchLatestCommitRequest.types"; +import type { PretagResponseData } from "git/requests/pretagRequest.types"; export interface GitApiError extends ApiResponseError { errorType?: string; @@ -42,7 +42,6 @@ export interface GitArtifactAPIResponsesReduxState connect: GitAsyncStateWithoutValue; status: GitAsyncState; commit: GitAsyncStateWithoutValue; - latestCommit: GitAsyncState; pull: GitAsyncStateWithoutValue; discard: GitAsyncStateWithoutValue; mergeStatus: GitAsyncState; @@ -61,6 +60,7 @@ export interface GitArtifactAPIResponsesReduxState triggerAutocommit: GitAsyncStateWithoutValue; sshKey: GitAsyncState; generateSSHKey: GitAsyncStateWithoutValue; + pretag: GitAsyncState; } export interface GitArtifactUIReduxState From 4e8ddf6d714498d5168af88ffc82c5a3ff889f83 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Wed, 5 Mar 2025 17:41:41 +0100 Subject: [PATCH 02/12] chore: pretag payload --- app/client/src/git/store/actions/pretagActions.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/client/src/git/store/actions/pretagActions.ts b/app/client/src/git/store/actions/pretagActions.ts index 3c846a91b87f..86a6efaf9302 100644 --- a/app/client/src/git/store/actions/pretagActions.ts +++ b/app/client/src/git/store/actions/pretagActions.ts @@ -5,17 +5,18 @@ import type { import { createArtifactAction } from "../helpers/createArtifactAction"; import type { PretagResponseData } from "git/requests/pretagRequest.types"; -export interface FetchLatestCommitInitPayload { +export interface PretagInitPayload { artifactId: string; } -export const pretagInitAction = - createArtifactAction((state) => { +export const pretagInitAction = createArtifactAction( + (state) => { state.apiResponses.pretag.loading = true; state.apiResponses.pretag.error = null; return state; - }); + }, +); export const pretagSuccessAction = createArtifactAction< GitAsyncSuccessPayload From bd278c8537a5126ac9d1b2903526798dc6c24a63 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Wed, 5 Mar 2025 17:58:50 +0100 Subject: [PATCH 03/12] chore: adding tagging --- .../git/components/OpsModal/OpsModalView.tsx | 20 +++++++++++ .../src/git/components/OpsModal/index.tsx | 3 ++ .../src/git/helpers/isGitTaggingEnabled.ts | 12 +++++++ app/client/src/git/sagas/index.ts | 4 +++ app/client/src/git/sagas/pretagSaga.ts | 36 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 app/client/src/git/helpers/isGitTaggingEnabled.ts create mode 100644 app/client/src/git/sagas/pretagSaga.ts diff --git a/app/client/src/git/components/OpsModal/OpsModalView.tsx b/app/client/src/git/components/OpsModal/OpsModalView.tsx index a0f696a747f4..9a38f0393e74 100644 --- a/app/client/src/git/components/OpsModal/OpsModalView.tsx +++ b/app/client/src/git/components/OpsModal/OpsModalView.tsx @@ -15,6 +15,10 @@ import styled from "styled-components"; // import ReconnectSSHError from "../components/ReconnectSSHError"; import { GitOpsTab } from "git/constants/enums"; import noop from "lodash/noop"; +import isGitTaggingEnabled from "git/helpers/isGitTaggingEnabled"; +import type { GitArtifactDef } from "git/types"; +import TabRelease from "./TabRelease"; +import { OPS_MODAL } from "git/ee/constants/messages"; const StyledModalContent = styled(ModalContent)` &&& { @@ -27,6 +31,7 @@ const StyledModalContent = styled(ModalContent)` `; interface OpsModalViewProps { + artifactDef: GitArtifactDef | null; fetchStatus: () => void; isOpsModalOpen: boolean; isProtectedMode: boolean; @@ -36,6 +41,7 @@ interface OpsModalViewProps { } function OpsModalView({ + artifactDef = null, fetchStatus = noop, isOpsModalOpen = false, isProtectedMode = false, @@ -43,6 +49,8 @@ function OpsModalView({ repoName = null, toggleOpsModal = noop, }: OpsModalViewProps) { + const isTaggingEnabled = isGitTaggingEnabled(artifactDef); + useEffect( function fetchStatusOnMountEffect() { if (isOpsModalOpen) { @@ -92,9 +100,21 @@ function OpsModalView({ {createMessage(MERGE)} + {isTaggingEnabled && ( + + {OPS_MODAL.TAB_RELEASE} + + )} {opsModalTab === GitOpsTab.Deploy && } {opsModalTab === GitOpsTab.Merge && } + {isTaggingEnabled && opsModalTab === GitOpsTab.Release && ( + + )} {/* */} diff --git a/app/client/src/git/components/OpsModal/index.tsx b/app/client/src/git/components/OpsModal/index.tsx index 66ea3ddf0182..2ba8febd7cd7 100644 --- a/app/client/src/git/components/OpsModal/index.tsx +++ b/app/client/src/git/components/OpsModal/index.tsx @@ -5,8 +5,10 @@ import useStatus from "git/hooks/useStatus"; import useOps from "git/hooks/useOps"; import useProtectedMode from "git/hooks/useProtectedMode"; import { GitOpsTab } from "git/constants/enums"; +import { useGitContext } from "../GitContextProvider"; export default function OpsModal() { + const { artifactDef } = useGitContext(); const { isOpsModalOpen, opsModalTab, toggleOpsModal } = useOps(); const { fetchStatus } = useStatus(); const isProtectedMode = useProtectedMode(); @@ -17,6 +19,7 @@ export default function OpsModal() { return ( , +) { + const { artifactDef, artifactId } = action.payload; + let response: PretagResponse | undefined; + + try { + response = yield call(pretagRequest, artifactDef.artifactType, artifactId); + + const isValidResponse: boolean = yield validateResponse(response); + + if (isValidResponse && response?.data) { + yield put( + gitArtifactActions.pretagSuccess({ + artifactDef, + responseData: response.data, + }), + ); + } + } catch (e) { + const error = handleApiErrors(e as Error, response); + + if (error) { + yield put(gitArtifactActions.pretagError({ artifactDef, error })); + } + } +} From 5daaa5262f9235eeada3a70df3b2d5b3b1654b46 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Thu, 6 Mar 2025 17:59:15 +0100 Subject: [PATCH 04/12] chore: adding fixes to release tab --- app/client/src/git/ce/constants/messages.tsx | 2 +- .../LatestCommitInfo/LatestCommitInfoView.tsx | 7 ++-- .../git/components/LatestCommitInfo/index.tsx | 6 +++- .../git/components/OpsModal/OpsModalView.tsx | 18 +++++------ .../ReleaseVersionRadioGroupView.tsx | 24 ++++++++------ .../ReleaseVersionRadioGroup/index.tsx | 2 +- app/client/src/git/requests/pretagRequest.ts | 2 +- .../store/actions/createReleaseTagActions.ts | 32 +++++++++++++++++++ app/client/src/git/store/gitArtifactSlice.ts | 16 ++++++++-- app/client/src/git/store/types.ts | 1 + 10 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 app/client/src/git/store/actions/createReleaseTagActions.ts diff --git a/app/client/src/git/ce/constants/messages.tsx b/app/client/src/git/ce/constants/messages.tsx index 0978898423ff..7dc036211f51 100644 --- a/app/client/src/git/ce/constants/messages.tsx +++ b/app/client/src/git/ce/constants/messages.tsx @@ -1,5 +1,5 @@ export const OPS_MODAL = { - TAB_RELEASE: "RELEASE", + TAB_RELEASE: "Release", }; export const TAB_RELEASE = { diff --git a/app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx b/app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx index fc6fb1ce671f..a005b696643f 100644 --- a/app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx +++ b/app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx @@ -23,9 +23,12 @@ function LatestCommitInfoView({ return ( - {message} + {message ?? "My latest commit message"} - {authorName ?? "-"} committed {committedAt ?? "-"} + {authorName && !committedAt ? `Committed by ${authorName}` : null} + {authorName && committedAt + ? `${authorName} committed ${committedAt ?? "-"}` + : null} diff --git a/app/client/src/git/components/LatestCommitInfo/index.tsx b/app/client/src/git/components/LatestCommitInfo/index.tsx index 98d9215d3256..17543396324b 100644 --- a/app/client/src/git/components/LatestCommitInfo/index.tsx +++ b/app/client/src/git/components/LatestCommitInfo/index.tsx @@ -5,11 +5,15 @@ import usePretag from "git/hooks/usePretag"; function LatestCommitInfo() { const { pretagResponse } = usePretag(); + const commitHash = pretagResponse?.hash + ? pretagResponse.hash.slice(0, 7) + : null; + return ( ); diff --git a/app/client/src/git/components/OpsModal/OpsModalView.tsx b/app/client/src/git/components/OpsModal/OpsModalView.tsx index 9a38f0393e74..54bd0c80476a 100644 --- a/app/client/src/git/components/OpsModal/OpsModalView.tsx +++ b/app/client/src/git/components/OpsModal/OpsModalView.tsx @@ -99,16 +99,16 @@ function OpsModalView({ > {createMessage(MERGE)} + {isTaggingEnabled && ( + + {OPS_MODAL.TAB_RELEASE} + + )} - {isTaggingEnabled && ( - - {OPS_MODAL.TAB_RELEASE} - - )} {opsModalTab === GitOpsTab.Deploy && } {opsModalTab === GitOpsTab.Merge && } diff --git a/app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx b/app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx index 3f05c811e19d..0aa83c793acd 100644 --- a/app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx +++ b/app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx @@ -7,23 +7,23 @@ import noop from "lodash/noop"; type ReleaseType = "major" | "minor" | "patch" | null; interface ReleaseVersionRadioGroupViewProps { - currentVersion: string | null; + latestReleaseVersion: string | null; onVersionChange: (value: string | null) => void; releasedAt: string | null; } function ReleaseVersionRadioGroupView({ - currentVersion = null, + latestReleaseVersion = null, onVersionChange = noop, releasedAt = null, }: ReleaseVersionRadioGroupViewProps) { const [releaseType, setReleaseType] = useState("patch"); const nextVersion = useMemo(() => { - if (!currentVersion || !releaseType) return null; + if (!releaseType) return null; - return inc(currentVersion, releaseType); - }, [currentVersion, releaseType]); + return inc(latestReleaseVersion ?? "0.0.0", releaseType); + }, [latestReleaseVersion, releaseType]); useEffect( function releaseVersionChangeEffect() { @@ -62,10 +62,16 @@ function ReleaseVersionRadioGroupView({ Patch - - {RELEASE_VERSION_RADIO_GROUP.LAST_RELEASED}: {currentVersion ?? "-"} ( - {releasedAt ?? "-"}) - + {latestReleaseVersion && ( + + {RELEASE_VERSION_RADIO_GROUP.LAST_RELEASED}:{" "} + {latestReleaseVersion ?? "-"} ({releasedAt ?? "-"}) + + )} ); } diff --git a/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx b/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx index c51db5f2887b..cd25d77669d2 100644 --- a/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx +++ b/app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx @@ -14,7 +14,7 @@ function ReleaseVersionRadioGroup({ return ( diff --git a/app/client/src/git/requests/pretagRequest.ts b/app/client/src/git/requests/pretagRequest.ts index fca382ce49e2..82cc8938e8fa 100644 --- a/app/client/src/git/requests/pretagRequest.ts +++ b/app/client/src/git/requests/pretagRequest.ts @@ -10,6 +10,6 @@ export default async function pretagRequest( branchedArtifactId: string, ): AxiosPromise { return Api.get( - `${GIT_BASE_URL}/${artifactType}/${branchedArtifactId}/commit/latest`, + `${GIT_BASE_URL}/${artifactType}/${branchedArtifactId}/pretag`, ); } diff --git a/app/client/src/git/store/actions/createReleaseTagActions.ts b/app/client/src/git/store/actions/createReleaseTagActions.ts new file mode 100644 index 000000000000..e6d761e1dffe --- /dev/null +++ b/app/client/src/git/store/actions/createReleaseTagActions.ts @@ -0,0 +1,32 @@ +import { createArtifactAction } from "../helpers/createArtifactAction"; +import type { GitAsyncErrorPayload } from "../types"; + +export interface CreateReleaseTagInitPayload { + tag: string; + releaseNote: string; + commitSHA: string; +} + +export const createReleaseTagInitAction = + createArtifactAction((state) => { + state.apiResponses.createReleaseTag.loading = true; + state.apiResponses.createReleaseTag.error = null; + + return state; + }); + +export const createReleaseTagSuccessAction = createArtifactAction((state) => { + state.apiResponses.createReleaseTag.loading = false; + + return state; +}); + +export const createReleaseTagErrorAction = + createArtifactAction((state, action) => { + const { error } = action.payload; + + state.apiResponses.createReleaseTag.loading = false; + state.apiResponses.createReleaseTag.error = error; + + return state; + }); diff --git a/app/client/src/git/store/gitArtifactSlice.ts b/app/client/src/git/store/gitArtifactSlice.ts index 10267ccbe7a7..01c04f21b85f 100644 --- a/app/client/src/git/store/gitArtifactSlice.ts +++ b/app/client/src/git/store/gitArtifactSlice.ts @@ -146,6 +146,11 @@ import { pretagInitAction, pretagSuccessAction, } from "./actions/pretagActions"; +import { + createReleaseTagErrorAction, + createReleaseTagInitAction, + createReleaseTagSuccessAction, +} from "./actions/createReleaseTagActions"; const initialState: GitArtifactRootReduxState = {}; @@ -210,9 +215,6 @@ export const gitArtifactSlice = createSlice({ pullError: pullErrorAction, toggleOpsModal: toggleOpsModalAction, toggleConflictErrorModal: toggleConflictErrorModalAction, - pretagInit: pretagInitAction, - pretagSuccess: pretagSuccessAction, - pretagError: pretagErrorAction, // branches fetchBranchesInit: fetchBranchesInitAction, @@ -260,6 +262,14 @@ export const gitArtifactSlice = createSlice({ pollAutocommitProgressStop: pollAutocommitProgressStopAction, toggleAutocommitDisableModal: toggleAutocommitDisableModalAction, + // release tags + pretagInit: pretagInitAction, + pretagSuccess: pretagSuccessAction, + pretagError: pretagErrorAction, + createReleaseTagInit: createReleaseTagInitAction, + createReleaseTagSuccess: createReleaseTagSuccessAction, + createReleaseTagError: createReleaseTagErrorAction, + ...gitArtifactCaseReducers, }, }); diff --git a/app/client/src/git/store/types.ts b/app/client/src/git/store/types.ts index 2513d965b207..da80f539a2e8 100644 --- a/app/client/src/git/store/types.ts +++ b/app/client/src/git/store/types.ts @@ -61,6 +61,7 @@ export interface GitArtifactAPIResponsesReduxState sshKey: GitAsyncState; generateSSHKey: GitAsyncStateWithoutValue; pretag: GitAsyncState; + createReleaseTag: GitAsyncStateWithoutValue; } export interface GitArtifactUIReduxState From 76266a9a8b3d73a00376130109a4480e2ac2c5d5 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Thu, 6 Mar 2025 18:43:17 +0100 Subject: [PATCH 05/12] chore: hooking action to tag --- .../OpsModal/TabRelease/TabReleaseView.tsx | 23 ++++++++++- .../components/OpsModal/TabRelease/index.tsx | 15 +++++++- app/client/src/git/hooks/useReleaseTag.ts | 38 +++++++++++++++++++ .../store/actions/createReleaseTagActions.ts | 1 + .../store/selectors/gitArtifactSelectors.ts | 5 +++ 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 app/client/src/git/hooks/useReleaseTag.ts diff --git a/app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx b/app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx index e408edb249a1..a28bff3afb2e 100644 --- a/app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx +++ b/app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx @@ -24,9 +24,21 @@ const StyledModalFooter = styled(ModalFooter)` interface TabReleaseProps { fetchPretag: () => void; + createReleaseTag: (params: { + tag: string; + releaseNote: string; + commitSHA: string; + }) => void; + isCreateReleaseTagLoading: boolean; + latestCommitSHA: string | null; } -function TabReleaseView({ fetchPretag = noop }: TabReleaseProps) { +function TabReleaseView({ + createReleaseTag = noop, + fetchPretag = noop, + isCreateReleaseTagLoading = false, + latestCommitSHA = null, +}: TabReleaseProps) { const [releaseVersion, setReleaseVersion] = useState(null); const [releaseNotes, setReleaseNotes] = useState(null); @@ -39,7 +51,13 @@ function TabReleaseView({ fetchPretag = noop }: TabReleaseProps) { [fetchPretag], ); - const handleClickOnRelease = useCallback(() => {}, []); + const handleClickOnRelease = useCallback(() => { + createReleaseTag({ + tag: releaseVersion ?? "", + releaseNote: releaseNotes ?? "", + commitSHA: latestCommitSHA ?? "", + }); + }, [createReleaseTag, latestCommitSHA, releaseNotes, releaseVersion]); return ( <> @@ -59,6 +77,7 @@ function TabReleaseView({ fetchPretag = noop }: TabReleaseProps) {