Skip to content

Commit

Permalink
feat: migrated from old ssi to new ssi and added share button feature
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilmhdh committed Oct 19, 2021
1 parent 277c0ca commit 7daf50a
Show file tree
Hide file tree
Showing 13 changed files with 718 additions and 107 deletions.
12 changes: 10 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
REACT_APP_POUCH_DB_URL=
# REACT_APP_POUCH_DB_NAME=

# opc-base
REACT_APP_OPCBASE_API_BASE_PATH=
REACT_APP_OPCBASE_SUBSCRIPTION_BASE_PATH=
REACT_APP_OPCBASE_KEYCLOAK_URL=
REACT_APP_OPCBASE_KEYCLOAK_CLIENT_ID=
REACT_APP_OPCBASE_KEYCLOAK_REALM=

POUCH_DB_ADMIN_TOKEN=
NODE_TLS_REJECT_UNAUTHORIZED=
# REACT_APP_POUCH_DB_NAME=
NODE_TLS_REJECT_UNAUTHORIZED=
641 changes: 640 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "idea-hub",
"version": "0.1.1",
"version": "0.1.2",
"private": true,
"homepage": "/ideas",
"author": {
Expand All @@ -10,6 +10,11 @@
},
"dependencies": {
"@hookform/resolvers": "^2.6.0",
"@one-platform/opc-base": "^1.0.2-beta",
"@one-platform/opc-feedback": "0.0.9-prerelease",
"@one-platform/opc-menu-drawer": "^0.1.1-prerelease",
"@one-platform/opc-nav": "0.0.2-prerelease",
"@one-platform/opc-notification-drawer": "^0.1.1-prerelease",
"@patternfly/react-core": "^4.128.2",
"@patternfly/react-icons": "^4.10.11",
"@patternfly/react-styles": "^4.10.11",
Expand Down
89 changes: 0 additions & 89 deletions public/chrome.html

This file was deleted.

2 changes: 0 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<!-- SSI -->
<!--#include virtual="/ideas/chrome.html" -->
<div id="root"></div>
</body>

Expand Down
17 changes: 17 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@ import { BrowserRouter } from 'react-router-dom';
import { Router } from './routes';
import './App.scss';

import opcBase from '@one-platform/opc-base';
import '@one-platform/opc-base/dist/opc-provider';

opcBase.configure({
apiBasePath: process.env.REACT_APP_OPCBASE_API_BASE_PATH as string,
subscriptionsPath: process.env.REACT_APP_OPCBASE_SUBSCRIPTION_BASE_PATH as string,
keycloakUrl: process.env.REACT_APP_OPCBASE_KEYCLOAK_URL as string,
keycloakClientId: process.env.REACT_APP_OPCBASE_KEYCLOAK_CLIENT_ID as string,
keycloakRealm: process.env.REACT_APP_OPCBASE_KEYCLOAK_REALM as string,
});

const App = (): JSX.Element => {
return (
<BrowserRouter>
<opc-provider>
<opc-nav></opc-nav>
<opc-menu-drawer></opc-menu-drawer>
<opc-notification-drawer></opc-notification-drawer>
<opc-feedback theme="blue"></opc-feedback>
</opc-provider>
<Router />
</BrowserRouter>
);
Expand Down
2 changes: 1 addition & 1 deletion src/containers/CommentsContainer/CommentsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const CommentsContainer = ({ ideaDetails }: Props): JSX.Element => {
.on('change', handleCommentFeedChange)
.on('error', function (err) {
console.error(err);
window.OpNotification.warning({
window.OpNotification.warn({
subject: 'Idea live change registration failed',
body: err.message,
});
Expand Down
4 changes: 4 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
import '@patternfly/react-core/dist/styles/base.css';
import '@one-platform/opc-nav/dist/opc-nav';
import '@one-platform/opc-menu-drawer/dist/opc-menu-drawer';
import '@one-platform/opc-notification-drawer/dist/opc-notification-drawer';
import '@one-platform/opc-feedback/dist/opc-feedback';

import App from './App';

Expand Down
2 changes: 1 addition & 1 deletion src/layouts/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import styles from './appLayout.module.scss';

export const AppLayout: FC = ({ children }) => {
return (
<Page mainContainerId="app-layout-page">
<Page mainContainerId="app-layout-page" className={styles['app-layout']}>
<Container>
<Flex
direction={{ default: 'column' }}
Expand Down
16 changes: 10 additions & 6 deletions src/layouts/AppLayout/appLayout.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.app-layout {
--pf-c-page__main--ZIndex: 0;
}

.banner {
background: rgba(120, 200, 250, 0.1) 0% 0% no-repeat padding-box !important;
border-radius: 8px;
background: rgba(120, 200, 250, 0.1) 0% 0% no-repeat padding-box !important;
border-radius: 8px;
}

.footer {
background: rgba(120, 200, 250, 0.1) 0% 0% no-repeat padding-box !important;
border-radius: 8px;
position: relative;
top: 1rem;
background: rgba(120, 200, 250, 0.1) 0% 0% no-repeat padding-box !important;
border-radius: 8px;
position: relative;
top: 1rem;
}
2 changes: 1 addition & 1 deletion src/pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const HomePage = (): JSX.Element => {
.on('change', onIdeaChangeCB)
.on('error', function (err) {
console.error(err);
window.OpNotification.warning({
window.OpNotification.warn({
subject: 'Idea live change registration failed',
body: err.message,
});
Expand Down
16 changes: 14 additions & 2 deletions src/pages/IdeaDetailPage/IdeaDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const IdeaDetailPage = (): JSX.Element => {
})
.on('error', function (err) {
console.error(err);
window.OpNotification.warning({
window.OpNotification.warn({
subject: 'Comment live change registration failed',
body: err.message,
});
Expand Down Expand Up @@ -99,6 +99,13 @@ export const IdeaDetailPage = (): JSX.Element => {
[idea]
);

const onShareButtonClick = () => {
if (navigator.clipboard) {
navigator.clipboard.writeText(window.location.href);
window.OpNotification.success({ subject: 'Idea link copied to clipboard' });
}
};

if (isIdeaLoading) {
return (
<Bullseye className="pf-u-p-xl">
Expand Down Expand Up @@ -183,7 +190,12 @@ export const IdeaDetailPage = (): JSX.Element => {
hasVoted={idea.hasVoted}
onVoteClick={() => handleVoteClick(idea.hasVoted, idea._id)}
>
<VoteCard.Button variant="link" icon={<ShareIcon />} style={{ color: 'unset' }}>
<VoteCard.Button
variant="link"
icon={<ShareIcon />}
style={{ color: 'unset' }}
onClick={onShareButtonClick}
>
Share
</VoteCard.Button>
</VoteCard>
Expand Down
15 changes: 14 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare module 'pouchdb-debug';

declare namespace JSX {
interface IntrinsicElements {
'opc-header': any;
'opc-footer': any;
'opc-menu-drawer': any;
'opc-notification-drawer': any;
'opc-feedback': any;
'opc-provider': any;
'opc-nav': any;
}
}

interface Window {
OpAuthHelper: OpAuthHelper;
OpNotification: OpNotification;
}

interface OpNotification {
success: (arg0: NotificationArg) => void;
warning: (arg0: NotificationArg) => void;
warn: (arg0: NotificationArg) => void;
danger: (arg0: NotificationArg) => void;
}

Expand Down

0 comments on commit 7daf50a

Please sign in to comment.