-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/equinor/fusion-workspace
- Loading branch information
Showing
19 changed files
with
370 additions
and
256 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const defaultGardenPackageWidth = 300; | ||
|
||
export function useItemWidths(columnCount: number) { | ||
const [widths, setWidths] = useState<number[]>([]); | ||
|
||
/** | ||
* How to calculate longest width? | ||
*/ | ||
useEffect(() => { | ||
if (columnCount > 0) { | ||
setWidths(new Array(columnCount).fill(defaultGardenPackageWidth)); | ||
} | ||
}, [columnCount]); | ||
|
||
return widths; | ||
} | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const defaultGardenPackageWidth = 300; | ||
|
||
export function useItemWidths(columnCount: number) { | ||
const [widths, setWidths] = useState<number[]>([]); | ||
|
||
/** | ||
* How to calculate longest width? | ||
*/ | ||
useEffect(() => { | ||
if (columnCount > 0) { | ||
setWidths(new Array(columnCount).fill(defaultGardenPackageWidth)); | ||
} | ||
}, [columnCount]); | ||
|
||
return widths; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 35 additions & 32 deletions
67
packages/workspace-fusion/src/lib/components/ErrorComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
import { Dialog, Typography } from '@equinor/eds-core-react'; | ||
|
||
interface DumpsterFireDialogProps { | ||
title?: string; | ||
text: string; | ||
buttons: React.ReactElement[]; | ||
} | ||
|
||
export function DumpsterFireDialog({ | ||
text, | ||
title = 'Ooops, this is embarassing..', | ||
buttons, | ||
}: DumpsterFireDialogProps): JSX.Element { | ||
return ( | ||
<Dialog style={{ width: '600px' }} open={true}> | ||
<Dialog.Header> | ||
<Dialog.Title>{title}</Dialog.Title> | ||
</Dialog.Header> | ||
<Dialog.CustomContent> | ||
<Typography variant="body_short">{text}</Typography> | ||
</Dialog.CustomContent> | ||
<Dialog.Actions> | ||
<> | ||
{buttons.map((comp, i) => { | ||
const Component = () => comp; | ||
return <Component key={i} />; | ||
})} | ||
</> | ||
</Dialog.Actions> | ||
</Dialog> | ||
); | ||
} | ||
import { Button, Dialog, Typography } from '@equinor/eds-core-react'; | ||
import { useState } from 'react'; | ||
|
||
interface DumpsterFireDialogProps { | ||
title?: string; | ||
text: string; | ||
buttons?: React.ReactElement[]; | ||
} | ||
|
||
export function DumpsterFireDialog({ | ||
text, | ||
title = 'Ooops, this is embarassing..', | ||
buttons, | ||
}: DumpsterFireDialogProps): JSX.Element { | ||
const [isOpen, setIsOpen] = useState(true); | ||
return ( | ||
<Dialog style={{ width: '600px' }} open={isOpen} isDismissable={true}> | ||
<Dialog.Header> | ||
<Dialog.Title>{title}</Dialog.Title> | ||
</Dialog.Header> | ||
<Dialog.CustomContent> | ||
<Typography variant="body_short">{text}</Typography> | ||
</Dialog.CustomContent> | ||
<Dialog.Actions> | ||
<> | ||
{buttons?.map((comp, i) => { | ||
const Component = () => comp; | ||
return <Component key={i} />; | ||
})} | ||
</> | ||
<Button onClick={() => setIsOpen(false)}>OK</Button> | ||
</Dialog.Actions> | ||
</Dialog> | ||
); | ||
} |
20 changes: 18 additions & 2 deletions
20
packages/workspace-fusion/src/lib/components/error/WorkspaceError.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
import { Button } from '@equinor/eds-core-react'; | ||
import { FallbackProps } from 'react-error-boundary'; | ||
|
||
export const WorkspaceError = ({ error }: FallbackProps) => { | ||
return <div>Ops... {error.message}</div>; | ||
export const WorkspaceError = ({ error, resetErrorBoundary }: FallbackProps) => { | ||
return ( | ||
<div> | ||
<div> | ||
An unknown error has occurred in the workspace | ||
<div>{error.message}</div> | ||
<pre>{error?.stack}</pre> | ||
</div> | ||
<Button | ||
onClick={() => { | ||
resetErrorBoundary(); | ||
}} | ||
> | ||
Try again | ||
</Button> | ||
</div> | ||
); | ||
}; |
71 changes: 36 additions & 35 deletions
71
packages/workspace-fusion/src/lib/integrations/grid/grid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
/** | ||
* Integrations folder for exporting types from the integration | ||
* namespace: @equinor/workspace-fusion/grid | ||
*/ | ||
|
||
import { | ||
ColDef, | ||
ColumnState, | ||
GridOptions, | ||
ICellRendererProps, | ||
IServerSideGetRowsParams, | ||
IServerSideGetRowsRequest, | ||
Module, | ||
} from '@equinor/workspace-ag-grid'; | ||
|
||
export type { | ||
ColDef, | ||
ColumnState, | ||
GridConfig, | ||
GridOptions, | ||
ICellRendererProps, | ||
IServerSideGetRowsParams, | ||
IServerSideGetRowsRequest, | ||
}; | ||
|
||
type GridConfig<T, TFilter> = { | ||
columnDefinitions: ColDef<T>[]; | ||
getRows: (params: IServerSideGetRowsParams, filters: TFilter) => Promise<void>; | ||
gridOptions?: Omit<GridOptions<T>, 'rowData' | 'context' | 'pagination' | 'paginationPageSize'>; | ||
/** | ||
* AG-grid-modules | ||
* https://www.ag-grid.com/javascript-data-grid/modules/ | ||
*/ | ||
modules?: Module[]; | ||
}; | ||
/** | ||
* Integrations folder for exporting types from the integration | ||
* namespace: @equinor/workspace-fusion/grid | ||
*/ | ||
|
||
import { | ||
ColDef, | ||
ColumnState, | ||
GridOptions, | ||
ICellRendererProps, | ||
IServerSideGetRowsParams, | ||
IServerSideGetRowsRequest, | ||
Module, | ||
} from '@equinor/workspace-ag-grid'; | ||
|
||
export type { | ||
ColDef, | ||
ColumnState, | ||
GridConfig, | ||
GridOptions, | ||
ICellRendererProps, | ||
IServerSideGetRowsParams, | ||
IServerSideGetRowsRequest, | ||
}; | ||
|
||
type GridConfig<T, TFilter> = { | ||
columnDefinitions: ColDef<T>[]; | ||
getRows: (params: IServerSideGetRowsParams, filters: TFilter) => Promise<void>; | ||
gridOptions?: Omit<GridOptions<T>, 'rowData' | 'context' | 'pagination' | 'paginationPageSize'>; | ||
/** | ||
* AG-grid-modules | ||
* https://www.ag-grid.com/javascript-data-grid/modules/ | ||
*/ | ||
modules?: Module[]; | ||
excelExport?: (params: TFilter) => Promise<void>; | ||
}; |
10 changes: 5 additions & 5 deletions
10
packages/workspace-fusion/src/lib/integrations/grid/types/workspaceProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { GridConfig } from '../grid'; | ||
|
||
export type WorkspaceGridProps<TData extends Record<PropertyKey, unknown>, TFilter> = { | ||
gridOptions?: GridConfig<TData, TFilter>; | ||
}; | ||
import { GridConfig } from '../grid'; | ||
|
||
export type WorkspaceGridProps<TData extends Record<PropertyKey, unknown>, TFilter> = { | ||
gridOptions?: GridConfig<TData, TFilter>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.