Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnusGjosund committed Sep 25, 2023
2 parents f60f055 + 7c5ec5e commit 3dd67d2
Show file tree
Hide file tree
Showing 19 changed files with 370 additions and 256 deletions.
8 changes: 0 additions & 8 deletions .changeset/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/config.json

This file was deleted.

13 changes: 0 additions & 13 deletions .github/pull_request_template.md

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Fusion Workspace

<p style="text-align: left;"><img src="./documentation/fusion.png" width="350"></p>
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/equinor/fusion-workspace/ci.yml) ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/equinor/fusion-workspace/publish.yml?logo=npm&label=Deployment) ![GitHub issues by-label](https://img.shields.io/github/issues/equinor/fusion-workspace/bug?label=%F0%9F%90%9B%20bug%20issues&color=red)
![GitHub issues](https://img.shields.io/github/issues/equinor/fusion-workspace) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/equinor/fusion-workspace)

> Fusion Workspace is a library built with a controller-based structure in mind. Core functionality tab navigation, data handling, and allowing you to register controllers that react around page change / config change and data changes.
Expand Down
13 changes: 10 additions & 3 deletions apps/test-app/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import { Workspace } from '@equinor/workspace-fusion';
import { gridModule } from '@equinor/workspace-fusion/grid-module';
import { gardenModule } from '@equinor/workspace-fusion/garden-module';
import { gridModule } from '@equinor/workspace-fusion/grid-module';
import { GroupingOption } from '@equinor/workspace-garden';
import React from 'react';
import { createRoot } from 'react-dom/client';

export function App() {
return (
Expand All @@ -14,6 +14,13 @@ export function App() {
getRows: async ({ success, request }, filter) => {
success({ rowData: [{ id: '123' }, { id: '125' }, { id: '9342' }, { id: '1212' }], rowCount: 4 });
},
excelExport: async (filterState) =>
new Promise((res, rej) =>
setTimeout(() => {
res();
console.log('løøøøøøø');
}, 2000)
),
}}
sidesheetOptions={{
type: 'default',
Expand Down
3 changes: 0 additions & 3 deletions dod.yaml

This file was deleted.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "workspace",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"scripts": {
"preinstall": "npx only-allow pnpm",
"first-time-setup": "npm i -g pnpm@8.0.0 turbo && pnpm i && pnpm test",
Expand All @@ -24,9 +25,5 @@
"turbo": "^1.9.3",
"typescript": "~5.0.2",
"typescript-plugin-styled-components": "^2.0.0"
},
"workspaces": [
"packages/**",
"apps/**"
]
}
}
36 changes: 18 additions & 18 deletions packages/garden/src/lib/hooks/useItemWidths.ts
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;
}
2 changes: 1 addition & 1 deletion packages/power-bi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-powerbi",
"version": "1.0.4",
"version": "1.0.6",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ export function ExpandedFilter({ controller }: ExpandedFilterProps): JSX.Element
return (
<StyledExpandedFilterWrapper>
<StyledFilterItemsWrapper>
{visibleFilters.map((groupName) => (
<FilterItems
controller={controller}
handleOnChange={handleOnChange}
handleOnSelectAll={controller.handleOnSelectAll}
activeFilters={activeFilters}
group={slicerFilters.find((s) => s.type === groupName) as PowerBiFilter}
key={groupName}
/>
))}
{slicerFilters
.filter((s) => visibleFilters.includes(s.type))
.map((group) => (
<FilterItems
controller={controller}
handleOnChange={handleOnChange}
handleOnSelectAll={controller.handleOnSelectAll}
activeFilters={activeFilters}
group={group}
key={group.type}
/>
))}
</StyledFilterItemsWrapper>
<StyledSidebar>
<div onClick={() => setIsFilterExpanded(!isFilterExpanded)}>
Expand Down
3 changes: 2 additions & 1 deletion packages/power-bi/src/lib/utils/getActiveFilterValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const getActiveFilterValues = async (filters: PowerBiFilter[]) => {
const activeFilterValues = {} as Record<string, (string | number | boolean)[]>;

filters.forEach(async (filter) => {
const { filters: slicerFilters } = await filter.slicer.getSlicerState();
const a = await filter.slicer.getSlicerState().catch((_) => {});
const slicerFilters = a ? a.filters : [];
activeFilterValues[filter.type] = [];
slicerFilters.forEach((slicerFilter: SlicerFilter) => {
activeFilterValues[filter.type] = slicerFilter?.values || [];
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace-fusion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-fusion",
"version": "5.0.4",
"version": "5.1.0",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
67 changes: 35 additions & 32 deletions packages/workspace-fusion/src/lib/components/ErrorComponent.tsx
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>
);
}
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 packages/workspace-fusion/src/lib/integrations/grid/grid.ts
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>;
};
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>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const GardenWrapper = <TData extends Record<PropertyKey, unknown>, TFilte
}, [groupingKeys, timeInterval, dateVariant]);

const { setIcons } = useWorkspaceHeaderComponents();

useEffect(() => {
const icon: HeaderIcon = {
Icon: ({ anchor }) => (
Expand Down
Loading

0 comments on commit 3dd67d2

Please sign in to comment.