Skip to content

Commit

Permalink
fix: add sticky note readonly state
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgrozav committed Sep 5, 2024
1 parent d74f2a6 commit ea6090f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ const id = toRef(props, 'id');
const data = toRef(props, 'data');
const label = toRef(props, 'label');
const selected = toRef(props, 'selected');
const readOnly = toRef(props, 'readOnly');
provide(CanvasNodeKey, {
id,
data,
label,
selected,
readOnly,
eventBus: canvasNodeEventBus,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const isDisableNodeVisible = computed(() => {
const isDeleteNodeVisible = computed(() => !props.readOnly);
const isStickyNoteNodeType = computed(() => render.value.type === CanvasNodeRenderType.StickyNote);
const isStickyNoteChangeColorVisible = computed(
() => !props.readOnly && render.value.type === CanvasNodeRenderType.StickyNote,
);
function executeNode() {
emit('run');
Expand Down Expand Up @@ -106,7 +108,10 @@ function onOpenContextMenu(event: MouseEvent) {
:title="i18n.baseText('node.delete')"
@click="onDeleteNode"
/>
<CanvasNodeStickyColorSelector v-if="isStickyNoteNodeType" @update="onChangeStickyColor" />
<CanvasNodeStickyColorSelector
v-if="isStickyNoteChangeColorVisible"
@update="onChangeStickyColor"
/>
<N8nIconButton
data-test-id="overflow-node-button"
type="tertiary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const emit = defineEmits<{
const $style = useCssModule();
const { id, isSelected, render, eventBus } = useCanvasNode();
const { id, isSelected, isReadOnly, render, eventBus } = useCanvasNode();
const renderOptions = computed(() => render.value.options as CanvasNodeStickyNoteRender['options']);
Expand Down Expand Up @@ -95,6 +95,7 @@ onBeforeUnmount(() => {
:min-width="150"
:height="renderOptions.height"
:width="renderOptions.width"
:is-visible="!isReadOnly"
@resize="onResize"
/>
<N8nSticky
Expand Down
3 changes: 2 additions & 1 deletion packages/editor-ui/src/composables/useCanvasNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function useCanvasNode() {
const connections = computed(() => data.value.connections);

const isDisabled = computed(() => data.value.disabled);

const isReadOnly = computed(() => node?.readOnly.value);
const isSelected = computed(() => node?.selected.value);

const pinnedDataCount = computed(() => data.value.pinnedData.count);
Expand Down Expand Up @@ -75,6 +75,7 @@ export function useCanvasNode() {
outputs,
connections,
isDisabled,
isReadOnly,
isSelected,
pinnedDataCount,
hasPinnedData,
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/types/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export interface CanvasNodeInjectionData {
data: Ref<CanvasNodeData>;
label: Ref<NodeProps['label']>;
selected: Ref<NodeProps['selected']>;
readOnly: Ref<boolean>;
eventBus: Ref<EventBus<CanvasNodeEventBusEvents>>;
}

Expand Down

0 comments on commit ea6090f

Please sign in to comment.