Skip to content

Commit

Permalink
Owner tab: COSV Submitter is always the current user, omit it (#2824)
Browse files Browse the repository at this point in the history
### What's done:
* Owner tab: COSV Submitter is always the current user, omit it
  • Loading branch information
kgevorkyan authored Oct 31, 2023
1 parent 569210f commit 968a787
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ val vulnerabilityCollectionView: FC<VulnerabilityCollectionViewProps> = FC { pro
val (vulnerabilityFilter, setVulnerabilityFilter) = useState(props.filter ?: VulnerabilityFilter.approved)
val (selectedMenu, setSelectedMenu) = useState(VulnerabilityListTab.PUBLIC)
val (publicTable, setPublicTable) = useState(true)
val (isOwnerTab, setIsOwnerTab) = useState(false)
val (countVulnerability, setCountVulnerability) = useState(0)

val enrollRequest = useDeferredRequest {
Expand All @@ -61,7 +62,7 @@ val vulnerabilityCollectionView: FC<VulnerabilityCollectionViewProps> = FC { pro
setCountVulnerability(count)
}

val vulnerabilityListTable: FC<FiltersProps> = useMemo(publicTable, i18n.language) {
val vulnerabilityListTable: FC<FiltersProps> = useMemo(isOwnerTab, publicTable, i18n.language) {
tableComponent(
columns = {
columns {
Expand Down Expand Up @@ -117,14 +118,17 @@ val vulnerabilityCollectionView: FC<VulnerabilityCollectionViewProps> = FC { pro
}
}
}
column(id = "user", header = "COSV Submitter".t(), { user.name }) { cellContext ->
Fragment.create {
td {
className = ClassName("align-middle")
cellContext.row.original.user.let { user ->
renderUserAvatarWithName(user) {
height = 2.rem
width = 2.rem
// don't show submitter on owner tab, it's always current user
if (!isOwnerTab) {
column(id = "user", header = "COSV Submitter".t(), { user.name }) { cellContext ->
Fragment.create {
td {
className = ClassName("align-middle")
cellContext.row.original.user.let { user ->
renderUserAvatarWithName(user) {
height = 2.rem
width = 2.rem
}
}
}
}
Expand Down Expand Up @@ -195,7 +199,7 @@ val vulnerabilityCollectionView: FC<VulnerabilityCollectionViewProps> = FC { pro
tab(selectedMenu.name, tabList, "nav nav-tabs mt-3") { value ->
setSelectedMenu { VulnerabilityListTab.valueOf(value) }
setVulnerabilityFilter {
getFiltersByTab(VulnerabilityListTab.valueOf(value), setPublicTable, props.currentUserInfo)
getFiltersByTab(VulnerabilityListTab.valueOf(value), setPublicTable, setIsOwnerTab, props.currentUserInfo)
}
}
}
Expand Down Expand Up @@ -236,6 +240,7 @@ val vulnerabilityCollectionView: FC<VulnerabilityCollectionViewProps> = FC { pro
getFiltersByTab(
selectedMenu,
setPublicTable,
setIsOwnerTab,
props.currentUserInfo
)
}
Expand Down Expand Up @@ -307,21 +312,25 @@ external interface FiltersProps : TableProps<VulnerabilityMetadataDto> {
private fun getFiltersByTab(
selectedMenu: VulnerabilityListTab,
setPublicTable: StateSetter<Boolean>,
setIsOwnerTab: StateSetter<Boolean>,
currentUserInfo: UserInfo?
) = when (selectedMenu) {
VulnerabilityListTab.PUBLIC -> {
setPublicTable(true)
setIsOwnerTab(false)
VulnerabilityFilter.approved
}
VulnerabilityListTab.ADMIN -> {
setPublicTable(false)
setIsOwnerTab(false)
VulnerabilityFilter(
identifierPrefix = "",
statuses = listOf(VulnerabilityStatus.PENDING_REVIEW),
)
}
VulnerabilityListTab.OWNER -> {
setPublicTable(false)
setIsOwnerTab(true)
VulnerabilityFilter(
identifierPrefix = "",
statuses = null,
Expand Down

0 comments on commit 968a787

Please sign in to comment.