From 88dec4a28fe01b79d59b2a7ced7bcaaca2b99daf Mon Sep 17 00:00:00 2001
From: Rodrigo Pombo
Date: Thu, 21 Feb 2019 18:54:32 -0300
Subject: [PATCH] Customize log in button
---
src/app-helpers.js | 32 ++++------------------------
src/git-providers/github-provider.js | 28 +++++++++++++++++++++++-
src/git-providers/gitlab-provider.js | 15 ++++++++++++-
3 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/src/app-helpers.js b/src/app-helpers.js
index ac39301..6832d79 100644
--- a/src/app-helpers.js
+++ b/src/app-helpers.js
@@ -29,6 +29,7 @@ export function Loading({ repo, path }) {
}
export function Error({ error, gitProvider }) {
+ const { LogInButton } = gitProvider;
if (error.status === 403) {
return (
@@ -36,7 +37,7 @@ export function Error({ error, gitProvider }) {
GitHub API rate limit exceeded for your IP (60 requests per hour).
Sign in with GitHub for more:
-
+
);
}
@@ -47,8 +48,8 @@ export function Error({ error, gitProvider }) {
File not found.
{gitProvider.isLoggedIn && !gitProvider.isLoggedIn() && (
- Is it from a private repo? Sign in with GitHub:
-
+ Is it from a private repo? Sign in:
+
)}
@@ -66,31 +67,6 @@ export function Error({ error, gitProvider }) {
);
}
-function GitHubButton({ onClick }) {
- return (
-
- );
-}
-
export function useLoader(promiseFactory, deps) {
const [state, setState] = useState({
data: null,
diff --git a/src/git-providers/github-provider.js b/src/git-providers/github-provider.js
index c8ed0b7..681b46a 100644
--- a/src/git-providers/github-provider.js
+++ b/src/git-providers/github-provider.js
@@ -1,4 +1,5 @@
import netlify from "netlify-auth-providers";
+import React from "react";
import { Base64 } from "js-base64";
const TOKEN_KEY = "github-token";
@@ -114,11 +115,36 @@ function logIn() {
});
// });
}
+function LogInButton() {
+ return (
+
+ );
+}
export default {
showLanding,
getPath,
getCommits,
logIn,
- isLoggedIn
+ isLoggedIn,
+ LogInButton
};
diff --git a/src/git-providers/gitlab-provider.js b/src/git-providers/gitlab-provider.js
index e5858ea..d8b008a 100644
--- a/src/git-providers/gitlab-provider.js
+++ b/src/git-providers/gitlab-provider.js
@@ -1,5 +1,6 @@
import netlify from "netlify-auth-providers";
import { Base64 } from "js-base64";
+import React from "react";
const TOKEN_KEY = "gitlab-token";
function getHeaders() {
@@ -115,10 +116,22 @@ function logIn() {
// });
}
+function LogInButton() {
+ return (
+
+ );
+}
+
export default {
showLanding,
getPath,
getCommits,
logIn,
- isLoggedIn
+ isLoggedIn,
+ LogInButton
};