Skip to content
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
1 change: 1 addition & 0 deletions frontend/web/components/base/IconButton/IconButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Icons on a filled variant use --slate-0: ink on a coloured surface stays
// white in both themes, and we have no token for that yet.
.ds-icon-button {
flex-shrink: 0;
justify-content: center;
border-radius: var(--radius-md);
transition: background-color var(--duration-fast) var(--easing-standard),
Expand Down
32 changes: 32 additions & 0 deletions frontend/web/components/feature-summary/FeatureModalTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { FC } from 'react'
import IconButton from 'components/base/IconButton'
import Icon from 'components/icons/Icon'
import Utils from 'common/utils/utils'

type FeatureModalTitleProps = {
name: string
label: string
}

const FeatureModalTitle: FC<FeatureModalTitleProps> = ({ label, name }) => (
<>
<span className='text-truncate'>
{/* Phones show just the name so the copy button stays beside it */}
<span className='d-none d-md-inline'>{label}: </span>
{name}
</span>
<IconButton
variant='ghost'
size='small'
aria-label='Copy feature name'
onClick={() => {
Utils.copyToClipboard(name)
}}
className='ms-2'
>
<Icon width={16} name='copy' />
</IconButton>
</>
)

export default FeatureModalTitle
23 changes: 7 additions & 16 deletions frontend/web/components/feature-summary/FeatureRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useGetHealthEventsQuery } from 'common/services/useHealthEvents'
import { useGetProjectQuery } from 'common/services/useProject'
import getUserDisplayName from 'common/utils/getUserDisplayName'
import FeatureName from './FeatureName'
import FeatureModalTitle from './FeatureModalTitle'
import FeatureDescription from './FeatureDescription'
import FeatureTags from './FeatureTags'
import { useFeatureRowState } from 'components/pages/features/hooks/useFeatureRowState'
Expand Down Expand Up @@ -235,7 +236,7 @@ const FeatureRow: FC<FeatureRowProps> = (props) => {
: []

openModal(
<Row className='align-items-center'>
<Row noWrap className='align-items-center'>
Comment thread
talissoncosta marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
{!!cameFrom && (
<IconButton
size='medium'
Expand All @@ -247,22 +248,12 @@ const FeatureRow: FC<FeatureRowProps> = (props) => {
<Icon name='arrow-left' width={20} />
</IconButton>
)}
<span>
{permission ? 'Edit Feature' : 'Feature'}: {projectFlag.name}
</span>
<IconButton
variant='ghost'
size='small'
aria-label='Copy feature name'
onClick={() => {
Utils.copyToClipboard(projectFlag.name)
}}
className='ms-2'
>
<Icon width={16} name='copy' />
</IconButton>
<FeatureModalTitle
name={projectFlag.name}
label={permission ? 'Edit Feature' : 'Feature'}
/>
{ownerChips.length > 0 && (
<div className='d-flex align-items-center gap-1 ms-3'>
<div className='d-none d-md-flex align-items-center gap-1 ms-3'>
<Icon name='people' width={16} fill='#9DA4AE' />
{ownerChips.slice(0, 3).map((chip) => (
<span key={chip.id} className='chip chip--xs'>
Expand Down
10 changes: 1 addition & 9 deletions frontend/web/components/metrics/EnvironmentMetricsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const EnvironmentMetricsList: FC<EnvironmentMetricsListProps> = ({
},
)

const MAX_COLUMNS = 6
const columns = Math.min(data?.metrics?.length || 0, MAX_COLUMNS) || 1

const extraMetricsData = getExtraMetricsData(projectId, environmentId)

useEffect(() => {
Expand All @@ -48,12 +45,7 @@ const EnvironmentMetricsList: FC<EnvironmentMetricsListProps> = ({
}
>
<div className='flex gap-2'>
<div
className='metrics-grid'
style={{
gridTemplateColumns: `repeat(${columns}, 1fr)`,
}}
>
<div className='metrics-grid'>
{data?.metrics.map((metric) => (
<EnvironmentMetric
key={metric.name}
Expand Down
33 changes: 16 additions & 17 deletions frontend/web/components/modals/CreateSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,34 +522,33 @@
: 'Add at least one AND/NOT rule to create a segment.'}
</InfoMessage>
)}
<Row className='justify-content-end'>
{!isReadOnly && (
<div
{!isReadOnly && (
<div className='d-flex flex-column flex-sm-row justify-content-sm-end gap-2'>
<Button
theme='outline'
data-test='add-rule'

Check warning on line 529 in frontend/web/components/modals/CreateSegment.tsx

View workflow job for this annotation

GitHub Actions / Lint changed files

Give the element a role or accessible name instead of data-test
type='button'
onClick={() =>
addRule(topLevelRuleType === 'ANY' ? 'ALL' : 'ANY')
}
className='text-center'
>
<Button theme='outline' data-test='add-rule' type='button'>
{topLevelRuleType === 'ANY'
? 'Add OR Condition'
: 'Add AND Condition'}
</Button>
</div>
)}
{!isReadOnly && topLevelRuleType !== 'ANY' && (
<div onClick={() => addRule('NONE')} className='text-center'>
{topLevelRuleType === 'ANY'
? 'Add OR Condition'
: 'Add AND Condition'}
</Button>
{topLevelRuleType !== 'ANY' && (
<Button
theme='outline'
className='ml-2 btn--outline-danger'
className='btn--outline-danger'
data-test='add-rule'
type='button'
onClick={() => addRule('NONE')}
>
Add AND NOT Condition
</Button>
</div>
)}
</Row>
)}
</div>
)}
</div>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions frontend/web/components/modals/base/ModalDefault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const setInterceptClose = (promise: (() => Promise<any>) | null) => {
interceptClose = promise
}

let cb
export const setModalTitle = (title: string) => {
let cb: ((title: ReactNode) => void) | undefined
export const setModalTitle = (title: ReactNode) => {
cb?.(title)
}
const ModalDefault: FC<ModalDefault> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import FeatureListStore from 'common/stores/feature-list-store'
import ES6Component from 'common/ES6Component'
import { setModalTitle } from 'components/modals/base/ModalDefault'
import FeatureModalTitle from 'components/feature-summary/FeatureModalTitle'

// TODO: Migrate to a custom hook once we move away from Flux stores.
// This class component is necessary because it uses ES6Component/listenTo
Expand Down Expand Up @@ -49,7 +50,14 @@ export default function withFeatureProvider(
`${document.location.pathname}?feature=${projectFlag.id}`,
)
const newEnvironmentFlag = envFlags?.[projectFlag.id] || {}
setModalTitle(`Edit Feature ${projectFlag.name}`)
setModalTitle(
<Row noWrap className='align-items-center'>
<FeatureModalTitle
name={projectFlag.name}
label='Edit Feature'
/>
</Row>,
)
this.setState({
environmentFlag: {
...this.state.environmentFlag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ const RuleConditionRow: React.FC<RuleConditionRowProps> = ({
<Flex className='or-divider__line' />
</Row>
)}
<div className='d-flex flex-row align-items-center gap-1 flex-nowrap'>
<div className='d-flex flex-1 flex-row rule align-items-center justify-content-between gap-1 col-8 col-md-10'>
<div className='col-10 col-sm-4 col-md-4'>
<div className='d-flex flex-row align-items-center gap-1 flex-wrap flex-sm-nowrap'>
<div className='d-flex flex-grow-1 flex-column flex-sm-row rule align-items-stretch align-items-sm-center justify-content-between gap-1 col-12 col-sm-8 col-md-10 mx-0'>
<div className='col-12 col-sm-4 col-md-4'>
<RuleConditionPropertySelect
dataTest={`${dataTest}-property-${ruleIndex}`}
ruleIndex={ruleIndex}
Expand All @@ -107,7 +107,7 @@ const RuleConditionRow: React.FC<RuleConditionRowProps> = ({
setRuleProperty(ruleIndex, 'operator', value)
}}
options={operators}
className='col-10 col-sm-3 col-md-3'
className='col-12 col-sm-3 col-md-3'
/>
)}
<RuleConditionValueInput
Expand All @@ -128,12 +128,12 @@ const RuleConditionRow: React.FC<RuleConditionRowProps> = ({
})
}}
isValid={Utils.validateRule(rule) && !ruleErrors?.value}
className='col-10 col-sm-4 col-md-4'
className='col-12 col-sm-4 col-md-4'
/>
</div>
<div
className={classNames(
'd-flex flex-sm-column flex-md-row',
'd-flex flex-sm-column flex-md-row ms-auto ms-sm-0',
Comment thread
talissoncosta marked this conversation as resolved.
Resolved
isLastRule && !readOnly ? 'gap-2' : '',
)}
>
Expand Down
10 changes: 9 additions & 1 deletion frontend/web/styles/components/_metrics.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@
display: grid;
justify-content: center;
row-gap: 12px;
}
grid-template-columns: repeat(2, 1fr);

// Wider screens: every metric on one row
@include media-breakpoint-up(md) {
grid-auto-columns: 1fr;
grid-auto-flow: column;
Comment thread
talissoncosta marked this conversation as resolved.
Resolved
grid-template-columns: none;
}
}
28 changes: 23 additions & 5 deletions frontend/web/styles/project/_modals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ $side-width: 800px;

.tabs {
.tab-item {
padding-top: 24px;
padding-bottom: 24px;
overflow-y: auto;
height: calc(100vh - 110px);
Expand Down Expand Up @@ -344,12 +343,31 @@ $side-width: 800px;
}
}

// Lets a long drawer title truncate instead of pushing its buttons out
.side-modal .modal-title {
min-width: 0;
}

.side-modal.create-feature-modal {
.modal-body {
padding-top: 0;
}
.tabs .tab-item {
padding-top: 24px;
}
}

@include media-breakpoint-down(md) {
.modal-dialog {
margin:0;
// Drawers fill the screen; dialogs stay cards
.side-modal .modal-dialog {
margin: 0;
// Bootstrap caps .modal-dialog width from 544px; drawers stay full width
max-width: none;
.modal-content {
border-radius:0;
height: 100vh;
border-radius: 0;
min-height: 100vh;
// Fits the visible screen when the mobile browser toolbar shows
min-height: 100dvh;
}
}
}
Expand Down
Loading