Skip to content

Commit 8f62e13

Browse files
authored
Fixed organization render avatar in vulnerability filters (#2954)
1 parent e101105 commit 8f62e13

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

frontend-common/src/main/kotlin/com/saveourtool/frontend/common/components/basic/AvatarRenderers.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,26 @@ fun ChildrenBuilder.renderTopBarAvatar(
258258
}
259259
}
260260

261+
/**
262+
* Render organization avatar or placeholder
263+
*
264+
* @param organizationDto organization to render avatar
265+
* @param classes classes applied to [img] html tag
266+
* @param link link to redirect to if clicked
267+
* @param styleBuilder [CSSProperties] builder
268+
*/
269+
fun ChildrenBuilder.renderFilterAvatar(
270+
organizationDto: OrganizationDto,
271+
classes: String = "",
272+
link: String? = null,
273+
styleBuilder: CSSProperties.() -> Unit = {},
274+
) = renderFilterAvatar(
275+
organizationDto.avatar?.avatarRenderer() ?: AVATAR_ORGANIZATION_PLACEHOLDER,
276+
classes,
277+
link ?: "/${organizationDto.name}",
278+
styleBuilder
279+
)
280+
261281
private fun ChildrenBuilder.renderAvatar(
262282
avatarLink: String,
263283
classes: String,
@@ -283,3 +303,24 @@ private fun ChildrenBuilder.renderAvatar(
283303
}
284304
} ?: renderImg()
285305
}
306+
307+
private fun ChildrenBuilder.renderFilterAvatar(
308+
avatarLink: String,
309+
classes: String,
310+
link: String?,
311+
styleBuilder: CSSProperties.() -> Unit,
312+
) {
313+
val renderImg: ChildrenBuilder.() -> Unit = {
314+
img {
315+
className = ClassName("avatar avatar-user border color-bg-default rounded-circle $classes")
316+
src = avatarLink
317+
style = jso { styleBuilder() }
318+
}
319+
}
320+
link?.let {
321+
Link {
322+
to = it
323+
renderImg()
324+
}
325+
} ?: renderImg()
326+
}

frontend-common/src/main/kotlin/com/saveourtool/frontend/common/components/inputform/InputWithDebounce.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.saveourtool.common.entities.OrganizationDto
66
import com.saveourtool.common.info.UserInfo
77
import com.saveourtool.common.utils.DEFAULT_DEBOUNCE_PERIOD
88
import com.saveourtool.frontend.common.components.basic.renderAvatar
9+
import com.saveourtool.frontend.common.components.basic.renderFilterAvatar
910
import com.saveourtool.frontend.common.utils.*
1011

1112
import js.core.jso
@@ -142,7 +143,7 @@ fun renderOrganizationWithAvatar(childrenBuilder: ChildrenBuilder, organizationD
142143
style = jso {
143144
fontSize = 1.2.rem
144145
}
145-
renderAvatar(organizationDto) {
146+
renderFilterAvatar(organizationDto) {
146147
width = 2.rem
147148
height = 2.rem
148149
}

0 commit comments

Comments
 (0)