Skip to content

Commit 57f89d1

Browse files
committed
feat(NodePropertiesPanel): make start nodes read-only and add notice
Add logic to prevent editing of start nodes by disabling input fields and buttons. Show a visual notice to inform users that start nodes are read-only.
1 parent 02b2c24 commit 57f89d1

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

src/lib/src/components/editors/NodePropertiesPanel.js

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ export function NodePropertiesPanel({
3333
return null;
3434
}
3535

36+
// Check if the node is editable (start nodes should not be editable)
37+
const isNodeEditable = node.type !== 'start';
38+
3639
const handleFieldChange = (field, value) => {
37-
if (onFieldChange) {
40+
if (onFieldChange && isNodeEditable) {
3841
onFieldChange(field, value);
3942

4043
// When name changes, also update label to keep them in sync
@@ -159,6 +162,25 @@ export function NodePropertiesPanel({
159162
</div>
160163
</div>
161164

165+
{/* Read-only notice for start nodes */}
166+
{!isNodeEditable && (
167+
<div style={{
168+
marginBottom: '16px',
169+
padding: '12px',
170+
backgroundColor: '#fef3c7',
171+
border: '1px solid #f59e0b',
172+
borderRadius: '6px',
173+
fontSize: '12px',
174+
color: '#92400e',
175+
display: 'flex',
176+
alignItems: 'center',
177+
gap: '8px'
178+
}}>
179+
<span style={{ fontSize: '14px' }}>ℹ️</span>
180+
<span>Start nodes are read-only and cannot be edited.</span>
181+
</div>
182+
)}
183+
162184
{/* Node ID */}
163185
<div style={{ marginBottom: '16px' }}>
164186
<label style={{
@@ -198,7 +220,8 @@ export function NodePropertiesPanel({
198220
type="text"
199221
value={formData.name || ''}
200222
onChange={(e) => handleFieldChange('name', e.target.value)}
201-
placeholder="Enter node name"
223+
placeholder={isNodeEditable ? "Enter node name" : "Start node name cannot be edited"}
224+
disabled={!isNodeEditable}
202225
style={{
203226
width: '100%',
204227
padding: '8px 12px',
@@ -207,14 +230,21 @@ export function NodePropertiesPanel({
207230
fontSize: '14px',
208231
outline: 'none',
209232
transition: 'border-color 0.2s',
233+
backgroundColor: !isNodeEditable ? '#f9fafb' : 'white',
234+
color: !isNodeEditable ? '#6b7280' : '#374151',
235+
cursor: !isNodeEditable ? 'not-allowed' : 'text',
210236
}}
211237
onFocus={(e) => {
212-
e.target.style.borderColor = '#3b82f6';
213-
e.target.style.boxShadow = '0 0 0 3px rgba(59, 130, 246, 0.1)';
238+
if (isNodeEditable) {
239+
e.target.style.borderColor = '#3b82f6';
240+
e.target.style.boxShadow = '0 0 0 3px rgba(59, 130, 246, 0.1)';
241+
}
214242
}}
215243
onBlur={(e) => {
216-
e.target.style.borderColor = '#d1d5db';
217-
e.target.style.boxShadow = 'none';
244+
if (isNodeEditable) {
245+
e.target.style.borderColor = '#d1d5db';
246+
e.target.style.boxShadow = 'none';
247+
}
218248
}}
219249
/>
220250
</div>
@@ -873,57 +903,59 @@ export function NodePropertiesPanel({
873903
>
874904
<button
875905
onClick={handleReset}
876-
disabled={!isDirty}
906+
disabled={!isDirty || !isNodeEditable}
877907
style={{
878908
padding: '8px 12px',
879909
border: '1px solid #d1d5db',
880910
backgroundColor: 'white',
881-
color: isDirty ? '#374151' : '#9ca3af',
911+
color: (isDirty && isNodeEditable) ? '#374151' : '#9ca3af',
882912
borderRadius: '6px',
883913
fontSize: '12px',
884914
fontWeight: '500',
885-
cursor: isDirty ? 'pointer' : 'not-allowed',
915+
cursor: (isDirty && isNodeEditable) ? 'pointer' : 'not-allowed',
886916
display: 'flex',
887917
alignItems: 'center',
888918
gap: '4px',
889919
transition: 'all 0.2s',
890920
}}
891921
onMouseEnter={(e) => {
892-
if (isDirty) {
922+
if (isDirty && isNodeEditable) {
893923
e.target.style.backgroundColor = '#f3f4f6';
894924
}
895925
}}
896926
onMouseLeave={(e) => {
897-
e.target.style.backgroundColor = 'white';
927+
if (isNodeEditable) {
928+
e.target.style.backgroundColor = 'white';
929+
}
898930
}}
899931
>
900932
<RotateCcw size={12} />
901933
Reset
902934
</button>
903935
<button
904936
onClick={handleSave}
905-
disabled={!isDirty}
937+
disabled={!isDirty || !isNodeEditable}
906938
style={{
907939
padding: '8px 12px',
908940
border: '1px solid #3b82f6',
909-
backgroundColor: isDirty ? '#3b82f6' : '#e5e7eb',
910-
color: isDirty ? 'white' : '#9ca3af',
941+
backgroundColor: (isDirty && isNodeEditable) ? '#3b82f6' : '#e5e7eb',
942+
color: (isDirty && isNodeEditable) ? 'white' : '#9ca3af',
911943
borderRadius: '6px',
912944
fontSize: '12px',
913945
fontWeight: '500',
914-
cursor: isDirty ? 'pointer' : 'not-allowed',
946+
cursor: (isDirty && isNodeEditable) ? 'pointer' : 'not-allowed',
915947
display: 'flex',
916948
alignItems: 'center',
917949
gap: '4px',
918950
transition: 'all 0.2s',
919951
}}
920952
onMouseEnter={(e) => {
921-
if (isDirty) {
953+
if (isDirty && isNodeEditable) {
922954
e.target.style.backgroundColor = '#2563eb';
923955
}
924956
}}
925957
onMouseLeave={(e) => {
926-
if (isDirty) {
958+
if (isDirty && isNodeEditable) {
927959
e.target.style.backgroundColor = '#3b82f6';
928960
}
929961
}}

0 commit comments

Comments
 (0)