Skip to content

Commit 2a3836d

Browse files
authored
Fetch breaking changes data from web api (#5202)
Signed-off-by: khanhtc1202 <[email protected]>
1 parent 8e62937 commit 2a3836d

File tree

7 files changed

+45
-0
lines changed

7 files changed

+45
-0
lines changed

web/src/api/piped.ts

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
ListReleasedVersionsRequest,
2323
RestartPipedRequest,
2424
RestartPipedResponse,
25+
ListDeprecatedNotesRequest,
26+
ListDeprecatedNotesResponse,
2527
} from "pipecd/web/api_client/service_pb";
2628

2729
export const getPipeds = ({
@@ -39,6 +41,16 @@ export const listReleasedVersions = (): Promise<
3941
return apiRequest(req, apiClient.listReleasedVersions);
4042
};
4143

44+
export const listBreakingChanges = ({
45+
projectId,
46+
}: ListDeprecatedNotesRequest.AsObject): Promise<
47+
ListDeprecatedNotesResponse.AsObject
48+
> => {
49+
const req = new ListDeprecatedNotesRequest();
50+
req.setProjectId(projectId);
51+
return apiRequest(req, apiClient.listDeprecatedNotes);
52+
};
53+
4254
export const registerPiped = ({
4355
name,
4456
desc,

web/src/components/application-detail-page/application-detail/index.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const baseState: Partial<AppState> = {
6969
registeredPiped: null,
7070
updating: false,
7171
releasedVersions: [],
72+
breakingChangesNote: "",
7273
},
7374
};
7475

web/src/components/applications-page/edit-application-drawer/index.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const initialState = {
3838
registeredPiped: null,
3939
updating: false,
4040
releasedVersions: [],
41+
breakingChangesNote: "",
4142
},
4243
applications: {
4344
loading: false,

web/src/components/deployments-detail-page/index.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe("DeploymentDetailPage", () => {
2828
registeredPiped: null,
2929
updating: false,
3030
releasedVersions: [],
31+
breakingChangesNote: "",
3132
},
3233
});
3334

web/src/components/settings-page/piped/index.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
restartPiped,
4343
fetchPipeds,
4444
fetchReleasedVersions,
45+
fetchBreakingChanges,
4546
Piped,
4647
RegisteredPiped,
4748
selectAllPipeds,
@@ -95,6 +96,7 @@ export const SettingsPipedPage: FC = memo(function SettingsPipedPage() {
9596
enabled: true,
9697
});
9798
const dispatch = useAppDispatch();
99+
const projectId = useAppSelector((state) => state.project.id);
98100
const pipeds = useAppSelector<Piped.AsObject[]>((state) =>
99101
selectFilteredPipeds(state, filterValues)
100102
);
@@ -103,10 +105,22 @@ export const SettingsPipedPage: FC = memo(function SettingsPipedPage() {
103105
dispatch(fetchReleasedVersions());
104106
}, [dispatch]);
105107

108+
useEffect(() => {
109+
if (projectId) {
110+
dispatch(fetchBreakingChanges({ projectId: projectId }));
111+
}
112+
}, [dispatch, projectId]);
113+
106114
const releasedVersions = useAppSelector<string[]>(
107115
(state) => state.pipeds.releasedVersions
108116
);
109117

118+
const breakingChangesNote = useAppSelector<string | null>(
119+
(state) => state.pipeds.breakingChangesNote
120+
);
121+
// TODO: Remove this console.log
122+
console.log("[DEBUG]", breakingChangesNote);
123+
110124
const [isUpgradeDialogOpen, setIsUpgradeDialogOpen] = useState(false);
111125
const handleUpgradeDialogClose = (): void => setIsUpgradeDialogOpen(false);
112126

web/src/modules/pipeds/index.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const baseState = {
1414
registeredPiped: null,
1515
updating: false,
1616
releasedVersions: [],
17+
breakingChangesNote: "",
1718
};
1819

1920
describe("pipedsSlice reducer", () => {

web/src/modules/pipeds/index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ export const fetchReleasedVersions = createAsyncThunk<string[]>(
3737
}
3838
);
3939

40+
export const fetchBreakingChanges = createAsyncThunk<
41+
string,
42+
{ projectId: string }
43+
>(`${MODULE_NAME}/fetchBreakingChanges`, async (props) => {
44+
const { notes } = await pipedsApi.listBreakingChanges({
45+
projectId: props.projectId,
46+
});
47+
return notes;
48+
});
49+
4050
export const fetchPipeds = createAsyncThunk<Piped.AsObject[], boolean>(
4151
`${MODULE_NAME}/fetchList`,
4252
async (withStatus: boolean) => {
@@ -120,10 +130,12 @@ export const pipedsSlice = createSlice({
120130
registeredPiped: RegisteredPiped | null;
121131
updating: boolean;
122132
releasedVersions: string[];
133+
breakingChangesNote: string;
123134
}>({
124135
registeredPiped: null,
125136
updating: false,
126137
releasedVersions: [],
138+
breakingChangesNote: "",
127139
}),
128140
reducers: {
129141
clearRegisteredPipedInfo(state) {
@@ -157,6 +169,9 @@ export const pipedsSlice = createSlice({
157169
})
158170
.addCase(fetchReleasedVersions.fulfilled, (state, action) => {
159171
state.releasedVersions = action.payload;
172+
})
173+
.addCase(fetchBreakingChanges.fulfilled, (state, action) => {
174+
state.breakingChangesNote = action.payload;
160175
});
161176
},
162177
});

0 commit comments

Comments
 (0)