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

Fixed organization render avatar in vulnerability filters #2954

Merged
merged 1 commit into from
May 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,26 @@ fun ChildrenBuilder.renderTopBarAvatar(
}
}

/**
* Render organization avatar or placeholder
*
* @param organizationDto organization to render avatar
* @param classes classes applied to [img] html tag
* @param link link to redirect to if clicked
* @param styleBuilder [CSSProperties] builder
*/
fun ChildrenBuilder.renderFilterAvatar(
organizationDto: OrganizationDto,
classes: String = "",
link: String? = null,
styleBuilder: CSSProperties.() -> Unit = {},
) = renderFilterAvatar(
organizationDto.avatar?.avatarRenderer() ?: AVATAR_ORGANIZATION_PLACEHOLDER,
classes,
link ?: "/${organizationDto.name}",
styleBuilder
)

private fun ChildrenBuilder.renderAvatar(
avatarLink: String,
classes: String,
Expand All @@ -283,3 +303,24 @@ private fun ChildrenBuilder.renderAvatar(
}
} ?: renderImg()
}

private fun ChildrenBuilder.renderFilterAvatar(
avatarLink: String,
classes: String,
link: String?,
styleBuilder: CSSProperties.() -> Unit,
) {
val renderImg: ChildrenBuilder.() -> Unit = {
img {
className = ClassName("avatar avatar-user border color-bg-default rounded-circle $classes")
src = avatarLink
style = jso { styleBuilder() }
}
}
link?.let {
Link {
to = it
renderImg()
}
} ?: renderImg()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.saveourtool.common.entities.OrganizationDto
import com.saveourtool.common.info.UserInfo
import com.saveourtool.common.utils.DEFAULT_DEBOUNCE_PERIOD
import com.saveourtool.frontend.common.components.basic.renderAvatar
import com.saveourtool.frontend.common.components.basic.renderFilterAvatar
import com.saveourtool.frontend.common.utils.*

import js.core.jso
Expand Down Expand Up @@ -142,7 +143,7 @@ fun renderOrganizationWithAvatar(childrenBuilder: ChildrenBuilder, organizationD
style = jso {
fontSize = 1.2.rem
}
renderAvatar(organizationDto) {
renderFilterAvatar(organizationDto) {
width = 2.rem
height = 2.rem
}
Expand Down
Loading