Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions app/client/src/git/components/LatestCommitInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<LatestCommitInfoView
authorName={latestCommit?.authorName ?? null}
committedAt={latestCommit?.committedAt ?? null}
hash={latestCommit?.hash ?? null}
message={latestCommit?.message ?? null}
authorName={pretagResponse?.author.name ?? null}
committedAt={pretagResponse?.committedAt ?? null}
hash={pretagResponse?.hash ?? null}
message={pretagResponse?.message ?? null}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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<string | null>(null);
const [releaseNotes, setReleaseNotes] = useState<string | null>(null);

const isReleaseDisabled = !releaseVersion || !releaseNotes;

useEffect(
function fetchPretagOnInitEffect() {
fetchPretag();
},
[fetchPretag],
);

const handleClickOnRelease = useCallback(() => {}, []);

return (
Expand Down Expand Up @@ -57,4 +69,4 @@ function TabRelease() {
);
}

export default TabRelease;
export default TabReleaseView;
11 changes: 11 additions & 0 deletions app/client/src/git/components/OpsModal/TabRelease/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import TabReleaseView from "./TabReleaseView";
import usePretag from "git/hooks/usePretag";

function TabRelease() {
const { fetchPretag } = usePretag();

return <TabReleaseView fetchPretag={fetchPretag} />;
}

export default TabRelease;
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,13 +10,13 @@ interface ReleaseVersionRadioGroupProps {
function ReleaseVersionRadioGroup({
onVersionChange = noop,
}: ReleaseVersionRadioGroupProps) {
const { latestCommit } = useLatestCommit();
const { pretagResponse } = usePretag();

return (
<ReleaseVersionRadioGroupView
currentVersion={latestCommit?.releaseTagName ?? null}
currentVersion={pretagResponse?.releaseTagName ?? null}
onVersionChange={onVersionChange}
releasedAt={latestCommit?.releasedAt ?? null}
releasedAt={pretagResponse?.releasedAt ?? null}
/>
);
}
Expand Down
29 changes: 0 additions & 29 deletions app/client/src/git/hooks/useLatestCommit.ts

This file was deleted.

27 changes: 27 additions & 0 deletions app/client/src/git/hooks/usePretag.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}
13 changes: 0 additions & 13 deletions app/client/src/git/requests/fetchLatestCommitRequest.types.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<FetchLatestCommitResponse> {
): AxiosPromise<PretagResponse> {
return Api.get(
`${GIT_BASE_URL}/${artifactType}/${branchedArtifactId}/commit/latest`,
);
Expand Down
17 changes: 17 additions & 0 deletions app/client/src/git/requests/pretagRequest.types.ts
Original file line number Diff line number Diff line change
@@ -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<PretagResponseData>;
38 changes: 0 additions & 38 deletions app/client/src/git/store/actions/fetchLatestCommitActions.ts

This file was deleted.

38 changes: 38 additions & 0 deletions app/client/src/git/store/actions/pretagActions.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Comment thread
brayn003 marked this conversation as resolved.
Outdated

export const pretagInitAction =
createArtifactAction<FetchLatestCommitInitPayload>((state) => {
state.apiResponses.pretag.loading = true;
state.apiResponses.pretag.error = null;

return state;
});
Comment thread
brayn003 marked this conversation as resolved.
Outdated

export const pretagSuccessAction = createArtifactAction<
GitAsyncSuccessPayload<PretagResponseData>
>((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;
},
);
14 changes: 7 additions & 7 deletions app/client/src/git/store/gitArtifactSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions app/client/src/git/store/helpers/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ const gitArtifactInitialAPIResponses: GitArtifactAPIResponsesReduxState = {
loading: false,
error: null,
},
latestCommit: {
value: null,
loading: false,
error: null,
},
pull: {
loading: false,
error: null,
Expand Down Expand Up @@ -134,6 +129,11 @@ const gitArtifactInitialAPIResponses: GitArtifactAPIResponsesReduxState = {
loading: false,
error: null,
},
pretag: {
value: null,
loading: false,
error: null,
},
// EE
...gitArtifactAPIResponsesInitialStateExtended,
};
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/git/store/selectors/gitArtifactSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/git/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,7 +42,6 @@ export interface GitArtifactAPIResponsesReduxState
connect: GitAsyncStateWithoutValue;
status: GitAsyncState<FetchStatusResponseData>;
commit: GitAsyncStateWithoutValue;
latestCommit: GitAsyncState<FetchLatestCommitResponseData>;
pull: GitAsyncStateWithoutValue;
discard: GitAsyncStateWithoutValue;
mergeStatus: GitAsyncState<FetchMergeStatusResponseData>;
Expand All @@ -61,6 +60,7 @@ export interface GitArtifactAPIResponsesReduxState
triggerAutocommit: GitAsyncStateWithoutValue;
sshKey: GitAsyncState<FetchSSHKeyResponseData>;
generateSSHKey: GitAsyncStateWithoutValue;
pretag: GitAsyncState<PretagResponseData>;
}

export interface GitArtifactUIReduxState
Expand Down