Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block #6

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@
// "@babel/preset-env"
"@babel/preset-react"
// "react-app"
],
"plugins": [
// "@babel/plugin-proposal-class-properties",
"react-hot-loader/babel"
]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/build

# misc
.env
.DS_Store
.env.local
.env.development.local
Expand All @@ -19,3 +20,4 @@

# secrets
secrets.*.js
.env
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"name": "planes-in-the-sky",
"name": "planes-dashboard",
"version": "4.3.5",
"description": "A chrome extension boilerplate built with React 17, Webpack 5, and Webpack Dev Server 4",
"description": "A Dashboard for all things planes",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/lxieyang/chrome-extension-boilerplate-react.git"
"url": "https://github.com/teamplanes/planes-dashboard.git"
},
"scripts": {
"build": "node utils/build.js",
"start": "node utils/webserver.js",
"prettier": "prettier --write '**/*.{js,jsx,ts,tsx,json,css,scss,md}'"
},
"dependencies": {
"@chakra-ui/react": "1.8.9",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@hot-loader/react-dom": "^17.0.2",
"framer-motion": "6.2.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-loader": "^4.13.0"
"@chakra-ui/icons": "^2.0.13",
"@chakra-ui/react": "^2.4.2",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"framer-motion": "^7.6.15",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/core": "^7.17.0",
Expand All @@ -35,7 +34,8 @@
"babel-preset-react-app": "^10.0.1yarn star",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^6.6.0",
"css-loader": "^6.7.2",
"dotenv-webpack": "^8.0.1",
"eslint": "^8.8.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-flowtype": "^8.0.3",
Expand All @@ -53,8 +53,8 @@
"terser-webpack-plugin": "^5.3.1",
"ts-loader": "^9.2.6",
"typescript": "^4.5.5",
"webpack": "^5.68.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1"
}
}
}
Binary file added src/assets/img/jira.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions src/assets/img/logo.svg

This file was deleted.

Binary file added src/assets/img/plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions src/containers/Greetings/Greetings.jsx

This file was deleted.

27 changes: 9 additions & 18 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"manifest_version": 3,
"name": "Takeoff",
"name": "Planes Dashboard",
"description": "A chrome extension that will help you to takeoff from your current tab to a new tab.",
"options_page": "options.html",
"background": {
"service_worker": "background.bundle.js"
},

"action": {
"default_popup": "popup.html",
"default_icon": "icon-34.png"
},
"permissions": ["identity", "identity.email"],
"chrome_url_overrides": {
"newtab": "newtab.html"
},
Expand All @@ -18,28 +20,17 @@
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*",
"<all_urls>"
],
"js": [
"contentScript.bundle.js"
],
"css": [
"content.styles.css"
]
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
"js": ["contentScript.bundle.js"],
"css": ["content.styles.css"]
}
],
"devtools_page": "devtools.html",
"web_accessible_resources": [
{
"resources": [
"content.styles.css",
"icon-128.png",
"icon-34.png"
],
"resources": ["content.styles.css", "icon-128.png", "icon-34.png"],
"matches": []
}
]
],
"permissions": ["identity"]
}
13 changes: 13 additions & 0 deletions src/pages/Background/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
console.log('This is the background page.');
console.log('Put the background scripts here.');

const userEmail = chrome.identity.getProfileUserInfo(function (info) {
console.log('info', info);
return info.email;
});

chrome.extension.onMessage.addListener(function (
request,
sender,
sendResponse
) {
sendResponse({ email: userEmail });
});
8 changes: 8 additions & 0 deletions src/pages/Content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ console.log('Content script works!');
console.log('Must reload extension for modifications to take effect.');

printLine("Using the 'printLine' function from the Print Module");

var loggedInUser;

chrome.extension.sendMessage({}, function (response) {
loggedInUser = response.email;
});

console.log('Got user:', loggedInUser);
38 changes: 0 additions & 38 deletions src/pages/Newtab/Newtab.css

This file was deleted.

49 changes: 26 additions & 23 deletions src/pages/Newtab/Newtab.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import React from 'react';
import logo from '../../assets/img/logo.svg';
import './Newtab.css';
import './Newtab.scss';
import { Text } from '@chakra-ui/react'
import { Greeting } from './components/greeting';
import { Announcements } from './components/announcements';
import { QuickAccessTools } from './components/quick-access-tools';
import { Box, Flex, Text } from '@chakra-ui/react';
import { Section } from './components/section';

const Newtab = () => {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<Text fontSize='20px' color='white'>
Edit <code>src/pages/Newtab/Newtab.js</code> and save to reload.
</Text>
<Text fontSize='50px' color='tomato'>
PLANES
</Text>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React!
</a>
</header>
</div>
<Box>
{/* greeting */}
<Greeting />
<Flex mx={8} gap={10}>
<Flex flexDir="column" flex={3} gap={10}>
<Announcements />
{/* Slack Channel announcements */}
{/* Runn timesheet notifications */}
{/* Quick access links */}
<QuickAccessTools />
</Flex>
<Flex flex={1}>
<Section title="Runn">
<Box py={4} px={6}>
<Text>Notifications here</Text>
</Box>
</Section>
</Flex>
</Flex>
</Box>
);
};

Expand Down
10 changes: 0 additions & 10 deletions src/pages/Newtab/Newtab.scss

This file was deleted.

93 changes: 93 additions & 0 deletions src/pages/Newtab/components/announcements.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { useEffect, useState } from 'react';
import {
Text,
Image,
Heading,
CardBody,
Flex,
Box
} from '@chakra-ui/react';
import { getSlackFetch } from '../utils/getSlackFetch';
import { Section } from './section';

const getMessages = async () => {
try {
const conversationHistory = await getSlackFetch(
'/conversations.history?channel=C04CX09AFFS'
);

const messages = conversationHistory.messages.filter(
(message) => message.subtype !== 'channel_join'
);

// Print results
console.log(
messages.length + ' messages found in planes-dashboard channel'
);
return messages[0];
} catch (error) {
console.error(error);
}
};

const getUser = async (userId) => {
try {
const user = await getSlackFetch(`/users.profile.get?user=${userId}`);

// Print results
console.log('user with id: ' + userId + JSON.stringify(user));
return user.profile;
} catch (error) {
console.error(error);
}
};

const getPermaLink = async (message) => {
try {
const response = await getSlackFetch(
`/chat.getPermalink?channel=C04CX09AFFS&message_ts=${message.ts}`
);
return response.permaLink;
} catch (error) {
console.error(error);
}
};

export const Announcements = () => {
// WebClient instantiates a client that can call API methods
// When using Bolt, you can use either `app.client` or the `client` passed to listeners.
const [message, setMessage] = useState('');
const [user, setUser] = useState('');
const [permaLink, setPermalink] = useState('');
const test = async () => {
const message = await getMessages();
const user = await getUser(message.user);
const link = await getPermaLink(message);
setPermalink(link);
setUser(user);
setMessage(message.text);
};

useEffect(() => {
test();
}, []);
const name = user.first_name + ' ' + user.last_name;

return (
<Section title="Announcements">
<Flex direction="row">
<Image
objectFit="cover"
maxW={{ base: '100%', sm: '200px' }}
src={user.image_192}
alt="User Avatar"
/>
<CardBody>
<Heading size="md">{name}</Heading>
<Box mt={2} />
<Text>{message}</Text>
</CardBody>
</Flex>
</Section>
);
};
Loading