Skip to content

Commit

Permalink
Bug fixes (#1359)
Browse files Browse the repository at this point in the history
* default score to zero in Chapter progress

* skip authorization for endpoint to get public link and partner section

* skip authorization for endpoint to get public link and partner section

* ensure long title text in Illustration Card dont break backgroundImage

* resolve rabbit suggestion

* fix broken link svg

* upate snapshot

* update padding in IllustrationCard
  • Loading branch information
george-misan authored Dec 16, 2024
1 parent 3c94d8f commit ce5d07d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ const AsideWithImageBlock: React.FC<
line-height: 100%;
font-weight: 400;
`}
>
{props.data.attributes.content}
</p>
dangerouslySetInnerHTML={{
__html: parseText(props.data.attributes.content, terms).parsedText,
}}
/>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const NextPage: React.FC<React.PropsWithChildren<NextPageProps>> = ({
</div>
<div className="answers">
<span className="metric">
{chapterProgress.givenScore}/{chapterProgress.maxScore}
{chapterProgress.givenScore ?? 0}/{chapterProgress.maxScore ?? 0}
</span>
<span className="description">{t("points-label")}</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions services/course-material/src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ const Layout: React.FC<React.PropsWithChildren<LayoutProps>> = ({ children }) =>
const [changeLanguageToThisCourseId, setChangeLanguageToThisCourseId] = useState<string | null>(
null,
)

const getPrivacyLink = useQuery({
queryKey: ["privacy-link", courseId],
queryFn: () => fetchPrivacyLink(courseId as NonNullable<string>),
enabled: !!courseId,
})

const customPrivacyLinks =
Expand Down Expand Up @@ -199,7 +199,7 @@ const Layout: React.FC<React.PropsWithChildren<LayoutProps>> = ({ children }) =>
`}
>
<DynamicToaster />
<PartnersSectionBlock courseId={courseId} />
{courseId && <PartnersSectionBlock courseId={courseId} />}
<Footer privacyLinks={customPrivacyLinks} />
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const PartnersSectionBlock: React.FC<PartnersBlockProps> = ({ courseId }) => {
const getPartnersBlock = useQuery({
queryKey: ["partners-block", courseId],
queryFn: () => fetchPartnersBlock(courseId as NonNullable<string>),
enabled: !!courseId,
})

const content =
Expand Down Expand Up @@ -77,10 +78,10 @@ const PartnersSectionBlock: React.FC<PartnersBlockProps> = ({ courseId }) => {
)}
</a>
) : isSvgUrl ? (
<DynamicSvg src={url} />
<DynamicSvg src={url} key={`partner-svg-${block.clientId}-${url}`} />
) : (
<figure>
<img src={url} alt={alt} />
<img src={url} alt={alt} key={`partner-img-${block.clientId}-${url}`} />
</figure>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async fn get_partners_block(
) -> ControllerResult<web::Json<PartnersBlock>> {
let course_id = path.into_inner();
let mut conn = pool.acquire().await?;
let token = authorize(&mut conn, Act::Teach, Some(user.id), Res::Course(course_id)).await?;
let token = skip_authorize();

// Check if the course exists in the partners_blocks table
let course_exists = models::partner_block::check_if_course_exists(&mut conn, course_id).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,14 +976,12 @@ GET /courses/:course_id/partners_blocks - Gets a partners block related to a cou
#[instrument(skip(pool))]
async fn get_partners_block(
path: web::Path<Uuid>,
user: AuthUser,
pool: web::Data<PgPool>,
) -> ControllerResult<web::Json<PartnersBlock>> {
let course_id = path.into_inner();
let mut conn = pool.acquire().await?;
let token = skip_authorize();
let partner_block = models::partner_block::get_partner_block(&mut conn, course_id).await?;

let token = skip_authorize();
token.authorized_ok(web::Json(partner_block))
}

Expand All @@ -993,15 +991,11 @@ GET /courses/:course_id/privacy_link - Gets a privacy link related to a course
#[instrument(skip(pool))]
async fn get_privacy_link(
course_id: web::Path<Uuid>,
user: AuthUser,
pool: web::Data<PgPool>,
) -> ControllerResult<web::Json<Vec<PrivacyLink>>> {
let mut conn = pool.acquire().await?;
let user_id = Some(user.id);
let token = authorize_access_to_course_material(&mut conn, user_id, *course_id).await?;

let privacy_link = models::privacy_link::get_privacy_link(&mut conn, *course_id).await?;

let token = skip_authorize();
token.authorized_ok(web::Json(privacy_link))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ const CardContentWrapper = styled.div`
margin-top: 5px;
font-size: clamp(26px, 2.2vw, 30px);
opacity: 0.9;
overflow: hidden;
text-overflow: ellipsis;
/* For multi-line truncation: */
display: -webkit-box;
-webkit-line-clamp: 3; /* Limit to 3 lines */
-webkit-box-orient: vertical;
}
`

Expand Down Expand Up @@ -74,14 +81,14 @@ const IllustrationCard: React.FC<React.PropsWithChildren<React.PropsWithChildren
<div
className={css`
width: 100%;
height: 370.6px;
height: 23.163rem;
transition: transform 0.2s;
${backgroundImage &&
`background-image: url(${backgroundImage});
background-repeat: no-repeat;
background-color: ${bg};
background-position: center center;
background-size: contain;
background-size: cover;
`}
&:hover {
Expand All @@ -97,7 +104,7 @@ const IllustrationCard: React.FC<React.PropsWithChildren<React.PropsWithChildren
background: #fff;
${respondToOrLarger.md} {
padding: 2rem 2rem;
padding: 1.6rem 1.25rem;
}
`}
>
Expand Down
1 change: 0 additions & 1 deletion shared-module/packages/common/src/styles/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const globalCss = css`
white-space: nowrap;
}
.${linkWithExtraIconClass} {
display: inline-flex;
align-items: center;
margin-right: 0.1rem;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce5d07d

Please sign in to comment.