Skip to content

Commit

Permalink
Merge pull request NIUANULP#340 from ManojNathIC/Bug-fixes
Browse files Browse the repository at this point in the history
Task #0000: Workspace visibility option logic and user domain wise content
  • Loading branch information
paritshivani authored Jul 6, 2024
2 parents b64a22c + cb2af89 commit 59060c7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 44 deletions.
12 changes: 12 additions & 0 deletions packages/nulp_elite/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ function App() {
const data = await response.json();
const rootOrgId = data.result.response.rootOrgId;
sessionStorage.setItem("rootOrgId", rootOrgId);
sessionStorage.setItem(
"userDomain",
data.result.response.framework.board
);
const rolesData = data.result.response.roles;
const roles = rolesData?.map((roleObject) => roleObject.role);

// Convert the roles array to a JSON string
const rolesJson = JSON.stringify(roles);

// Save the JSON string to sessionStorage
sessionStorage.setItem("roles", rolesJson);
console.log(data.result.response.framework.board);
localStorage.setItem(
"defaultFramework",
Expand Down
44 changes: 23 additions & 21 deletions packages/nulp_elite/src/components/domainCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export default function DomainCarousel({
const [activeDomain, setActiveDomain] = useState(null);
const [scrolled, setScrolled] = useState(false);
// const navigate = useNavigate();
const [userDomain, setUserDomain] = useState(null);

useEffect(() => {
const domain = sessionStorage.getItem("userDomain");
setUserDomain(domain);
}, []);

const handleResize = () => {
setIsMobile(window.innerWidth <= 767);
Expand Down Expand Up @@ -124,9 +130,9 @@ export default function DomainCarousel({
<Carousel
swipeable={true}
draggable={true}
showDots={["mobile"]} // Show dots only if there are more than 4 items
showDots={["mobile"]}
responsive={responsive}
ssr={true} // means to render carousel on server-side.
ssr={true}
infinite={true}
autoPlaySpeed={1000}
keyBoardControl={true}
Expand All @@ -140,7 +146,11 @@ export default function DomainCarousel({
itemsArray?.slice(0, 10).map((domain, index) => (
<Box
className={`my-class ${
activeStates === index ? "carousel-active-ui" : ""
activeStates === index
? "carousel-active-ui"
: userDomain === domain.code
? "carousel-active-ui"
: ""
}`}
onClick={(e) =>
handleDomainClick(domain.code, index, domain.name)
Expand Down Expand Up @@ -175,10 +185,7 @@ export default function DomainCarousel({
<Box sx={{ alignSelf: "center" }} className="cursor-pointer">
<Typography
level="title-md"
style={{
fontSize: "12px",
textAlign: "center",
}}
style={{ fontSize: "12px", textAlign: "center" }}
className="domainText"
>
{domain.name}
Expand All @@ -192,7 +199,7 @@ export default function DomainCarousel({
<>
<Box className="carousel-bx scrolled">
<Box className="text-white h5-title pl-20 pb-15">
Select your prefered domain :
Select your preferred domain:
</Box>

<Box
Expand All @@ -206,7 +213,11 @@ export default function DomainCarousel({
itemsArray?.slice(0, 10).map((domain, index) => (
<Box
className={`my-class ${
activeStates === index ? "carousel-active-ui" : ""
activeStates === index
? "carousel-active-ui"
: userDomain === domain.code
? "carousel-active-ui"
: ""
}`}
onClick={(e) =>
handleDomainClick(domain.code, index, domain.name)
Expand All @@ -219,24 +230,15 @@ export default function DomainCarousel({
onMouseEnter={(event) => handleMouseEnter(index)}
onMouseLeave={handleMouseLeave}
>
<Box className=" cursor-pointer">
<Box className=" cursor-pointer">
{/* {(domain.image != undefined) && <img src={require(baseImgUrl+domain.image)} style={{width:'40px',objectFit:'contain'}} alt={domain.name} />}
{(domain.image == undefined)&& <img src={require("../assets/swm.png")} style={{width:'40px',objectFit:'contain'}} alt={domain.name} />} */}
{/* <Tooltip title={domain.description}> */}
<Box className="cursor-pointer">
<Box className="cursor-pointer">
<img
className="domainHover"
src={require(`../assets/domainImgs${domain.image}`)}
alt={domain.name}
/>

{/* </Tooltip> */}

{/* <img src={require("../assets/swm.png")} style={{width:'40px',objectFit:'contain'}} alt={domain.name} /> */}
</Box>

{/* {(activeDomain === index || activeStates === index) && ( */}
<span className=" cursor-pointer domainText">
<span className="cursor-pointer domainText">
{domain.name}
</span>
{/* )} */}
Expand Down
58 changes: 37 additions & 21 deletions packages/nulp_elite/src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ function Header({ globalSearchQuery }) {
const navigate = useNavigate();
const _userId = util.userId();
const [userData, setUserData] = useState(null);

const [roles, setRoles] = useState([]);
// Retrieve roles from sessionStorage
const rolesJson = sessionStorage.getItem("roles");
useEffect(() => {
if (rolesJson) {
const parsedRoles = JSON.parse(rolesJson);
setRoles(parsedRoles);
}
}, []);
const handleOpenNavMenu = (event) => {
setAnchorElNav(event.currentTarget);
};
Expand Down Expand Up @@ -496,16 +504,20 @@ function Header({ globalSearchQuery }) {
{t("PROFILE")}
</Link>
</MenuItem>
<MenuItem>
<Link
target="_blank"
href="https://nulp.niua.org/workspace/content/create"
underline="none"
textAlign="center"
>
{t("WORKSPACE")}
</Link>
</MenuItem>
{/* Check if roles array is empty or contains "PUBLIC" */}
{(roles && roles.length === 0) ||
(roles.length === 1 && roles.includes("PUBLIC")) ? null : (
<MenuItem>
<Link
target="_blank"
href="/workspace/content/create"
underline="none"
textAlign="center"
>
{t("WORKSPACE")}
</Link>
</MenuItem>
)}
<MenuItem>
<Link
href={routeConfig.ROUTES.HELP_PAGE.HELP}
Expand Down Expand Up @@ -746,16 +758,20 @@ function Header({ globalSearchQuery }) {
{t("PROFILE")}
</Link>
</MenuItem>
<MenuItem>
<Link
target="_blank"
href="https://nulp.niua.org/workspace/content/create"
underline="none"
textAlign="center"
>
{t("WORKSPACE")}
</Link>
</MenuItem>
{/* Check if roles array is empty or contains "PUBLIC" */}
{(roles && roles.length === 0) ||
(roles.length === 1 && roles.includes("PUBLIC")) ? null : (
<MenuItem>
<Link
target="_blank"
href="/workspace/content/create"
underline="none"
textAlign="center"
>
{t("WORKSPACE")}
</Link>
</MenuItem>
)}
<MenuItem>
<Link
href={routeConfig.ROUTES.HELP_PAGE.HELP}
Expand Down
8 changes: 6 additions & 2 deletions packages/nulp_elite/src/pages/content/AllContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import SkeletonLoader from "components/skeletonLoader";
import NoResult from "./noResultFound";
const routeConfig = require("../../configs/routeConfig.json");


const responsiveCard = {
superLargeDesktop: {
breakpoint: { max: 4000, min: 3000 },
Expand Down Expand Up @@ -101,6 +100,11 @@ const AllContent = () => {
};

useEffect(() => {
const userDomain = sessionStorage.getItem("userDomain");
if (userDomain) {
setSelectedDomain(userDomain);
setDomainName(userDomain);
}
fetchData();
fetchDomains();
}, []);
Expand Down Expand Up @@ -435,7 +439,7 @@ const AllContent = () => {
);
})
) : (
<NoResult />
<NoResult />
)}
</Container>
<FloatingChatIcon />
Expand Down

0 comments on commit 59060c7

Please sign in to comment.