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 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 52x 52x 52x 52x 52x 52x 52x | /*
* 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 from 'react'
import { Layout, Text } from '@wings-software/uicore'
import { TimeAgo } from '@common/exports'
import { useStrings } from 'framework/strings'
export enum FeatureFlagStatus {
ACTIVE = 'active',
INACTIVE = 'inactive',
NEVER_REQUESTED = 'never-requested'
}
export interface FlagStatusProps {
status?: FeatureFlagStatus
lastAccess?: number
}
export const FlagStatus: React.FC<FlagStatusProps> = ({ status, lastAccess }) => {
const { getString } = useStrings()
const isNeverRequested = status === FeatureFlagStatus.NEVER_REQUESTED
const textStyle = {
fontWeight: 600,
fontSize: '10px',
lineHeight: '16px',
textAlign: 'center',
borderRadius: '5px',
padding: '2px 6px',
...{ color: '#8EB0F4', background: '#EDF8FF' },
...(status === FeatureFlagStatus.INACTIVE ? { background: '#F3F3FA', color: '#9293AB' } : undefined),
...(isNeverRequested
? {
color: 'rgba(146, 170, 202, 0.8)',
background: 'transparent',
border: '1px solid rgba(189, 210, 219, 0.6)',
padding: '0 4px'
}
: undefined)
} as React.CSSProperties
const subTextStyle = { color: '#8F90A6', fontSize: '12px' }
const ComponentLayout = isNeverRequested ? Layout.Vertical : Layout.Horizontal
Iif (!status || !lastAccess) {
return null
}
return (
<ComponentLayout spacing="xsmall" style={{ alignItems: isNeverRequested ? 'baseline' : 'center' }}>
<Text inline style={textStyle}>
{(status || '').toLocaleUpperCase()}
</Text>
{(!isNeverRequested && <TimeAgo time={lastAccess} icon={undefined} style={subTextStyle} />) || (
<Text style={subTextStyle}>{getString('cf.featureFlags.makeSure')}</Text>
)}
</ComponentLayout>
)
}
|