Skip to content

Commit

Permalink
Rename diff segments to segment overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg committed Nov 20, 2024
1 parent 9ae5a5c commit 1076ed5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions frontend/web/components/diff/DiffFeature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from './diff-utils'
import DiffString from './DiffString'
import DiffEnabled from './DiffEnabled'
import DiffSegments from './DiffSegments'
import DiffSegmentOverrides from './DiffSegmentOverrides'
import DiffVariations from './DiffVariations'
import InfoMessage from 'components/InfoMessage'
import Icon from 'components/Icon'
Expand Down Expand Up @@ -216,7 +216,7 @@ const DiffFeature: FC<FeatureDiffType> = ({
/>
</div>
)}
<DiffSegments
<DiffSegmentOverrides
diffs={segmentDiffs.diffs}
projectId={projectId}
environmentId={environmentId}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { TDiffSegment } from './diff-utils'
import { TDiffSegmentOverride } from './diff-utils'
import React, { FC, useMemo } from 'react'
import DiffString from './DiffString'
import DiffEnabled from './DiffEnabled'
import { sortBy } from 'lodash'
import Tabs from 'components/base/forms/Tabs'
import TabItem from 'components/base/forms/TabItem'
import Utils from 'common/utils/utils'
import Icon from 'components/Icon'
import Tooltip from 'components/Tooltip'
import { Link } from 'react-router-dom'
import DiffVariations from './DiffVariations'

type DiffSegment = {
diff: TDiffSegment
type DiffSegmentOverride = {
diff: TDiffSegmentOverride
projectId: string
environmentId: string
}

const widths = [200, 80, 105]
const DiffSegment: FC<DiffSegment> = ({ diff, environmentId, projectId }) => {
const DiffSegmentOverride: FC<DiffSegmentOverride> = ({
diff,
environmentId,
projectId,
}) => {
return (
<div>
<div className={'flex-row list-item list-item-sm'}>
Expand Down Expand Up @@ -75,21 +78,21 @@ const DiffSegment: FC<DiffSegment> = ({ diff, environmentId, projectId }) => {
)
}

type DiffSegmentsType = {
diffs: TDiffSegment[] | undefined
type DiffSegmentOverridesType = {
diffs: TDiffSegmentOverride[] | undefined
projectId: string
environmentId: string
}
const DiffSegments: FC<DiffSegmentsType> = ({
const DiffSegmentOverrides: FC<DiffSegmentOverridesType> = ({
diffs,
environmentId,
projectId,
}) => {
const { created, deleted, modified, unChanged } = useMemo(() => {
const created: TDiffSegment[] = []
const deleted: TDiffSegment[] = []
const modified: TDiffSegment[] = []
const unChanged: TDiffSegment[] = []
const created: TDiffSegmentOverride[] = []
const deleted: TDiffSegmentOverride[] = []
const modified: TDiffSegmentOverride[] = []
const unChanged: TDiffSegmentOverride[] = []

sortBy(diffs || [], (diff) => diff.newPriority)?.forEach((diff) => {
if (diff.created) {
Expand Down Expand Up @@ -133,7 +136,7 @@ const DiffSegments: FC<DiffSegmentsType> = ({
>
{tableHeader}
{created.map((diff, i) => (
<DiffSegment
<DiffSegmentOverride
environmentId={environmentId}
projectId={projectId}
key={i}
Expand All @@ -153,7 +156,7 @@ const DiffSegments: FC<DiffSegmentsType> = ({
>
{tableHeader}
{deleted.map((diff, i) => (
<DiffSegment
<DiffSegmentOverride
environmentId={environmentId}
projectId={projectId}
key={i}
Expand All @@ -173,7 +176,7 @@ const DiffSegments: FC<DiffSegmentsType> = ({
>
{tableHeader}
{modified.map((diff, i) => (
<DiffSegment
<DiffSegmentOverride
environmentId={environmentId}
projectId={projectId}
key={i}
Expand All @@ -193,7 +196,7 @@ const DiffSegments: FC<DiffSegmentsType> = ({
>
{tableHeader}
{unChanged.map((diff, i) => (
<DiffSegment
<DiffSegmentOverride
environmentId={environmentId}
projectId={projectId}
key={i}
Expand All @@ -210,4 +213,4 @@ const DiffSegments: FC<DiffSegmentsType> = ({
)
}

export default DiffSegments
export default DiffSegmentOverrides
5 changes: 2 additions & 3 deletions frontend/web/components/diff/diff-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
FeatureConflict,
FeatureState,
FeatureStateWithConflict,
ProjectFlag,
Segment,
} from 'common/types/responses'
import Utils from 'common/utils/utils'
Expand Down Expand Up @@ -34,7 +33,7 @@ export function getFeatureStateDiff(
return diff
}

export type TDiffSegment = {
export type TDiffSegmentOverride = {
segment: Segment
newEnabled: boolean
newPriority: number
Expand Down Expand Up @@ -150,7 +149,7 @@ export const getSegmentDiff = (
segment,
totalChanges: segmentChanges,
variationDiff,
} as TDiffSegment
} as TDiffSegmentOverride
})
return {
diffs,
Expand Down

0 comments on commit 1076ed5

Please sign in to comment.