diff --git a/website/netlify.toml b/website/netlify.toml index 575fd8b5..4ecccebd 100644 --- a/website/netlify.toml +++ b/website/netlify.toml @@ -7,7 +7,6 @@ ignore = "false" [context.deploy-preview] - command = "yarn build:withoutAuth" ignore = "false" [[redirects]] @@ -18,21 +17,6 @@ status = 302 force = true -[[redirects]] -from = "/github-proxy/*" -to = "https://github.com/:splat" -status = 200 - -[[redirects]] -from = "/github-api-proxy/*" -to = "https://api.github.com/:splat" -status = 200 - -[[redirects]] -from = "/docs-access/*" -to = "https://j20f3pfq11.execute-api.us-east-1.amazonaws.com/Prod/u/:splat" -status = 200 - [[redirects]] from = "/t" to = "https://api.amplitude.com" diff --git a/website/package.json b/website/package.json index cda98f47..69f527c4 100644 --- a/website/package.json +++ b/website/package.json @@ -4,17 +4,15 @@ "private": true, "scripts": { "docusaurus": "docusaurus", - "start": "OAUTH_ENABLE=false docusaurus start", - "start:withAuth": "OAUTH_ENABLE=true docusaurus start --port=3001", - "build": "OAUTH_ENABLE=true docusaurus build", - "build:withoutAuth": "OAUTH_ENABLE=false docusaurus build", + "start": "docusaurus start", + "build": "docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", "serve": "docusaurus serve", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "start-server": "concurrently \"OAUTH_ENABLE=false yarn docusaurus start --port=3000 --no-open\" \"OAUTH_ENABLE=true yarn docusaurus start --port=3001 --no-open\"", + "start-server": "concurrently \"yarn docusaurus start --port=3000 --no-open\" \"yarn docusaurus start --port=3001 --no-open\"", "ci": "start-server-and-test 'yarn start-server' '3000|3001' 'yarn run cypress run'" }, "dependencies": { diff --git a/website/src/api/github.js b/website/src/api/github.js deleted file mode 100644 index ea39bc49..00000000 --- a/website/src/api/github.js +++ /dev/null @@ -1,67 +0,0 @@ -import axios from 'axios'; - -const AxiosInstance = axios.create({ - headers: { 'Accept': 'application/vnd.github.v3+json' }, -}); - -function bindApiCall({ url, config, errorMessage }) { - try { - const apiCall = AxiosInstance.get(url, { - ...config, - validateStatus: function (status) { - return status < 500; // Resolve only if the status code is less than 500 - } - }) - - return apiCall - } catch (error) { - console.log(errorMessage, error.message) - } -} - -async function getAccessToken(code) { - const accessToken = await bindApiCall({ - url: `${process.env.REACT_APP_API_PROXY_ENABLE == 'true' ? '/github-proxy' : 'https://github.com'}/login/oauth/access_token`, - config: { - params: { - code, - client_id: process.env.REACT_APP_CLIENT_ID, - client_secret: process.env.REACT_APP_CLIENT_SECRET, - }, - errorMessage: 'error getAccessToken' - } - }) - - return accessToken.data -} - -export async function getUser(access_token) { - const user = await bindApiCall({ - url: `${process.env.REACT_APP_API_PROXY_ENABLE == 'true' ? '/github-api-proxy' : 'https://api.github.com'}/user`, - config: { - headers: { Authorization: `token ${access_token}` }, - }, - errorMessage: 'error getUser' - }) - - return { - login: user.data?.login, - error: user.data?.error_description, - status: user.status - } -} - -export async function checkUserCollaboratorStatus(code) { - const { access_token } = await getAccessToken(code) - const { login } = await getUser(access_token) - - const isUserCollaborator = await bindApiCall({ - url: `${process.env.REACT_APP_API_PROXY_ENABLE == 'true' ? '/docs-access' : 'https://j20f3pfq11.execute-api.us-east-1.amazonaws.com/Prod/u'}/${login}`, - errorMessage: 'error checkUserCollaboratorStatus' - }) - - return { - permission: isUserCollaborator.data, - login - } -} \ No newline at end of file diff --git a/website/src/components/DocPageAuthentication.js b/website/src/components/DocPageAuthentication.js deleted file mode 100644 index e352fb56..00000000 --- a/website/src/components/DocPageAuthentication.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import { GithubLoginButton } from 'react-social-login-buttons'; -import style from './DocPageAuthentication.module.css' - -export default function DocAuthentication() { - return ( -
-

Welcome to the Dagger documentation

-

Please Sign In to Github to get access to the doc

-
- window.location.href = process.env.REACT_APP_GITHUB_AUTHORIZE_URI} /> -
-
- ) -} \ No newline at end of file diff --git a/website/src/components/DocPageAuthentication.module.css b/website/src/components/DocPageAuthentication.module.css deleted file mode 100644 index e0f16f4d..00000000 --- a/website/src/components/DocPageAuthentication.module.css +++ /dev/null @@ -1,18 +0,0 @@ -.container { - background: url("/img/Dagger_Website_Space_Uranus.png") no-repeat; - background-size: cover; - height: 100vh; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} - -.btn__github { - width: 240px !important; - border-radius: 0 !important; -} - -.btn__github > div { - display: inline-flex !important; -} diff --git a/website/src/components/DocPageCustom.js b/website/src/components/DocPageCustom.js deleted file mode 100644 index f97509ad..00000000 --- a/website/src/components/DocPageCustom.js +++ /dev/null @@ -1,39 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import qs from 'querystringify'; -import isEmpty from 'lodash/isEmpty'; -import NProgress from "nprogress"; - -import { checkUserCollaboratorStatus } from '../api/github' -import DocPageAuthentication from './DocPageAuthentication'; -import DocPageRedirect from './DocPageRedirect'; - -function DocPageCustom({ location, userAccessStatus, setUserAccessStatus }) { - const [isLoading, setIsLoading] = useState(true) - const [redirectState, setRedirectState] = useState() - const authQuery = qs.parse(location.search); - - useEffect(async () => { - NProgress.start() - if (!isEmpty(authQuery?.code) && userAccessStatus === null) { //callback after successful auth with github - const user = await checkUserCollaboratorStatus(authQuery?.code); - setUserAccessStatus(user) - if (user?.permission) { - window.localStorage.setItem('user', JSON.stringify(user)); - } - } - NProgress.done(); - setIsLoading(false) - }, []) - - if(isLoading) return

...

- - if (userAccessStatus?.permission === false) { - return - } - - if (userAccessStatus === null) { - return - } -} - -export default DocPageCustom \ No newline at end of file diff --git a/website/src/components/DocPageRedirect.js b/website/src/components/DocPageRedirect.js deleted file mode 100644 index 981dd0c5..00000000 --- a/website/src/components/DocPageRedirect.js +++ /dev/null @@ -1,29 +0,0 @@ -import React, { useEffect, useState } from "react"; -import style from './DocPageRedirect.module.css' - - -export default function DocPageRedirect() { - const [counter, setCounter] = useState(10) - - useEffect(() => { - setTimeout(() => window.location.href = process.env.REACT_APP_DAGGER_SITE_URI, 10000) - setInterval(() => setCounter((prevState) => prevState - 1), 1000) - }, []) - - return ( -
-
-
-

Oups!

-

It seems you don't have the permission to see Dagger's documentation. But don't worry you can request an Eary Access :). You'll be redirect to Dagger website in {counter} seconds

-

See you soon !

-
- If nothing happen, click here to go to Dagger website -
-
- -
-
-
- ) -} \ No newline at end of file diff --git a/website/src/components/DocPageRedirect.module.css b/website/src/components/DocPageRedirect.module.css deleted file mode 100644 index 32f717b2..00000000 --- a/website/src/components/DocPageRedirect.module.css +++ /dev/null @@ -1,25 +0,0 @@ -.wrapper { - background: linear-gradient(180deg, #131226, #0e2b3d); - height: 100vh; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - color: var(--ifm-color-primary-light); - max-width: 100%; -} - -.wrapper a { - color: var(--ifm-color-primary-light); - text-decoration: underline; -} - -.h1 { - margin-bottom: 2rem; -} - -.row { - justify-content: center; - align-content: center; - align-items: center; -} diff --git a/website/src/theme/DocPage/index.js b/website/src/theme/DocPage/index.js index 0ef5f893..b76af607 100644 --- a/website/src/theme/DocPage/index.js +++ b/website/src/theme/DocPage/index.js @@ -25,7 +25,6 @@ import { DocsVersionProvider, } from '@docusaurus/theme-common'; import Head from '@docusaurus/Head'; -import DocPageCustom from "../../components/DocPageCustom" import amplitude from 'amplitude-js'; function DocPageContent({ @@ -140,29 +139,9 @@ function DocPage(props) { ); // DocPage Swizzle - const [userAccessStatus, setUserAccessStatus] = useState( - (() => { - if (typeof window !== 'undefined') - return JSON.parse(window.localStorage.getItem('user')); - })(), - ); - useEffect(() => { - if (userAccessStatus?.login) { - var amplitudeInstance = amplitude.getInstance().init(process.env.REACT_APP_AMPLITUDE_ID, userAccessStatus?.login.toLowerCase(), { - apiEndpoint: `${window.location.hostname}/t` - }); - amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname }); - - if (window?.hj) { - window.hj("identify", userAccessStatus?.login.toLowerCase(), {}); - } - } - }, [location.pathname, userAccessStatus]) - - if (process.env.OAUTH_ENABLE == 'true' && userAccessStatus?.permission !== true) { - return - } + amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname }); + }, [location.pathname]) // End DocPageSwizzle if (!currentDocRoute) {