Skip to content

Commit

Permalink
Merge pull request #27 from input-output-hk/fix/pvt-repo-access
Browse files Browse the repository at this point in the history
Fix to private-repo-access not working
  • Loading branch information
amnambiar authored Sep 29, 2023
2 parents 214f168 + f0a1bb0 commit 7deb855
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/components/RepoAccessStatus/repoAccessStatus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ export const ACCESS_STATUS: { [index: string]: any } = {
verifying: {
className: "image anim-rotate",
"data-testid": "verifying",
src: "images/running.svg",
src: "/images/running.svg",
alt: "verifying",
color: "#DBAB0A",
},
accessible: {
className: "image",
"data-testid": "accessible",
src: "images/passed.svg",
src: "/images/passed.svg",
alt: "accessible",
color: "#009168",
},
notAccessible: {
className: "image",
"data-testid": "notAccessible",
src: "images/failed.svg",
src: "/images/failed.svg",
alt: "not accessible",
color: "#FF493D",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { auditorRunTestFormSchema } from "./auditorRunTestForm.schema";
import { IAuditorRunTestFormFields } from "./auditorRunTestForm.interface";
import {
clearAccessStatus,
clearAccessToken,
getUserAccessToken,
verifyRepoAccess,
} from "store/slices/repositoryAccess.slice";
Expand Down Expand Up @@ -76,7 +77,7 @@ const AuditorRunTestForm: React.FC<IAuditorRunTestForm> = ({

const { repoUrl } = useAppSelector((state) => state.certification);
const { profile } = useAppSelector((state) => state.auth);
const { showConfirmConnection, accessStatus } = useAppSelector((state) => state.repoAccess);
const { showConfirmConnection, accessStatus, accessToken } = useAppSelector((state) => state.repoAccess);
const confirm = useConfirm();
const [submitting, setSubmitting] = useState(false);
const [showError, setShowError] = useState("");
Expand All @@ -93,6 +94,7 @@ const AuditorRunTestForm: React.FC<IAuditorRunTestForm> = ({
// fetch CLIENT_ID from api
const clientId = (await fetchData.get("/github/client-id").catch(error => { throw new Error(error) }))
.data as string;
localStorage.setItem('testingForm', JSON.stringify(form.getValues()))
clientId && window.location.assign(
`https://github.com/login/oauth/authorize?client_id=${clientId}&scope=repo`
);
Expand Down Expand Up @@ -148,6 +150,7 @@ const AuditorRunTestForm: React.FC<IAuditorRunTestForm> = ({
return;
}


const [, , , username, repoName, , commitHash] =
formData.repoURL.split("/");
dispatch(setRepoUrl(`https://github.com/${username}/${repoName}`));
Expand All @@ -166,10 +169,12 @@ const AuditorRunTestForm: React.FC<IAuditorRunTestForm> = ({
repo: repoName,
name: name,
version: version,
subject: subject
subject: subject,
githubToken: accessToken || null,
},
}));
if (response.payload && response.payload?.dapp?.owner) {
dispatch(clearAccessToken())
const runResponse = await postData.post("/run", checkout);
if (runResponse.data) {
// store data into LS
Expand Down Expand Up @@ -217,6 +222,13 @@ const AuditorRunTestForm: React.FC<IAuditorRunTestForm> = ({
}
// the enclosed snippet is to be triggered only once right when the component is rendered to check if the url contains code (to validate if it is a redirect from github)

const formDataInLS = localStorage.getItem('testingForm')
if (formDataInLS && formDataInLS !== 'undefined') {
const profileFormData = JSON.parse(formDataInLS);
form.reset(profileFormData)
localStorage.removeItem('testingForm')
}

// Run on unmount
return () => {
dispatch(clearAccessStatus())
Expand Down

0 comments on commit 7deb855

Please sign in to comment.