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

Commits show up in UI after authentication success #1042

Merged
merged 2 commits into from
Nov 5, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions ui/components/CommitsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Link from "./Link";
type Props = {
className?: string;
app: Application;
authSuccess: boolean;
onAuthClick?: () => void;
};

Expand All @@ -31,23 +32,22 @@ const timestamp = (isoStr: string) => {
return DateTime.fromISO(isoStr).toRelative();
};

function CommitsTable({ className, app, onAuthClick }: Props) {
function CommitsTable({ className, app, authSuccess, onAuthClick }: Props) {
const { applicationsClient } = useContext(AppContext);
const [commits, loading, error, req] = useRequestState<ListCommitsResponse>();

React.useEffect(() => {
if (!app || !app.name) {
return;
}

req(
applicationsClient.ListCommits({
name: app.name,
namespace: app.namespace,
pageSize: 10,
})
);
}, [app]);
}, [app, authSuccess]);

if (error) {
return error.code === GrpcErrorCodes.Unauthenticated ? (
Expand Down
8 changes: 6 additions & 2 deletions ui/components/__tests__/CommitsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ describe("CommitsTable", () => {
let c;
await act(async () => {
const { container: div } = render(
withTheme(withContext(<CommitsTable app={app} />, "/", ovr)),
withTheme(
withContext(<CommitsTable app={app} authSuccess={true} />, "/", ovr)
),
container
);
c = div;
Expand All @@ -60,7 +62,9 @@ describe("CommitsTable", () => {

await act(async () => {
render(
withTheme(withContext(<CommitsTable app={app} />, "/", ovr)),
withTheme(
withContext(<CommitsTable app={app} authSuccess={true} />, "/", ovr)
),
container
);
});
Expand Down
1 change: 1 addition & 0 deletions ui/pages/ApplicationDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function ApplicationDetail({ className, name }: Props) {
<CommitsTable
// Get CommitsTable to retry after auth
app={application}
authSuccess={authSuccess}
onAuthClick={() => setGithubAuthModalOpen(true)}
/>
<Modal
Expand Down