-
- {' '}
- then{' '}
- generate a new client secret.
-
+
+ {' '}
+ on GitHub then paste your{' '}
+ client id and client secret below.
}
/>
@@ -109,28 +107,25 @@ export const LoginEnterpriseRoute: FC = () => {
placeholder="ABC123DEF456"
/>
-
-
-
-
-
-
-
+
+
+
+
);
@@ -160,7 +155,10 @@ export const LoginEnterpriseRoute: FC = () => {
/>
-
Login with GitHub Enterprise
+
+
+ Login with OAuth App
+
diff --git a/src/routes/LoginWithToken.test.tsx b/src/routes/LoginWithPersonalAccessToken.test.tsx
similarity index 90%
rename from src/routes/LoginWithToken.test.tsx
rename to src/routes/LoginWithPersonalAccessToken.test.tsx
index eb969083f..6c0a4eae5 100644
--- a/src/routes/LoginWithToken.test.tsx
+++ b/src/routes/LoginWithPersonalAccessToken.test.tsx
@@ -11,7 +11,10 @@ import { MemoryRouter } from 'react-router-dom';
import TestRenderer from 'react-test-renderer';
import { AppContext } from '../context/App';
-import { LoginWithToken, validate } from './LoginWithToken';
+import {
+ LoginWithPersonalAccessToken,
+ validate,
+} from './LoginWithPersonalAccessToken';
const mockNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
@@ -19,7 +22,7 @@ jest.mock('react-router-dom', () => ({
useNavigate: () => mockNavigate,
}));
-describe('routes/LoginWithToken.tsx', () => {
+describe('routes/LoginWithPersonalAccessToken.tsx', () => {
const openExternalMock = jest.spyOn(shell, 'openExternal');
const mockValidateToken = jest.fn();
@@ -33,7 +36,7 @@ describe('routes/LoginWithToken.tsx', () => {
it('renders correctly', () => {
const tree = TestRenderer.create(
-
+
,
);
@@ -43,7 +46,7 @@ describe('routes/LoginWithToken.tsx', () => {
it('let us go back', () => {
render(
-
+
,
);
@@ -77,7 +80,7 @@ describe('routes/LoginWithToken.tsx', () => {
render(
-
+
,
);
@@ -95,7 +98,7 @@ describe('routes/LoginWithToken.tsx', () => {
render(
-
+
,
);
@@ -112,7 +115,7 @@ describe('routes/LoginWithToken.tsx', () => {
render(
-
+
,
);
@@ -138,7 +141,7 @@ describe('routes/LoginWithToken.tsx', () => {
render(
-
+
,
);
@@ -162,7 +165,7 @@ describe('routes/LoginWithToken.tsx', () => {
it('should render the form with errors', () => {
render(
-
+
,
);
@@ -183,7 +186,7 @@ describe('routes/LoginWithToken.tsx', () => {
render(
-
+
,
);
diff --git a/src/routes/LoginWithToken.tsx b/src/routes/LoginWithPersonalAccessToken.tsx
similarity index 76%
rename from src/routes/LoginWithToken.tsx
rename to src/routes/LoginWithPersonalAccessToken.tsx
index 919706d54..5fc1b6ac9 100644
--- a/src/routes/LoginWithToken.tsx
+++ b/src/routes/LoginWithPersonalAccessToken.tsx
@@ -29,11 +29,6 @@ interface IFormErrors {
export const validate = (values: IValues): IFormErrors => {
const errors: IFormErrors = {};
- if (!values.token) {
- errors.token = 'Required';
- } else if (!/^[A-Z0-9_]{40}$/i.test(values.token)) {
- errors.token = 'Invalid token.';
- }
if (!values.hostname) {
errors.hostname = 'Required';
@@ -45,10 +40,16 @@ export const validate = (values: IValues): IFormErrors => {
errors.hostname = 'Invalid hostname.';
}
+ if (!values.token) {
+ errors.token = 'Required';
+ } else if (!/^[A-Z0-9_]{40}$/i.test(values.token)) {
+ errors.token = 'Invalid token.';
+ }
+
return errors;
};
-export const LoginWithToken: FC = () => {
+export const LoginWithPersonalAccessToken: FC = () => {
const { validateToken } = useContext(AppContext);
const navigate = useNavigate();
const [isValidToken, setIsValidToken] = useState
(true);
@@ -63,10 +64,8 @@ export const LoginWithToken: FC = () => {
label="Hostname"
placeholder="github.company.com"
helpText={
-
-
- Change only if you are using GitHub Enterprise Server.
-
+
+ Change only if you are using GitHub Enterprise Server.
}
/>
@@ -81,7 +80,6 @@ export const LoginWithToken: FC = () => {
)}
-
-
-
-
-
-
-
+
+
+
);
};
- const submit = useCallback(async (data: IValues) => {
+ const login = useCallback(async (data: IValues) => {
setIsValidToken(true);
try {
await validateToken(data as AuthTokenOptions);
@@ -155,7 +149,8 @@ export const LoginWithToken: FC = () => {
/>
-
+
+
Login with Personal Access Token
@@ -163,10 +158,10 @@ export const LoginWithToken: FC = () => {
+
+ Login with
+
`;
diff --git a/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap b/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap
deleted file mode 100644
index b5a7bc654..000000000
--- a/src/routes/__snapshots__/LoginEnterprise.test.tsx.snap
+++ /dev/null
@@ -1,243 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`routes/LoginEnterprise.tsx renders correctly 1`] = `
-
-
-
-
- Login with GitHub Enterprise
-
-
-
-
-`;
diff --git a/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap b/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap
new file mode 100644
index 000000000..dc9f6d4dd
--- /dev/null
+++ b/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap
@@ -0,0 +1,254 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`routes/LoginWithOAuthApp.tsx renders correctly 1`] = `
+
+
+
+
+
+ Login with OAuth App
+
+
+
+
+`;
diff --git a/src/routes/__snapshots__/LoginWithToken.test.tsx.snap b/src/routes/__snapshots__/LoginWithPersonalAccessToken.test.tsx.snap
similarity index 53%
rename from src/routes/__snapshots__/LoginWithToken.test.tsx.snap
rename to src/routes/__snapshots__/LoginWithPersonalAccessToken.test.tsx.snap
index d92a91a2b..64ac93269 100644
--- a/src/routes/__snapshots__/LoginWithToken.test.tsx.snap
+++ b/src/routes/__snapshots__/LoginWithPersonalAccessToken.test.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`routes/LoginWithToken.tsx renders correctly 1`] = `
+exports[`routes/LoginWithPersonalAccessToken.tsx renders correctly 1`] = `
@@ -37,8 +37,29 @@ exports[`routes/LoginWithToken.tsx renders correctly 1`] = `
+
Login with Personal Access Token
@@ -72,12 +93,10 @@ exports[`routes/LoginWithToken.tsx renders correctly 1`] = `
-
-
- Change only if you are using GitHub Enterprise Server.
-
+
+ Change only if you are using GitHub Enterprise Server.
@@ -109,7 +128,7 @@ exports[`routes/LoginWithToken.tsx renders correctly 1`] = `
-
-
-
+
-
+ }
+ viewBox="0 0 16 16"
+ width={16}
+ >
+
+
+ Login
+
diff --git a/src/routes/__snapshots__/Settings.test.tsx.snap b/src/routes/__snapshots__/Settings.test.tsx.snap
index f8a185eb6..318cde581 100644
--- a/src/routes/__snapshots__/Settings.test.tsx.snap
+++ b/src/routes/__snapshots__/Settings.test.tsx.snap
@@ -563,11 +563,11 @@ exports[`routes/Settings.tsx General should render itself & its children 1`] = `