diff --git a/app/embeds/GoogleCalendar.js b/app/embeds/GoogleCalendar.js new file mode 100644 index 0000000000..0cbba3c74b --- /dev/null +++ b/app/embeds/GoogleCalendar.js @@ -0,0 +1,37 @@ +// @flow +import * as React from "react"; +import Image from "components/Image"; +import Frame from "./components/Frame"; + +const URL_REGEX = new RegExp("^https?://calendar.google.com/calendar/(.*)$"); + +type Props = {| + attrs: {| + href: string, + matches: string[], + |}, +|}; + +export default class GoogleCalendar extends React.Component { + static ENABLED = [URL_REGEX]; + + render() { + return ( + + } + canonicalUrl={this.props.attrs.href} + title="Google Calendar" + border + /> + ); + } +} diff --git a/app/embeds/GoogleCalendar.test.js b/app/embeds/GoogleCalendar.test.js new file mode 100644 index 0000000000..2e9cffbd7b --- /dev/null +++ b/app/embeds/GoogleCalendar.test.js @@ -0,0 +1,19 @@ +/* eslint-disable flowtype/require-valid-file-annotation */ +import GoogleCalendar from "./GoogleCalendar"; + +describe("GoogleCalendar", () => { + const match = GoogleCalendar.ENABLED[0]; + test("to be enabled on share link", () => { + expect( + "https://calendar.google.com/calendar/embed?src=tom%40outline.com&ctz=America%2FSao_Paulo".match( + match + ) + ).toBeTruthy(); + }); + + test("to not be enabled elsewhere", () => { + expect("https://calendar.google.com/calendar".match(match)).toBe(null); + expect("https://calendar.google.com".match(match)).toBe(null); + expect("https://www.google.com".match(match)).toBe(null); + }); +}); diff --git a/public/images/google-calendar.png b/public/images/google-calendar.png new file mode 100644 index 0000000000..3f6285ea30 Binary files /dev/null and b/public/images/google-calendar.png differ