Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-issue-template
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnusGjosund authored Mar 19, 2024
2 parents 13cb942 + 3d84106 commit 3893d4e
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 152 deletions.
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.14",
"version": "2.0.0",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
16 changes: 10 additions & 6 deletions packages/power-bi/src/lib/components/PowerBi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ import { Loading } from './loading';
import { chevron_down, chevron_up } from '@equinor/eds-icons';
import { Icon } from '@equinor/eds-core-react';
import { QueryClient, QueryClientProvider, QueryErrorResetBoundary } from '@tanstack/react-query';
import { ErrorBoundary } from 'react-error-boundary';
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
import { FusionEmbedConfig, FusionPowerBiToken } from '../types';
import { ErrorComponent } from './error/ErrorComponent';

import { PowerBiController } from '../classes';
import { IBasicFilter } from 'index';
import { Report } from './report/Report';
import React from 'react';

Icon.add({ chevron_down, chevron_up });

export type ErrorComponentProps = {
reportUri: string;
} & FallbackProps;

export interface PowerBiProps {
reportUri: string;
getToken: (reportUri: string, signal?: AbortSignal) => Promise<FusionPowerBiToken>;
getEmbedInfo: (reportUri: string, token: string, signal?: AbortSignal) => Promise<FusionEmbedConfig>;
getErrorMessage: (reportUri: string) => Promise<string>;
ErrorComponent: React.ComponentType<ErrorComponentProps>;
filters?: IBasicFilter;
bookmark?: string;
controller: PowerBiController;
Expand All @@ -25,16 +30,15 @@ export interface PowerBiProps {
const client = new QueryClient();

export const PowerBi = (props: PowerBiProps) => {
const { reportUri, ErrorComponent } = props;
return (
<QueryClientProvider client={client}>
<Suspense fallback={<Loading />}>
<QueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary
onReset={reset}
fallbackRender={(e) => (
<ErrorComponent {...e} getErrorMessage={props.getErrorMessage} reportUri={props.reportUri} />
)}
FallbackComponent={(errorProps) => <ErrorComponent {...errorProps} reportUri={reportUri} />}
>
<Report {...props} />
</ErrorBoundary>
Expand Down
10 changes: 7 additions & 3 deletions packages/power-bi/src/lib/components/QuickFilter/QuickFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ const StyledFilterButtons = styled.div`
const StyledQuickFilterWrapper = styled.div`
display: grid;
width: 100%;
justify-content: flex-end;
grid-template-columns: repeat(auto-fit, minmax(60px, max-content));
gap: 2em;
justify-content: flex-start;
grid-template-columns: repeat(auto-fit, minmax(max-content, 50px));
grid-template-rows: 1fr;
gap: 10px;
align-items: center;
overflow-x: hidden;
padding-left: 10px;
padding-right: 10px;
`;

const FilterButtonContainer = styled.div`
Expand Down
22 changes: 0 additions & 22 deletions packages/power-bi/src/lib/components/error/ErrorComponent.tsx

This file was deleted.

62 changes: 0 additions & 62 deletions packages/power-bi/src/lib/components/error/ReportErrorMessage.tsx

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ActiveFilter, PowerBiFilter, PowerBiFilterItem } from '../../types';
import { getFilterHeaderText } from '../../utils/getFilterHeader';
import { FilterController } from '../Filter/Filter';
import { PowerBiGroupPopoverMenu } from '../groupPopoverMenu/GroupPopoverMenu';
import { StyledFilterGroupWrapper } from './quickFilterGroup.styles';
import { StyledFilterGroupContent, StyledFilterGroupWrapper } from './quickFilterGroup.styles';

interface PowerBiFilterGroupProps {
controller: FilterController;
Expand All @@ -24,18 +24,21 @@ export const PowerBiFilterGroup = ({

if (!activeFilters) return null;
const isAllChecked = activeFilters.length === 0 || activeFilters.length === group.filterVals.length;

return (
<div style={{ height: '50px', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<>
<StyledFilterGroupWrapper onClick={() => setIsOpen((s) => !s)} ref={anchorEl}>
<div>
{getFilterHeaderText(
isAllChecked,
group.type,
activeFilters.map((s) => s?.toString() ?? '(Blank)')
)}
</div>
<StyledFilterGroupContent>
<div>
{getFilterHeaderText(
isAllChecked,
group.type,
activeFilters.map((s) => s?.toString() ?? '(Blank)')
)}
</div>

<Icon color={tokens.colors.text.static_icons__tertiary.hex} name="chevron_down" />
<Icon color={tokens.colors.text.static_icons__tertiary.hex} name="chevron_down" />
</StyledFilterGroupContent>
</StyledFilterGroupWrapper>
{isOpen && (
<PowerBiGroupPopoverMenu
Expand All @@ -48,6 +51,6 @@ export const PowerBiFilterGroup = ({
onCloseMenu={() => setIsOpen(false)}
/>
)}
</div>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import { tokens } from '@equinor/eds-tokens';
import styled from 'styled-components';

export const StyledFilterGroupWrapper = styled.div`
height: 50px;
width: min-content;
display: flex;
align-items: center;
`;

export const StyledFilterGroupContent = styled.div`
height: auto;
width: auto;
width: min-content;
display: flex;
align-items: center;
cursor: pointer;
justify-content: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
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": "7.0.4",
"version": "8.0.0",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Integrations folder for exporting types from the integration
* namespace: @equinor/workspace-fusion/power-bi
*/
import { FallbackProps } from 'react-error-boundary';

import {
ActiveFilter,
Expand Down Expand Up @@ -54,6 +55,10 @@ type EmbedConfiguration = {
reportId: string;
};

export type ErrorComponentProps = {
reportUri: string;
} & FallbackProps;

type PowerBiConfig = {
reportUri: string;
getEmbed: (reportUri: string, token: string, signal?: AbortSignal) => Promise<EmbedConfiguration>;
Expand All @@ -68,7 +73,7 @@ type PowerBiConfig = {
* }
* ```
*/
getErrorMessage: (reportUri: string, signal?: AbortSignal) => Promise<string>;
ErrorComponent: React.ComponentType<ErrorComponentProps>;
filters?: FilterConfig;
ReportMetaData?: (props: ReportMetaDataProps) => JSX.Element;
getClassification?: (reportUri: string, signal?: AbortSignal) => Promise<string>;
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace-fusion/src/modules/power-bi/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ const PowerBiWrapper = (powerBiConfig: PowerBiConfig & { controller: PowerBiCont

return (
<PowerBI
getErrorMessage={powerBiConfig.getErrorMessage}
controller={powerBiConfig.controller}
getToken={powerBiConfig.getToken}
getEmbedInfo={powerBiConfig.getEmbed}
reportUri={powerBiConfig.reportUri}
filters={createBasicFilter(powerBiConfig.filters)}
ErrorComponent={powerBiConfig.ErrorComponent}
/>
);
};
Expand Down

0 comments on commit 3893d4e

Please sign in to comment.