Skip to content

Commit

Permalink
feat: Add Google DataStudio embed (outline#2293)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Moor <[email protected]>
  • Loading branch information
matbrgz and tommoor authored Jul 14, 2021
1 parent 8e5a2b8 commit 06e16ee
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app/embeds/GoogleDataStudio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @flow
import * as React from "react";
import Image from "components/Image";
import Frame from "./components/Frame";

const URL_REGEX = new RegExp(
"^https?://datastudio.google.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
);

type Props = {|
attrs: {|
href: string,
matches: string[],
|},
|};

export default class GoogleDataStudio extends React.Component<Props> {
static ENABLED = [URL_REGEX];

render() {
return (
<Frame
{...this.props}
src={this.props.attrs.href.replace("u/0", "embed").replace("/edit", "")}
icon={
<Image
src="/images/google-datastudio.png"
alt="Google Data Studio Icon"
width={16}
height={16}
/>
}
canonicalUrl={this.props.attrs.href}
title="Google Data Studio"
border
/>
);
}
}
19 changes: 19 additions & 0 deletions app/embeds/GoogleDataStudio.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import GoogleDataStudio from "./GoogleDataStudio";

describe("GoogleDataStudio", () => {
const match = GoogleDataStudio.ENABLED[0];
test("to be enabled on share link", () => {
expect(
"https://datastudio.google.com/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBeTruthy();
});

test("to not be enabled elsewhere", () => {
expect("https://datastudio.google.com/u/0/".match(match)).toBe(null);
expect("https://datastudio.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
});
});
8 changes: 8 additions & 0 deletions app/embeds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Descript from "./Descript";
import Figma from "./Figma";
import Framer from "./Framer";
import Gist from "./Gist";
import GoogleDataStudio from "./GoogleDataStudio";
import GoogleDocs from "./GoogleDocs";
import GoogleDrawings from "./GoogleDrawings";
import GoogleDrive from "./GoogleDrive";
Expand Down Expand Up @@ -148,6 +149,13 @@ export default [
component: GoogleSlides,
matcher: matcher(GoogleSlides),
},
{
title: "Google Data Studio",
keywords: "business intelligence",
icon: () => <Img src="/images/google-datastudio.png" />,
component: GoogleDataStudio,
matcher: matcher(GoogleDataStudio),
},
{
title: "InVision",
keywords: "design prototype",
Expand Down
Binary file added public/images/google-datastudio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06e16ee

Please sign in to comment.