* First try

* Support old embeds
This commit is contained in:
Limezy
2023-03-03 23:28:16 +07:00
committed by GitHub
parent bef9673530
commit e4fadd01d9
6 changed files with 47 additions and 40 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -1,29 +0,0 @@
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);
expect(
"https://datastudioogoogle.com/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBe(null);
expect(
"https://datastudio.googleecom/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBe(null);
});
});

View File

@@ -0,0 +1,34 @@
import GoogleLookerStudio from "./GoogleLookerStudio";
describe("GoogleLookerStudio", () => {
const match = GoogleLookerStudio.ENABLED[0];
test("to be enabled on share link", () => {
expect(
"https://lookerstudio.google.com/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBeTruthy();
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://lookerstudio.google.com/u/0/".match(match)).toBe(null);
expect("https://lookerstudio.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://lookerstudioogoogle.com/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBe(null);
expect(
"https://lookerstudio.googleecom/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBe(null);
});
});

View File

@@ -3,30 +3,30 @@ import Frame from "../components/Frame";
import Image from "../components/Image";
import { EmbedProps as Props } from ".";
function GoogleDataStudio(props: Props) {
function GoogleLookerStudio(props: Props) {
return (
<Frame
{...props}
src={props.attrs.href.replace("u/0", "embed").replace("/edit", "")}
icon={
<Image
src="/images/google-datastudio.png"
alt="Google Data Studio Icon"
src="/images/google-lookerstudio.png"
alt="Google Looker Studio Icon"
width={16}
height={16}
/>
}
canonicalUrl={props.attrs.href}
title="Google Data Studio"
title="Google Looker Studio"
border
/>
);
}
GoogleDataStudio.ENABLED = [
GoogleLookerStudio.ENABLED = [
new RegExp(
"^https?://datastudio\\.google\\.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
"^https?://(lookerstudio|datastudio)\\.google\\.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
),
];
export default GoogleDataStudio;
export default GoogleLookerStudio;

View File

@@ -20,11 +20,11 @@ import Framer from "./Framer";
import Gist from "./Gist";
import Gliffy from "./Gliffy";
import GoogleCalendar from "./GoogleCalendar";
import GoogleDataStudio from "./GoogleDataStudio";
import GoogleDocs from "./GoogleDocs";
import GoogleDrawings from "./GoogleDrawings";
import GoogleDrive from "./GoogleDrive";
import GoogleForms from "./GoogleForms";
import GoogleLookerStudio from "./GoogleLookerStudio";
import GoogleSheets from "./GoogleSheets";
import GoogleSlides from "./GoogleSlides";
import Grist from "./Grist";
@@ -248,10 +248,12 @@ const embeds: EmbedDescriptor[] = [
component: GoogleCalendar,
}),
new EmbedDescriptor({
title: "Google Data Studio",
title: "Google Looker Studio",
keywords: "bi business intelligence",
icon: <Img src="/images/google-datastudio.png" alt="Google Data Studio" />,
component: GoogleDataStudio,
icon: (
<Img src="/images/google-lookerstudio.png" alt="Google Looker Studio" />
),
component: GoogleLookerStudio,
}),
new EmbedDescriptor({
title: "Google Forms",