-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): Powerbi richtext embed slice (#8703)
* Add powerbi library and component * Add powerbi slice code * Allow powerbi slice on project pages * Add powerbi slice to project subpages * Add support for forms on project pages while we're at it Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
da9c333
commit 6bf6221
Showing
13 changed files
with
181 additions
and
31 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
apps/web/components/Organization/Slice/PowerBiSlice/PowerBiSlice.css.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { style } from '@vanilla-extract/css' | ||
|
||
export const container = style({ | ||
height: '500px', | ||
}) |
27 changes: 27 additions & 0 deletions
27
apps/web/components/Organization/Slice/PowerBiSlice/PowerBiSlice.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { PowerBIEmbed } from 'powerbi-client-react' | ||
import { Embed } from 'powerbi-client' | ||
import { PowerBiSlice as PowerBiSliceSchema } from '@island.is/web/graphql/schema' | ||
import * as styles from './PowerBiSlice.css' | ||
|
||
interface PowerBiSliceProps { | ||
slice: PowerBiSliceSchema | ||
} | ||
|
||
export const PowerBiSlice = ({ slice }: PowerBiSliceProps) => { | ||
const getEmbeddedComponent = (embed: Embed) => { | ||
if (slice?.powerBiEmbedProps?.height) { | ||
embed.element.style.height = slice.powerBiEmbedProps.height | ||
} | ||
} | ||
|
||
const embedProps = slice?.powerBiEmbedProps ?? {} | ||
return ( | ||
<PowerBIEmbed | ||
embedConfig={{ type: 'report', ...embedProps }} | ||
cssClassName={styles.container} | ||
getEmbeddedComponent={getEmbeddedComponent} | ||
/> | ||
) | ||
} | ||
|
||
export default PowerBiSlice |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import dynamic from 'next/dynamic' | ||
export const PowerBiSlice = dynamic(() => import('./PowerBiSlice'), { | ||
ssr: false, | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Field, ID, ObjectType } from '@nestjs/graphql' | ||
import graphqlTypeJson from 'graphql-type-json' | ||
import { SystemMetadata } from '@island.is/shared/types' | ||
import { IPowerBiSlice } from '../generated/contentfulTypes' | ||
|
||
@ObjectType() | ||
export class PowerBiSlice { | ||
@Field(() => ID) | ||
id!: string | ||
|
||
@Field() | ||
title?: string | ||
|
||
@Field(() => graphqlTypeJson, { nullable: true }) | ||
powerBiEmbedProps?: Record<string, unknown> | ||
} | ||
|
||
export const mapPowerBiSlice = ({ | ||
fields, | ||
sys, | ||
}: IPowerBiSlice): SystemMetadata<PowerBiSlice> => { | ||
return { | ||
typename: 'PowerBiSlice', | ||
id: sys.id, | ||
title: fields.title ?? '', | ||
powerBiEmbedProps: fields.config ?? null, | ||
} | ||
} |
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
Oops, something went wrong.