Skip to content

Commit

Permalink
new button
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliodiez committed Jan 20, 2024
1 parent 13d1362 commit a77f204
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core/providers/canvas-schema/canvas-schema.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const createDefaultDatabaseSchemaVm = (): DatabaseSchemaVm => ({
export interface CanvasSchemaContextVm {
canvasSchema: DatabaseSchemaVm;
loadSchema: (schema: DatabaseSchemaVm) => void;
createEmptySchema: () => void;
updateTablePosition: (
id: string,
position: Coords,
Expand Down
5 changes: 5 additions & 0 deletions src/core/providers/canvas-schema/canvas-schema.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const CanvasSchemaProvider: React.FC<Props> = props => {
setSchema(newSchema);
};

const createEmptySchema = () => {
setSchema(createDefaultDatabaseSchemaVm());
};

const updateFullTable = (table: TableVm) => {
setSchema(prevSchema => updateTable(table, prevSchema));
};
Expand Down Expand Up @@ -88,6 +92,7 @@ export const CanvasSchemaProvider: React.FC<Props> = props => {
<CanvasSchemaContext.Provider
value={{
canvasSchema,
createEmptySchema,
loadSchema,
updateTablePosition,
doFieldToggleCollapse,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { NewIcon } from '@/common/components/icons/new-icon.component';
import { useCanvasSchemaContext } from '@/core/providers';
import { ToolbarButton } from '@/pods/toolbar/components/toolbar-button';
import classes from '@/pods/toolbar/toolbar.pod.module.css';

export const NewButton = () => {
const { createEmptySchema } = useCanvasSchemaContext();

const handleNewButtonClick = () => {
console.log('New button clicked');
createEmptySchema();
};

return (
Expand Down

0 comments on commit a77f204

Please sign in to comment.