Skip to content

Commit

Permalink
[console] - fixed issues with importing schematics with empty keys (#…
Browse files Browse the repository at this point in the history
…1007)

* [console] - fixed issues with importing schematics with empty keys

* [console] - bumped version
  • Loading branch information
emilbon99 authored Dec 23, 2024
1 parent 8817eaa commit 698b76b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion console/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synnaxlabs/console",
"private": true,
"version": "0.36.1",
"version": "0.36.2",
"type": "module",
"scripts": {
"dev": "tauri dev",
Expand Down
4 changes: 2 additions & 2 deletions console/src/lineplot/LinePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
import { useMutation } from "@tanstack/react-query";
import { type ReactElement, useCallback, useEffect, useMemo, useState } from "react";
import { useDispatch } from "react-redux";
import { v4 as uuidv4 } from "uuid";
import { v4 as uuid } from "uuid";

import { Menu } from "@/components/menu";
import { useLoadRemote } from "@/hooks/useLoadRemote";
Expand Down Expand Up @@ -512,7 +512,7 @@ export const create =
(initial: Partial<State> & Omit<Partial<Layout.State>, "type">): Layout.Creator =>
({ dispatch }) => {
const { name = "Line Plot", location = "mosaic", window, tab, ...rest } = initial;
const key = initial.key ?? uuidv4();
const key: string = primitiveIsZero(initial.key) ? uuid() : (initial.key as string);
dispatch(internalCreate({ ...deep.copy(ZERO_STATE), ...rest, key }));
return { key, name, location, type: LAYOUT_TYPE, icon: "Visualize", window, tab };
};
Expand Down
4 changes: 2 additions & 2 deletions console/src/log/Log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Icon } from "@synnaxlabs/media";
import { Align, Log as Core, telem, Text, usePrevious } from "@synnaxlabs/pluto";
import { deep, primitiveIsZero, TimeSpan, type UnknownRecord } from "@synnaxlabs/x";
import { type ReactElement, useCallback, useEffect } from "react";
import { v4 as uuidv4 } from "uuid";
import { v4 as uuid } from "uuid";

import { useLoadRemote } from "@/hooks/useLoadRemote";
import { Layout } from "@/layout";
Expand Down Expand Up @@ -142,7 +142,7 @@ export const create =
(initial: Partial<State> & Omit<Partial<Layout.State>, "type">): Layout.Creator =>
({ dispatch }) => {
const { name = "Log", location = "mosaic", window, tab, ...rest } = initial;
const key = initial.key ?? uuidv4();
const key: string = primitiveIsZero(initial.key) ? uuid() : (initial.key as string);
dispatch(internalCreate({ ...deep.copy(ZERO_STATE), ...rest, key }));
return {
key,
Expand Down
4 changes: 2 additions & 2 deletions console/src/schematic/Schematic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
useSyncedRef,
Viewport,
} from "@synnaxlabs/pluto";
import { box, deep, id, xy } from "@synnaxlabs/x";
import { box, deep, id, primitiveIsZero, xy } from "@synnaxlabs/x";
import {
type ReactElement,
useCallback,
Expand Down Expand Up @@ -445,7 +445,7 @@ export const create =
const canEditSchematic = selectHasPermission(store.getState());
const { name = "Schematic", location = "mosaic", window, tab, ...rest } = initial;
const newTab = canEditSchematic ? tab : { ...tab, editable: false };
const key = initial.key ?? uuid();
const key: string = primitiveIsZero(initial.key) ? uuid() : (initial.key as string);
dispatch(internalCreate({ ...deep.copy(ZERO_STATE), ...rest, key }));
return {
key,
Expand Down
4 changes: 2 additions & 2 deletions console/src/schematic/services/palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import { Icon } from "@synnaxlabs/media";

import { type Command } from "@/palette/Palette";
import { importSchematic } from "@/schematic/file";
import { create } from "@/schematic/Schematic";
import { selectHasPermission } from "@/schematic/selectors";
import { importSchematic } from "@/schematic/file";
import { Workspace } from "@/workspace";
import { ImportIcon } from "@/schematic/services/Icon";
import { Workspace } from "@/workspace";

export const createCommand: Command = {
key: "create-schematic",
Expand Down
5 changes: 3 additions & 2 deletions console/src/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import {
clamp,
dimensions,
type location,
primitiveIsZero,
type UnknownRecord,
xy,
} from "@synnaxlabs/x";
import { memo, type ReactElement, useCallback, useEffect, useRef } from "react";
import { useDispatch } from "react-redux";
import { v4 as uuidv4 } from "uuid";
import { v4 as uuid } from "uuid";

import { Menu as CMenu } from "@/components/menu";
import { CSS } from "@/css";
Expand Down Expand Up @@ -361,8 +362,8 @@ interface CellContainerProps {
export const create =
(initial: Partial<State> & Omit<Partial<Layout.State>, "type">): Layout.Creator =>
({ dispatch }) => {
const key = initial.key ?? uuidv4();
const { name = "Table", location = "mosaic", window, tab, ...rest } = initial;
const key: string = primitiveIsZero(initial.key) ? uuid() : (initial.key as string);
dispatch(internalCreate({ ...ZERO_STATE, ...rest, key }));
return {
key,
Expand Down

0 comments on commit 698b76b

Please sign in to comment.