Skip to content

Commit 4c0ed00

Browse files
Clean up unused commands (#6570)
## Problems - `AdjustNumberProperty` and `UpdatePropIfExists` command aren't used - `deleteValuesAtPath` and `applyValuesAtPath` are defined in command runners, but are actually widely used helpers ## Fix - Delete `AdjustNumberProperty` and `UpdatePropIfExists` - Move `deleteValuesAtPath` and `applyValuesAtPath` into a dedicated utils file **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Play mode --------- Co-authored-by: Balazs Bajorics <2226774+balazsbajorics@users.noreply.github.com>
1 parent fd3e0ad commit 4c0ed00

18 files changed

+100
-522
lines changed

editor/src/components/canvas/canvas-strategies/strategies/convert-to-absolute-and-move-strategy.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import { getFullFrame } from '../../../frame'
4444
import { stylePropPathMappingFn } from '../../../inspector/common/property-path-hooks'
4545
import type { CanvasFrameAndTarget } from '../../canvas-types'
4646
import type { CanvasCommand } from '../../commands/commands'
47-
import { convertToAbsolute } from '../../commands/convert-to-absolute-command'
4847
import type { SetCssLengthProperty } from '../../commands/set-css-length-command'
4948
import {
5049
setCssLengthProperty,

editor/src/components/canvas/canvas-strategies/strategies/set-padding-strategy.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ import { elementHasOnlyTextChildren } from '../../canvas-utils'
7272
import type { Modifiers } from '../../../../utils/modifiers'
7373
import type { Axis } from '../../../inspector/inspector-common'
7474
import { detectFillHugFixedState, isHuggingFixedHugFill } from '../../../inspector/inspector-common'
75-
import {
76-
AdjustCssLengthProperties,
77-
adjustCssLengthProperties,
78-
} from '../../commands/adjust-css-length-command'
7975
import type { ElementPathTrees } from '../../../../core/shared/element-path-tree'
8076
import { activeFrameTargetPath, setActiveFrames } from '../../commands/set-active-frames-command'
8177

editor/src/components/canvas/canvas-strategies/strategies/shared-absolute-resize-strategy-helpers.ts

-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ import {
4040
EdgePositionBottom,
4141
} from '../../canvas-types'
4242
import { pickPointOnRect, snapPoint } from '../../canvas-utils'
43-
import type { AdjustCssLengthProperties } from '../../commands/adjust-css-length-command'
44-
import {
45-
adjustCssLengthProperties,
46-
lengthPropertyToAdjust,
47-
} from '../../commands/adjust-css-length-command'
4843
import { pointGuidelineToBoundsEdge } from '../../controls/guideline-helpers'
4944
import type { AbsolutePin } from './resize-helpers'
5045
import { ensureAtLeastTwoPinsForEdgePosition, resizeBoundingBox } from './resize-helpers'

editor/src/components/canvas/commands/add-contain-layout-if-needed-command.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { MetadataUtils } from '../../../core/model/element-metadata-utils'
22
import * as EP from '../../../core/shared/element-path'
33
import { emptyComments, jsExpressionValue } from '../../../core/shared/element-template'
44
import type { ElementPath } from '../../../core/shared/project-file-types'
5-
import { PropertyPath } from '../../../core/shared/project-file-types'
65
import * as PP from '../../../core/shared/property-path'
76
import type { EditorState } from '../../editor/store/editor-state'
8-
import { applyValuesAtPath } from './adjust-number-command'
97
import type { BaseCommand, CommandFunction, WhenToRun } from './commands'
8+
import { applyValuesAtPath } from './utils/property-utils'
109

1110
export interface AddContainLayoutIfNeeded extends BaseCommand {
1211
type: 'ADD_CONTAIN_LAYOUT_IF_NEEDED'

editor/src/components/canvas/commands/adjust-css-length-command.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { modifyUnderlyingForOpenFile } from '../../editor/store/editor-state'
2222
import type { CSSNumber, FlexDirection } from '../../inspector/common/css-utils'
2323
import { parseCSSPercent, parseCSSPx, printCSSNumber } from '../../inspector/common/css-utils'
2424
import type { BaseCommand, CommandFunction, WhenToRun } from './commands'
25-
import { deleteValuesAtPath } from './delete-properties-command'
2625
import { patchParseSuccessAtElementPath } from './patch-utils'
26+
import { deleteValuesAtPath } from './utils/property-utils'
2727

2828
export type CreateIfNotExistant = 'create-if-not-existing' | 'do-not-create-if-doesnt-exist'
2929

@@ -416,7 +416,7 @@ function getConflictingPropertiesToDelete(
416416
return propertiesToDelete
417417
}
418418

419-
export function deleteConflictingPropsForWidthHeightFromAttributes(
419+
function deleteConflictingPropsForWidthHeightFromAttributes(
420420
attributes: JSXAttributes,
421421
propertyPath: PropertyPath,
422422
parentFlexDirection: FlexDirection | null,

editor/src/components/canvas/commands/adjust-number-command.spec.tsx

-143
This file was deleted.

0 commit comments

Comments
 (0)