Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 9683be9

Browse files
authored
refactor: Cleaned up drag and drop (#298)
1 parent e11d7be commit 9683be9

114 files changed

Lines changed: 341 additions & 230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/App.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import algoliasearch from 'algoliasearch';
22
import { createStore, StoreProvider } from 'easy-peasy';
33
import { useRef } from 'react';
4-
import Toast from './components/atoms/Toast';
5-
import ToolTip from './components/atoms/Tooltip';
6-
import ConfirmationModal from './components/containers/ConfirmationModal';
7-
import KBarList from './components/containers/KBarList';
8-
import EditorPane from './components/panes/EditorPane';
9-
import NavigationPane from './components/panes/NavigationPane';
10-
import WorkflowsPane from './components/panes/WorkflowsPane';
4+
import Toast from './core/components/atoms/Toast';
5+
import ToolTip from './core/components/atoms/Tooltip';
6+
import ConfirmationModal from './core/components/containers/ConfirmationModal';
7+
import KBarList from './core/components/containers/KBarList';
8+
import EditorPane from './core/components/panes/EditorPane';
9+
import NavigationPane from './core/components/panes/NavigationPane';
10+
import WorkflowsPane from './core/components/panes/WorkflowsPane';
1111
import './index.css';
12-
import useWindowDimensions, { useStoreState } from './state/Hooks';
13-
import Store from './state/Store';
12+
import useWindowDimensions, { useStoreState } from './core/state/Hooks';
13+
import Store from './core/state/Store';
1414
export const store = createStore(Store);
1515
export const inspectorWidth = 400;
1616

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const AddButton = (props: ButtonHTMLAttributes<HTMLButtonElement>) => {
77
type="button"
88
{...props}
99
className={
10-
`bg-circle-gray-300 transition-colors h-8 w-8 rounded ${props.className}
10+
`bg-circle-gray-300 transition-colors h-8 w-8 rounded ${props.className}
1111
${props.disabled ? 'opacity-50 cursor-default' : 'hover:bg-circle-gray-400 '}`
1212
}
1313
>

src/components/atoms/ComponentInfo.tsx renamed to src/core/components/atoms/ComponentInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import InspectableMapping, {
22
GenerableInfoType,
3-
} from '../../mappings/InspectableMapping';
3+
} from '../../../mappings/InspectableMapping';
44

55
const ComponentInfo = ({
66
type,
File renamed without changes.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
OrbImport,
66
OrbRef,
77
} from '@circleci/circleci-config-sdk/dist/src/lib/Orb';
8-
import InspectableMapping from '../../mappings/InspectableMapping';
8+
import InspectableMapping from '../../../mappings/InspectableMapping';
99
import { useStoreActions } from '../../state/Hooks';
1010
import { InspectorDefinitionMenuNav } from '../menus/definitions/InspectorDefinitionMenu';
1111

@@ -35,7 +35,7 @@ export const flattenGenerable = (data: Generable, nested?: boolean) => {
3535
)[0];
3636
};
3737

38-
const Definition = (props: {
38+
const Definition = ({ data, ...props}: {
3939
data: Generable | OrbRef<AnyParameterLiteral>;
4040
type: InspectableMapping;
4141
index: number;
@@ -47,27 +47,27 @@ const Definition = (props: {
4747

4848
return (
4949
<button
50-
className="w-full mb-2 p-4 py-2 cursor-pointer text-left text-circle-black
50+
className="w-full mb-2 p-4 py-2 cursor-pointer text-left text-circle-black
5151
bg-white border border-circle-gray-300 rounded-md2 hover:border-gray-700 text-base"
5252
draggable="true"
5353
onDragStart={(e) => {
54-
const type = props.type;
54+
const dataMapping = props.type;
5555

56-
if (type?.dragTarget) {
57-
setDragging({ dataType: type, data: props.data });
56+
if (dataMapping?.dragTarget) {
57+
setDragging({ dataMapping, data });
5858
}
5959
}}
6060
onClick={(e) => {
61-
if (props.data instanceof CircleCI.orb.OrbRef) {
61+
if (data instanceof CircleCI.orb.OrbRef) {
6262
return;
6363
}
6464

65-
const flattened = flattenGenerable(props.data);
65+
const flattened = flattenGenerable(data);
6666

6767
navigateTo({
6868
component: InspectorDefinitionMenuNav,
6969
props: {
70-
data: props.data,
70+
data,
7171
editing: true,
7272
values: flattened,
7373
dataType: props.type,
@@ -76,7 +76,7 @@ const Definition = (props: {
7676
});
7777
}}
7878
>
79-
<Summary data={props.data} />
79+
<Summary data={data} />
8080
</button>
8181
);
8282
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PropsWithChildren } from 'react';
2-
import { inspectorWidth } from '../../App';
2+
import { inspectorWidth } from '../../../App';
33

44
export const Footer = ({
55
children,

0 commit comments

Comments
 (0)