Skip to content

Commit

Permalink
Merge pull request #222 from Sunbird-ALL/all-1.3-tn-dev-hotfix
Browse files Browse the repository at this point in the history
All 1.3 tn dev hotfix
  • Loading branch information
gouravmore authored Nov 27, 2024
2 parents 0f3154d + c550f97 commit 3a92e59
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 51 deletions.
1 change: 1 addition & 0 deletions .github/workflows/all-app-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }}
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/all-dev-rig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }}
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/all-dev-tn-new.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ALL tn new dev Deployment
name: ALL new tn dev Deployment

on:
push:
Expand Down Expand Up @@ -74,6 +74,7 @@ jobs:
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }}
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/all-dev-tn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ jobs:
REACT_APP_LANGUAGES: ${{ vars.REACT_APP_LANGUAGES }}
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }}
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }}
REACT_APP_SHOW_HELP_VIDEO:${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_SHOW_HELP_VIDEO_LINK:${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/all-prod-rig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }}
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/all-prod-tn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
REACT_APP_IS_IN_APP_AUTHORISATION: ${{ vars.REACT_APP_IS_IN_APP_AUTHORISATION }}
REACT_APP_LANGUAGES: ${{ vars.REACT_APP_LANGUAGES }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/all-staging-tn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
REACT_APP_AWS_ACCESS_KEY_ID: ${{ secrets.REACT_APP_AWS_ACCESS_KEY_ID }}
REACT_APP_AWS_SECRET_ACCESS_KEY: ${{ secrets.REACT_APP_AWS_SECRET_ACCESS_KEY }}
REACT_APP_SHOW_HELP_VIDEO: ${{ vars.REACT_APP_SHOW_HELP_VIDEO }}
REACT_APP_PARENT_ORIGIN_URL: ${{ vars.REACT_APP_PARENT_ORIGIN_URL }}
REACT_APP_SHOW_HELP_VIDEO_LINK: ${{ vars.REACT_APP_SHOW_HELP_VIDEO_LINK }}
CI: false # Disabling CI to not treat warnings as errors
run: npm run build
Expand Down
78 changes: 30 additions & 48 deletions src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,38 @@ const Assesment = ({ discoverStart }) => {

const { virtualId } = useSelector((state) => state.user);

const [isVideoOpen, setIsVideoOpen] = useState(false);

const handleOpenVideo = () => {
setIsVideoOpen(true);
};
if (process.env.REACT_APP_SHOW_HELP_VIDEO === "true") {
let allowedOrigins = [];
try {
allowedOrigins = JSON.parse(
process.env.REACT_APP_PARENT_ORIGIN_URL || "[]"
);
} catch (error) {
console.error(
"Invalid JSON format in REACT_APP_PARENT_ORIGIN_URL:",
error
);
}

const parentOrigin =
window?.location?.ancestorOrigins?.[0] || window.parent.location.origin;

const handleCloseVideo = () => {
setIsVideoOpen(false);
if (allowedOrigins.includes(parentOrigin)) {
try {
window.parent.postMessage(
{
message: "help-video-link",
},
parentOrigin
);
} catch (error) {
console.error("Error sending postMessage:", error);
}
} else {
console.warn(`Parent origin "${parentOrigin}" is not allowed.`);
}
}
};

const navigate = useNavigate();
Expand Down Expand Up @@ -855,48 +879,6 @@ const Assesment = ({ discoverStart }) => {
</Box>
</MainLayout>
)}
{/* Video Modal */}
<Dialog
open={isVideoOpen}
onClose={handleCloseVideo}
maxWidth="lg"
fullWidth
>
<Box
sx={{
position: "relative",
width: "100%",
paddingTop: "56.25%", // Maintain 16:9 aspect ratio
backgroundColor: "black", // Optional: Ensure a dark background
}}
>
<iframe
src={process.env.REACT_APP_SHOW_HELP_VIDEO_LINK}
title="YouTube video"
frameBorder="0"
allow="autoplay; encrypted-media"
allowFullScreen
style={{
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%",
}}
/>
</Box>
<IconButton
onClick={handleCloseVideo}
sx={{
position: "absolute",
top: 8,
right: 8,
zIndex: 1,
}}
>
<CloseIcon />
</IconButton>
</Dialog>
</>
);
};
Expand Down

0 comments on commit 3a92e59

Please sign in to comment.