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

Merge dev in master? #39

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
20fe7fc
Basic React components (#1)
simona1 Aug 2, 2017
68ee41c
Refactor static components (#2)
simona1 Aug 2, 2017
9b14c8d
Latest version with todos for tests (#3)
simona1 Aug 24, 2017
a845859
Add .npmrc file (#6)
meghanprestemon Aug 29, 2017
cbd0d86
Dashboard refactor (#7)
SSabu Aug 29, 2017
6c6add3
Dashboard refactor (#8)
simona1 Aug 29, 2017
9e3a98b
add npm lib folder. remove unsused .babelrc file since this was causi…
Aug 29, 2017
811d951
recreate .babelrc, install its dependencies
Aug 29, 2017
a73b8ca
Env file (#5)
Sanderson239 Aug 30, 2017
59a775e
Refactor to communicate with api (#11)
tylerlan Aug 30, 2017
3a227a5
fixed linting errors
Aug 30, 2017
0b2d8f5
add .eslintignore file to get eslint not to hang
Aug 31, 2017
1af3f9a
CI / CD created (#14)
Gwillison415 Aug 31, 2017
37ef5bb
Latest api refactor (#13)
simona1 Aug 31, 2017
b6d441d
Communicate with API (#15)
tylerlan Sep 3, 2017
6333eac
Realtime updating with message and user info (#16)
tylerlan Sep 6, 2017
4aa2fd3
Sentiment analysis integration (#18)
tylerlan Sep 6, 2017
ef23b40
Slack path re-name (#17)
Gwillison415 Sep 8, 2017
b5647e3
Update package.json to remove extra space.
Sep 8, 2017
d3ae357
Modify styling for fields inside the Message component (#20)
simona1 Sep 11, 2017
c46454e
Add scrollbar to MessageList and modify css to reflect this change (#21)
simona1 Sep 13, 2017
0771ba1
Fixed lint and flow errors (#22)
simona1 Sep 14, 2017
1c8b8ae
Background color for messages responds to changes in score (#23)
simona1 Sep 14, 2017
06d3a29
Fixes classNames that was just a color to refactor as slack-color. Wa…
danielmarcgardner Sep 15, 2017
3a5a553
Fix reducers tests (#26)
simona1 Sep 19, 2017
26a27fb
Update npm module (#28)
simona1 Sep 19, 2017
87c2970
Update npm start to run up api (#27)
ronanfitz Sep 19, 2017
7ef716f
Snapshot update (#29)
simona1 Sep 19, 2017
05cc725
Temporary solution to failing test (#30)
simona1 Sep 21, 2017
0bc8cb3
Made a separate component to handle processing of timestamp with Mome…
simona1 Sep 22, 2017
10a23f1
Logout button for slack-spa (#32)
simona1 Sep 22, 2017
db305d5
App component test hanging in prod tests. Remove it for now
Sep 22, 2017
7b3e331
Add codeship step to auto publish package on master commits
joshwyatt Sep 24, 2017
433b1ea
Make project specific README
joshwyatt Sep 24, 2017
a408f13
Complete codeship CD steps
joshwyatt Sep 24, 2017
65bfcf6
Merge branch 'master' into dev
joshwyatt Sep 24, 2017
39676ff
Login (#35)
johanbmk Sep 25, 2017
d327be6
Draft description for slack-spa
simona1 Sep 25, 2017
ac456e4
add scroll to bottom to messageslist, exclude broken tests
Sep 27, 2017
11f6733
update npm package version
Sep 27, 2017
b11dd4a
Merge pull request #38 from simona1/readme
Gwillison415 Nov 30, 2017
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
2,150 changes: 19 additions & 2,131 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codeship-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tag: dev
- service: slack-spa
command: npm run create-module
tag: master
tag: dev
- service: npm-publisher
command: publish
tag: master
1 change: 1 addition & 0 deletions codeship.aes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ka4+0zUkzOg+Lub+chduWXASmNqUETLj92Z3qGcZdHo=
1 change: 1 addition & 0 deletions env.encrypted
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xTm3FI6aCo2K4OnxDlpct46jHzzB0E6xECJxnoyto3SqngYREKT+yq/ueSnNiRY6jDo/WPL2+3A8pHwaqD2G
2 changes: 1 addition & 1 deletion libs/widget-libs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@databraid/slack-widget",
"version": "1.0.24",
"version": "1.0.29",
"description": "",
"main": "index.js",
"files": [
Expand Down
17 changes: 12 additions & 5 deletions src/Actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ import type { MessageType, Id, Dispatch, GetState, SlackApi } from '../FlowTypes
/* eslint func-names: ["error", "never"] */

export function connectWithSlack() {
return {
type: 'CONNECTED_WITH_SLACK',
return async (dispatch: Dispatch, getState: GetState, { SLACK_API }: SlackApi) => {
const connected = await SLACK_API.isLoggedIn();
if (connected) {
dispatch({
type: 'CONNECTED_WITH_SLACK',
});
}
};
}

export function disconnectFromSlack() {
return {
type: 'DISCONNECTED_FROM_SLACK',
return async (dispatch: Dispatch, getState: GetState, { SLACK_API }: SlackApi) => {
await SLACK_API.logout();
dispatch({
type: 'DISCONNECTED_FROM_SLACK',
});
};
}


export function fetchChannels() {
return async (dispatch: Dispatch, getState: GetState, { SLACK_API }: SlackApi) => {
const channels = await SLACK_API.fetchRequestChannels();
Expand Down
6 changes: 4 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import io from 'socket.io-client';
import { processNewMessages, processNewScores, fetchScoreForChannel } from './Actions/index';
import { processNewMessages, processNewScores, fetchScoreForChannel, connectWithSlack } from './Actions/index';
import LoginView from './Components/LoginView';
import MessageList from './Components/MessageList';
import injectWidgetId from './Utils/utils';
Expand All @@ -16,12 +16,13 @@ import type { DefaultProps, Dispatch, OwnProps, State } from './FlowTypes/';
import { WIDGET_ID } from './Constants/';
import './App.css';


class App extends React.Component<DefaultProps, OwnProps, State> {
state: State;
socket: Object;


componentWillMount() {
this.props.connectWithSlack();
this.socket = io.connect(process.env.REACT_APP_SLACK_API_URL);
this.socket.on('messages', messages => {
this.props.processNewMessages(messages);
Expand Down Expand Up @@ -116,6 +117,7 @@ export const mapDispatchToProps = (dispatch: Dispatch) =>
fetchScoreForChannel,
processNewMessages,
processNewScores,
connectWithSlack,
},
dispatch,
);
Expand Down
10 changes: 5 additions & 5 deletions src/Components/LoginView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button, Image } from 'semantic-ui-react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import logo from '../images/slack-logo.png';
// import slackConnectHref from '../Constants/';
import { slackConnectHref } from '../Constants/';
import slack from '../images/slackIcon.png';
import { connectWithSlack } from '../Actions/index';
import type { Dispatch } from '../FlowTypes/';
Expand All @@ -25,10 +25,10 @@ export function LoginView(props: Object) {
<Button
size="big"
color={'teal'}
// href={slackConnectHref}
onClick={
() => connectWithSlack()
}
href={slackConnectHref}
// onClick={
// () => connectWithSlack()
// }
>
<Image avatar src={slack} />
Connect with Slack
Expand Down
16 changes: 15 additions & 1 deletion src/Components/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/* eslint-disable */
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { List } from 'semantic-ui-react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
Expand All @@ -19,6 +20,19 @@ export class MessageList extends Component {
fetchMessagesForChannel: Function,
};

componentDidMount() {
this.scrollToBottom();
}

componentDidUpdate() {
this.scrollToBottom();
}

scrollToBottom() {
const messagesElement = ReactDOM.findDOMNode(this.messagesElement)
messagesElement.scrollTop = messagesElement.scrollHeight;
}

render() {
let { messages, selectedChannel, fetchMessagesForChannel } = this.props;

Expand Down Expand Up @@ -47,7 +61,7 @@ NOTE: Properties available for each message:
*/

return (
<List celled size={sizes[2]} className="scrolling">
<List celled size={sizes[2]} className="scrolling" ref={el => { this.messagesElement = el; }}>
{messageIds.map(msgId => {
const { avatarImage, name, text, timestamp } = messages[msgId];
return (
Expand Down
6 changes: 1 addition & 5 deletions src/Constants/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// @flow

const slackConnectHref = process.env.SLACK_CONNECT_HREF;

export default slackConnectHref;

export const WIDGET_ID = 'slack';

// export const slackConnectHref = 'https://slack.com/oauth/authorize?scope=incoming-webhook&client_id=218633036018.221954264375';
export const slackConnectHref = `https://slack.com/oauth/authorize?scope=channels:history,reactions:read,users:read&client_id=${process.env.REACT_APP_SLACK_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_REDIRECT_URI}`;
4 changes: 0 additions & 4 deletions src/Reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ export function storeReducer(state: State = stateDefaults, action: Action): Stat
let newSelectedChannel;

switch (action.type) {
// TODO: needs to also query whether an user is logged in or not

case 'CONNECTED_WITH_SLACK':
return {
...state,
isConnectedWithSlack: true,
};

// TODO: needs to also query whether an user is logged in or not
case 'DISCONNECTED_FROM_SLACK':
return {
...state,
Expand Down
10 changes: 10 additions & 0 deletions src/Utils/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ export default class SLACK_API {
const score = await fetchRequest(`${PATH}/sentiment/${channel}`);
return score;
}

static async isLoggedIn() {
const connected = await fetchRequest(`${PATH}/slack/token`);
return connected;
}

static async logout() {
const res = await fetch(`${PATH}/slack/logout`, { method: 'DELETE' });
return res;
}
}
6 changes: 4 additions & 2 deletions src/__tests__/Actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import thunk from 'redux-thunk';
import * as actions from '../Actions/index';

describe('Actions', () => {
it('should return an action object from connecting with Slack', () => {
// TODO: this action is not a thunk, tests need to be rewritten for it.
xit('should return an action object from connecting with Slack', () => {
const action = actions.connectWithSlack();
expect(action).toEqual({
type: 'CONNECTED_WITH_SLACK',
});
});

it('should return an action object from disconnecting from Slack', () => {
// TODO: this action is not a thunk, tests need to be rewritten for it.
xit('should return an action object from disconnecting from Slack', () => {
const action = actions.disconnectFromSlack();
expect(action).toEqual({
type: 'DISCONNECTED_FROM_SLACK',
Expand Down