Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 2x 2x 2x 2x 2x | /*
* Copyright 2021 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/
import React, { useState } from 'react'
import { Container } from '@wings-software/uicore'
import { ItemBriefInfo } from '@cf/components/ItemBriefInfo/ItemBriefInfo'
import type { Segment } from 'services/cf'
import { ItemContainer } from '../ItemContainer/ItemContainer'
export interface SegmentRowProps {
segment: Segment
checked: boolean
onChecked: (checked: boolean, segment: Segment) => void
}
export const SegmentRow: React.FC<SegmentRowProps> = ({ segment, checked, onChecked }) => {
// const { getString } = useStrings()
// const tags: string[] = ((segment as unknown) as { tags: string[] })?.tags || []
// const segmentHasFlags = !!segment?.included?.length
const [isChecked, setIsChecked] = useState(checked)
const toggleCheck = () => {
setIsChecked(previous => {
onChecked(!previous, segment)
return !previous
})
}
return (
<ItemContainer
clickable
style={{
flexGrow: 1,
border: '1px solid rgba(40, 41, 61, 0.04)',
marginRight: '1px',
display: 'flex',
alignItems: 'center',
cursor: 'pointer'
}}
onClick={toggleCheck}
>
<Container flex style={{ alignItems: 'center', width: '25px', justifyContent: 'center' }}>
<input type="checkbox" checked={isChecked} style={{ cursor: 'pointer' }} />
</Container>
<ItemBriefInfo
name={segment.name}
description={(segment as unknown as { desciption: string }).desciption} // cast util API supports it
style={{ boxShadow: 'none', flexGrow: 1, paddingLeft: 'var(--spacing-xsmall)' }}
padding="none"
/>
{/* Disable since backend does not support this info yet
<Container width={70}>
<Text
inline
icon="main-tags"
tooltip={
tags.length ? (
<Layout.Vertical padding="medium" spacing="medium" style={{ maxWidth: 400 }}>
<Text>{getString('tagsLabel').toUpperCase()}</Text>
<TagsViewer tags={tags} />
</Layout.Vertical>
) : undefined
}
>
{tags.length}
</Text>
</Container>
<Text width={175} color={segmentHasFlags ? Color.BLUE_500 : undefined}>
{getString('cf.selectSegmentModal.flagsUsingSegment', { counter: segment?.included?.length })}
</Text> */}
</ItemContainer>
)
}
|