Skip to content
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

Fetch breaking changes data from web api #5202

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 12 additions & 0 deletions web/src/api/piped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
ListReleasedVersionsRequest,
RestartPipedRequest,
RestartPipedResponse,
ListDeprecatedNotesRequest,
ListDeprecatedNotesResponse,
} from "pipecd/web/api_client/service_pb";

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

export const listBreakingChanges = ({
projectId,
}: ListDeprecatedNotesRequest.AsObject): Promise<
ListDeprecatedNotesResponse.AsObject
> => {
const req = new ListDeprecatedNotesRequest();
req.setProjectId(projectId);
return apiRequest(req, apiClient.listDeprecatedNotes);
};

export const registerPiped = ({
name,
desc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const baseState: Partial<AppState> = {
registeredPiped: null,
updating: false,
releasedVersions: [],
breakingChangesNote: "",
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const initialState = {
registeredPiped: null,
updating: false,
releasedVersions: [],
breakingChangesNote: "",
},
applications: {
loading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("DeploymentDetailPage", () => {
registeredPiped: null,
updating: false,
releasedVersions: [],
breakingChangesNote: "",
},
});

Expand Down
14 changes: 14 additions & 0 deletions web/src/components/settings-page/piped/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
restartPiped,
fetchPipeds,
fetchReleasedVersions,
fetchBreakingChanges,
Piped,
RegisteredPiped,
selectAllPipeds,
Expand Down Expand Up @@ -95,6 +96,7 @@ export const SettingsPipedPage: FC = memo(function SettingsPipedPage() {
enabled: true,
});
const dispatch = useAppDispatch();
const projectId = useAppSelector((state) => state.project.id);
const pipeds = useAppSelector<Piped.AsObject[]>((state) =>
selectFilteredPipeds(state, filterValues)
);
Expand All @@ -103,10 +105,22 @@ export const SettingsPipedPage: FC = memo(function SettingsPipedPage() {
dispatch(fetchReleasedVersions());
}, [dispatch]);

useEffect(() => {
if (projectId) {
dispatch(fetchBreakingChanges({ projectId: projectId }));
}
}, [dispatch, projectId]);

const releasedVersions = useAppSelector<string[]>(
(state) => state.pipeds.releasedVersions
);

const breakingChangesNote = useAppSelector<string | null>(
(state) => state.pipeds.breakingChangesNote
);
// TODO: Remove this console.log
console.log("[DEBUG]", breakingChangesNote);

const [isUpgradeDialogOpen, setIsUpgradeDialogOpen] = useState(false);
const handleUpgradeDialogClose = (): void => setIsUpgradeDialogOpen(false);

Expand Down
1 change: 1 addition & 0 deletions web/src/modules/pipeds/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const baseState = {
registeredPiped: null,
updating: false,
releasedVersions: [],
breakingChangesNote: "",
};

describe("pipedsSlice reducer", () => {
Expand Down
15 changes: 15 additions & 0 deletions web/src/modules/pipeds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export const fetchReleasedVersions = createAsyncThunk<string[]>(
}
);

export const fetchBreakingChanges = createAsyncThunk<
string,
{ projectId: string }
>(`${MODULE_NAME}/fetchBreakingChanges`, async (props) => {
const { notes } = await pipedsApi.listBreakingChanges({
projectId: props.projectId,
});
return notes;
});

export const fetchPipeds = createAsyncThunk<Piped.AsObject[], boolean>(
`${MODULE_NAME}/fetchList`,
async (withStatus: boolean) => {
Expand Down Expand Up @@ -120,10 +130,12 @@ export const pipedsSlice = createSlice({
registeredPiped: RegisteredPiped | null;
updating: boolean;
releasedVersions: string[];
breakingChangesNote: string;
}>({
registeredPiped: null,
updating: false,
releasedVersions: [],
breakingChangesNote: "",
}),
reducers: {
clearRegisteredPipedInfo(state) {
Expand Down Expand Up @@ -157,6 +169,9 @@ export const pipedsSlice = createSlice({
})
.addCase(fetchReleasedVersions.fulfilled, (state, action) => {
state.releasedVersions = action.payload;
})
.addCase(fetchBreakingChanges.fulfilled, (state, action) => {
state.breakingChangesNote = action.payload;
});
},
});
Expand Down
Loading