Skip to content

Commit

Permalink
Clean up unused commands (#6570)
Browse files Browse the repository at this point in the history
## 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>
  • Loading branch information
bkrmendy and balazsbajorics authored Oct 22, 2024
1 parent fd3e0ad commit 4c0ed00
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 522 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { getFullFrame } from '../../../frame'
import { stylePropPathMappingFn } from '../../../inspector/common/property-path-hooks'
import type { CanvasFrameAndTarget } from '../../canvas-types'
import type { CanvasCommand } from '../../commands/commands'
import { convertToAbsolute } from '../../commands/convert-to-absolute-command'
import type { SetCssLengthProperty } from '../../commands/set-css-length-command'
import {
setCssLengthProperty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ import { elementHasOnlyTextChildren } from '../../canvas-utils'
import type { Modifiers } from '../../../../utils/modifiers'
import type { Axis } from '../../../inspector/inspector-common'
import { detectFillHugFixedState, isHuggingFixedHugFill } from '../../../inspector/inspector-common'
import {
AdjustCssLengthProperties,
adjustCssLengthProperties,
} from '../../commands/adjust-css-length-command'
import type { ElementPathTrees } from '../../../../core/shared/element-path-tree'
import { activeFrameTargetPath, setActiveFrames } from '../../commands/set-active-frames-command'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ import {
EdgePositionBottom,
} from '../../canvas-types'
import { pickPointOnRect, snapPoint } from '../../canvas-utils'
import type { AdjustCssLengthProperties } from '../../commands/adjust-css-length-command'
import {
adjustCssLengthProperties,
lengthPropertyToAdjust,
} from '../../commands/adjust-css-length-command'
import { pointGuidelineToBoundsEdge } from '../../controls/guideline-helpers'
import type { AbsolutePin } from './resize-helpers'
import { ensureAtLeastTwoPinsForEdgePosition, resizeBoundingBox } from './resize-helpers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { MetadataUtils } from '../../../core/model/element-metadata-utils'
import * as EP from '../../../core/shared/element-path'
import { emptyComments, jsExpressionValue } from '../../../core/shared/element-template'
import type { ElementPath } from '../../../core/shared/project-file-types'
import { PropertyPath } from '../../../core/shared/project-file-types'
import * as PP from '../../../core/shared/property-path'
import type { EditorState } from '../../editor/store/editor-state'
import { applyValuesAtPath } from './adjust-number-command'
import type { BaseCommand, CommandFunction, WhenToRun } from './commands'
import { applyValuesAtPath } from './utils/property-utils'

export interface AddContainLayoutIfNeeded extends BaseCommand {
type: 'ADD_CONTAIN_LAYOUT_IF_NEEDED'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { modifyUnderlyingForOpenFile } from '../../editor/store/editor-state'
import type { CSSNumber, FlexDirection } from '../../inspector/common/css-utils'
import { parseCSSPercent, parseCSSPx, printCSSNumber } from '../../inspector/common/css-utils'
import type { BaseCommand, CommandFunction, WhenToRun } from './commands'
import { deleteValuesAtPath } from './delete-properties-command'
import { patchParseSuccessAtElementPath } from './patch-utils'
import { deleteValuesAtPath } from './utils/property-utils'

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

Expand Down Expand Up @@ -416,7 +416,7 @@ function getConflictingPropertiesToDelete(
return propertiesToDelete
}

export function deleteConflictingPropsForWidthHeightFromAttributes(
function deleteConflictingPropsForWidthHeightFromAttributes(
attributes: JSXAttributes,
propertyPath: PropertyPath,
parentFlexDirection: FlexDirection | null,
Expand Down
143 changes: 0 additions & 143 deletions editor/src/components/canvas/commands/adjust-number-command.spec.tsx

This file was deleted.

Loading

0 comments on commit 4c0ed00

Please sign in to comment.