Skip to content

Commit

Permalink
Add GHE support in UI
Browse files Browse the repository at this point in the history
- update the deployment manifests
- read enterprise url from env
- use `react-ghe-login` in place of `react-github-login`

Signed-off-by: vinamra28 <[email protected]>
  • Loading branch information
vinamra28 committed Jun 9, 2021
1 parent 07abb91 commit bf57dff
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions config/03-ui/30-ui-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ data:
API_URL: 'https://api.hub.tekton.dev'
GH_CLIENT_ID: ''
API_VERSION: ''
GHE_URL: ''
5 changes: 5 additions & 0 deletions config/03-ui/31-ui-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ spec:
- name: ui
image: quay.io/tekton-hub/ui
env:
- name: GHE_URL
valueFrom:
configMapKeyRef:
name: ui
key: GHE_URL
- name: API_URL
valueFrom:
configMapKeyRef:
Expand Down
1 change: 1 addition & 0 deletions ui/image/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ window.config = {
API_URL: '$API_URL',
GH_CLIENT_ID: '$GH_CLIENT_ID',
API_VERSION: '$API_VERSION',
GHE_URL: '$GHE_URL',
};
Expand Down
8 changes: 4 additions & 4 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"mst-persist": "^0.1.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-github-login": "^1.0.3",
"react-ghe-login": "^1.2.0",
"react-hotkeys-hook": "^3.3.1",
"react-markdown": "^5.0.3",
"react-router-dom": "^5.2.0",
Expand Down
3 changes: 2 additions & 1 deletion ui/public/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
window.config = {
API_URL: 'https://api.hub.tekton.dev',
GH_CLIENT_ID: '',
API_VERSION: 'v1'
API_VERSION: 'v1',
GHE_URL: '',
};
1 change: 1 addition & 0 deletions ui/src/config/constant.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ interface API_CONFIG {
API_URL: string;
GH_CLIENT_ID: string;
API_VERSION: string;
GHE_URL: string;
}

export declare global {
Expand Down
1 change: 1 addition & 0 deletions ui/src/config/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ window.config = window.config || {
export const API_URL = window.config.API_URL;
export const GH_CLIENT_ID = window.config.GH_CLIENT_ID;
export const API_VERSION = window.config.API_VERSION;
export const GHE_URL = window.config.GHE_URL;
2 changes: 1 addition & 1 deletion ui/src/containers/Authentication/Authentication.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Card } from '@patternfly/react-core';
import { mount, shallow } from 'enzyme';
import React from 'react';
import renderer from 'react-test-renderer';
import GitHubLogin from 'react-github-login';
import GitHubLogin from 'react-ghe-login';
import Authentication from '.';
import { FakeHub } from '../../api/testutil';
import { createProviderAndStore } from '../../store/root';
Expand Down
5 changes: 3 additions & 2 deletions ui/src/containers/Authentication/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import GitHubLogin from 'react-github-login';
import GitHubLogin from 'react-ghe-login';
import { useHistory } from 'react-router-dom';
import { observer } from 'mobx-react';
import { Card, CardBody, CardHeader, AlertVariant } from '@patternfly/react-core';
import { GH_CLIENT_ID } from '../../config/constants';
import { GHE_URL, GH_CLIENT_ID } from '../../config/constants';
import { useMst } from '../../store/root';
import { AuthCodeProps } from '../../store/auth';
import { Icons } from '../../common/icons';
Expand Down Expand Up @@ -34,6 +34,7 @@ const Authentication: React.FC = observer(() => {
redirectUri=""
onSuccess={onSuccess}
onFailure={user.onFailure}
host={GHE_URL || 'https://github.com'}
/>
</CardBody>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/// <reference types="react-scripts" />
declare module 'react-github-login';
declare module 'react-ghe-login';

0 comments on commit bf57dff

Please sign in to comment.