Skip to content

Commit

Permalink
Merge branch 'feat--export-to-excel-in-grid' of https://github.com/eq…
Browse files Browse the repository at this point in the history
…uinor/fusion-workspace into feat--export-to-excel-in-grid
  • Loading branch information
espenkalle committed Sep 19, 2023
2 parents c7c51d3 + 189b9d6 commit b12c5cd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fusion Workspace

![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)
![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
8 changes: 7 additions & 1 deletion apps/test-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +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)),
excelExport: async (filterState) =>
new Promise((res, rej) =>
setTimeout(() => {
res();
console.log('løøøøøøø');
}, 2000)
),
}}
sidesheetOptions={{
type: 'default',
Expand Down
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/**"
]
}
}
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.5",
"version": "1.0.6",
"type": "module",
"sideEffects": false,
"license": "MIT",
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,20 @@ export const GridOptionPopover = ({ anchor, excelExport, filterState }: GridOpti
</Popover.Header>
<Popover.Content style={{ overflow: 'hidden' }}>
<ButtContainer>
{isError && <DumpsterFireDialog text={typeof error === 'string' ? error : 'We encountered an issue fetching the data. Please try again later.'} />}
<Button disabled={excelExport == undefined} style={{ width: '130px' }} onClick={!isLoading ? handleExportToExcel : undefined}>
{isError && (
<DumpsterFireDialog
text={
typeof error === 'string'
? error
: 'We encountered an issue fetching the data. Please try again later.'
}
/>
)}
<Button
disabled={excelExport == undefined}
style={{ width: '130px' }}
onClick={!isLoading ? handleExportToExcel : undefined}
>
{isLoading ? <Progress.Dots color={'neutral'} /> : 'Export to Excel'}
</Button>
</ButtContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { GridOptionPopover } from './GridOptionsPopover';
export type GridWrapperProps<
TData extends Record<PropertyKey, unknown>,
TContext extends Record<PropertyKey, unknown> = never,
TFilter = undefined
TFilter = undefined,
> = {
config: GridConfig<TData, TFilter>;
getIdentifier: GetIdentifier<TData>;
Expand All @@ -22,7 +22,7 @@ export type GridWrapperProps<
export const GridWrapper = <
TData extends Record<PropertyKey, unknown>,
TContext extends Record<PropertyKey, unknown> = never,
TFilter = undefined
TFilter = undefined,
>({
config,
getIdentifier,
Expand Down Expand Up @@ -54,7 +54,9 @@ export const GridWrapper = <

useEffect(() => {
const icon: HeaderIcon = {
Icon: ({ anchor }) => <GridOptionPopover anchor={anchor} filterState={filterState} excelExport={config.excelExport} />,
Icon: ({ anchor }) => (
<GridOptionPopover anchor={anchor} filterState={filterState} excelExport={config.excelExport} />
),
name: 'grid-settings',
placement: 'right',
type: 'button',
Expand Down

0 comments on commit b12c5cd

Please sign in to comment.