Skip to content

Commit 84bf7a5

Browse files
committed
Merge branch 'main' of https://github.com/EOS-uiux-Solutions/user-story into tests/setup
2 parents 216bbb8 + b5dd659 commit 84bf7a5

21 files changed

+600
-602
lines changed

.eslintrc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ rules:
1616
prefer-template: 'error'
1717
prefer-destructuring: ['error', { 'object': true, 'array': false }]
1818
object-curly-spacing: [2, 'always']
19-
no-console: 'error'

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
.env.development.local
3131
.env.test.local
3232
.env.production.local
33-
config.json
3433
.vscode/
3534
npm-debug.log*
3635
yarn-debug.log*

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
[![Open Source Love svg2](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
22
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](https://choosealicense.com/licenses/mit/)
3-
[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](https://suse-uiux.gitlab.io/eos-feature-request/)
43

5-
# EOS Feature Request
4+
# User Story
65

7-
# Guideline to develop this site
6+
![](./static/user_story.png)
87

9-
In the project directory, you can run:
8+
# Introduction
109

11-
### Starting up the project
10+
The goal of **User Story** is to design and present a scalable backend infrastructure that delivers a web interface allowing users to request new features and give feedback in an easy and intuitive way. Users can attach files with their story to explain what they want. The admins can then resolve, close and update the status of these stories. Users can interact with other stories via comments and votes. This can also serve as an efficient feedback and response mechanism which is critical for any organization to improve and make progress. Simply, its a **product management tool**.
11+
12+
# How it works
13+
14+
![](./static/user_story_workflow.png)
15+
16+
# Guidelines for development
17+
18+
### Setting up the project
1219

1320
After cloning this repository you will need to install all the dependencies: `npm i`
1421

15-
There are two options to set up the `backend` for this repository:
22+
User Story uses [this repository](https://github.com/EOS-uiux-Solutions/strapi) as its `backend`. There are two ways to set up the `backend`:
1623

17-
1. If you are planning to work only on the UI/UX of `eos-user-story`, then follow along. Skip to point 2 if you need to setup backend as well. For setting up using `docker`, first make sure you have `docker` & `docker-compose` installed ([Install instructions](https://docs.docker.com/engine/install/)). Next, run `docker-compose up` and wait for the server to start on `http://localhost:1337`. Visit [http://localhost:1337/admin/auth/](http://localhost:1337/admin/auth/) and create the admin user for Strapi. Then set the roles and permissions for the api endpoints. That's it, the backend is up and running. Proceed to the next paragraph for further instructions.
24+
- You can use Docker to setup backend by following [these instructions](https://github.com/EOS-uiux-Solutions/strapi#using-docker) If you are planning to work only on the `frontend` of User Story, then follow along.
1825

19-
2. This repository uses [EOS-uiux-Solutions/strapi](https://github.com/EOS-uiux-Solutions/strapi) as the backend Strapi server. Follow [these](https://github.com/EOS-uiux-Solutions/strapi#how-to-install-it) instructions to set it up.
26+
- You can setup `backend` locally by following [these instructions](https://github.com/EOS-uiux-Solutions/strapi#locally).
2027

21-
After setting up the backend, you need to connect the frontend to the Strapi server. To do this, duplicate the file `src/config.json.template` into a new file called `src/config.json` and replace the content of the variable with your server URL.
28+
If you want to work only on the `frontend` then go to `src/config.json` and change the value of `apiURL` to `https://userstory-strapi.herokuapp.com`.
2229

23-
Then run: `npm start` to run the app in the development mode.
30+
Then run: `npm start` to run the app in development mode.
2431

2532
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
2633

27-
The page will reload if you make edits.<br />
28-
You will also see any lint errors in the console.
34+
The page will reload if you make edits. You will also see any lint errors in the console.
2935

3036
### JS and SCSS quality assurance
3137

@@ -38,10 +44,10 @@ To make sure your SCSS is compliant run: `npm run test:scss`
3844

3945
`npm run build`
4046

41-
Builds the app for production to the `build` folder.<br />
42-
It correctly bundles React in production mode and optimizes the build for the best performance.
47+
Builds the app for production to the `build` folder. It correctly bundles React in production mode and optimizes the build for the best performance.
4348

4449
The build is minified and the filenames include the hashes.<br />
50+
4551
Your app is ready to be deployed!
4652

4753
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
@@ -50,7 +56,7 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
5056

5157
### Code contributions
5258

53-
1. Open a new or pick an open issue from the issue list and claim it in the comments. Make sure that the issue is confirmed so you don't work on something that will not be approved to be merged.
59+
1. Open a new issue or pick an open issue from the issue list and claim it in the comments. Make sure that the issue is confirmed so you don't work on something that will not be approved to be merged.
5460
2. Make sure you follow our best practices: [refer to our Wiki](https://gitlab.com/SUSE-UIUX/eos/-/wikis/home). You'll find information on writing code, how to name a branch, how we release, etc.
5561
3. Join Slack [optional] to get in touch with the maintainers if you have any doubt: [join slack](http://slack.eosdesignsystem.com/)
5662
4. Make sure you fork the project, cloning it will not give you the right access to open a PR/MR. [How to open a PR in open source](https://gitlab.com/SUSE-UIUX/eos/-/wikis/Basic-git-instructions-for-beginners)
@@ -59,7 +65,7 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
5965

6066
If you'd like to contribute with design changes, you'll have to do as follows:
6167

62-
1. [Open an issue](https://gitlab.com/SUSE-UIUX/eos-feature-request/-/issues/new)
68+
1. [Open an issue](https://github.com/EOS-uiux-Solutions/user-story/issues/new)
6369
2. Add all relevant information to the issue. Please be as descriptive as possible. Add links to references, images, videos, etc.
6470
3. While working on your design, please make sure you follow our [design guidelines](https://gitlab.com/SUSE-UIUX/eos/wikis/Design-process-and-feedback-gathering).
6571
4. Once the issue is approved by us, it'll be ready to be implemented.

src/assets/scss/components/storiesList.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
cursor: pointer;
4848
flex-grow: 2;
4949
margin: 0px 16px;
50-
width: 50%;
50+
width: 40%;
5151
}
5252

5353
@media only screen and (max-width: 768px) {

src/components/Comments.js

Lines changed: 4 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React, { useState, useEffect, useContext } from 'react'
22
import { Link } from '@reach/router'
33
import Button from './Button'
4-
import axios from 'axios'
5-
import { apiURL } from '../config.json'
64
import { useForm } from 'react-hook-form'
75

86
import Context from '../modules/Context'
97
import FormError from '../components/FormError'
8+
import userStory from '../services/user_story'
109

1110
const Comments = (props) => {
1211
const { storyId } = props
@@ -43,80 +42,14 @@ const Comments = (props) => {
4342

4443
useEffect(() => {
4544
const fetchComments = async () => {
46-
const response = await axios.post(
47-
`${apiURL}/graphql`,
48-
{
49-
query: `
50-
query {
51-
userStory(id: "${storyId}") {
52-
user_story_comments {
53-
id
54-
Comments
55-
user {
56-
id
57-
username
58-
}
59-
createdAt
60-
user_story_comment_replies {
61-
createdAt
62-
Comments
63-
user {
64-
id
65-
username
66-
}
67-
}
68-
}
69-
}
70-
}
71-
`
72-
},
73-
{
74-
withCredentials: true
75-
}
76-
)
45+
const response = await userStory.getComments(storyId)
7746
setComments(response.data.data.userStory.user_story_comments)
7847
}
7948
fetchComments()
8049
}, [storyId, fetchComments])
8150

8251
const addComment = async (data) => {
83-
const response = await axios.post(
84-
`${apiURL}/graphql`,
85-
{
86-
query: `
87-
mutation {
88-
createUserStoryComment(input: {
89-
data: {
90-
Comments: "${data.addComment}"
91-
user_story: "${storyId}"
92-
user: "${id}"
93-
}
94-
}) {
95-
userStoryComment {
96-
id
97-
user {
98-
id
99-
username
100-
}
101-
Comments
102-
createdAt
103-
user_story_comment_replies {
104-
createdAt
105-
Comments
106-
user {
107-
id
108-
username
109-
}
110-
}
111-
}
112-
}
113-
}
114-
`
115-
},
116-
{
117-
withCredentials: true
118-
}
119-
)
52+
const response = await userStory.postComment(data.addComment, storyId, id)
12053
setComments([
12154
...comments,
12255
response.data.data.createUserStoryComment.userStoryComment
@@ -125,27 +58,7 @@ const Comments = (props) => {
12558
}
12659

12760
const addCommentReply = async (data) => {
128-
await axios.post(
129-
`${apiURL}/graphql`,
130-
{
131-
query: `
132-
mutation {
133-
createUserStoryCommentThread (input: {
134-
data: {
135-
Comments: "${data.addReply}"
136-
user_story_comment: "${commentId}"
137-
user: "${id}"
138-
}
139-
}){
140-
userStoryCommentThread {
141-
createdAt
142-
}
143-
}
144-
}
145-
`
146-
},
147-
{ withCredentials: true }
148-
)
61+
await userStory.postCommentReply(data.addReply, commentId, id)
14962
setCommentReply('')
15063
setFetchComments((fetchComments) => !fetchComments)
15164
setRepliesToggled(null)

src/components/Notifications.js

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useState, useEffect, useContext, useRef } from 'react'
2-
import axios from 'axios'
32
import { Link, navigate } from '@reach/router'
4-
import { apiURL } from '../config.json'
53
import Context from '../modules/Context'
4+
import userStory from '../services/user_story'
65

76
const Notifications = () => {
87
const userId = localStorage.getItem('id')
@@ -39,32 +38,7 @@ const Notifications = () => {
3938

4039
useEffect(() => {
4140
const fetchNotifications = async () => {
42-
const response = await axios.post(
43-
`${apiURL}/graphql`,
44-
{
45-
query: `query {
46-
userStoryNotifications (where: {
47-
users: {
48-
id: "${userId}"
49-
}
50-
}){
51-
message
52-
id
53-
users {
54-
id
55-
}
56-
seenBy {
57-
id
58-
}
59-
date
60-
link
61-
}
62-
}`
63-
},
64-
{
65-
withCredentials: true
66-
}
67-
)
41+
const response = await userStory.getNotificationsByUserId(userId)
6842
let unseenNotifications = []
6943
if (response.data.data.userStoryNotifications) {
7044
unseenNotifications = response.data.data.userStoryNotifications
@@ -87,31 +61,7 @@ const Notifications = () => {
8761
const seenBy = notification.seenBy.map((seen) => seen.id)
8862
if (!seenBy.includes(userId)) {
8963
seenBy.push(userId)
90-
await axios.post(
91-
`${apiURL}/graphql`,
92-
{
93-
query: `mutation updateNotifications($seenBy: [ID]){
94-
updateUserStoryNotification(input: {
95-
where: {
96-
id: "${notification.id}"
97-
}
98-
data: {
99-
seenBy: $seenBy
100-
}
101-
}) {
102-
userStoryNotification {
103-
id
104-
}
105-
}
106-
}`,
107-
variables: {
108-
seenBy: seenBy
109-
}
110-
},
111-
{
112-
withCredentials: true
113-
}
114-
)
64+
await userStory.markNotificationAsRead(notification.id, seenBy)
11565
setNotifications([])
11666
setNotificationCount(0)
11767
setNotificationsSeen(false)

src/components/UsersSuggestionDropdown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const UsersSuggestionDropdown = ({
88
isOpen,
99
userTerm,
1010
setUserTerm,
11-
setUserQuery,
11+
setAuthorQuery,
1212
setUsersSuggestionOpen
1313
}) => {
1414
const [usersToSuggest, setUsersToSuggest] = useState([])
@@ -90,7 +90,7 @@ const UsersSuggestionDropdown = ({
9090
key={user.id}
9191
onClick={() => {
9292
setUserTerm(user.username)
93-
setUserQuery(user.username)
93+
setAuthorQuery(user.username)
9494
setUsersSuggestionOpen(false)
9595
}}
9696
className='user-data'

src/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"apiURL": "http://localhost:1337",
3+
"APP_ENV": "dev"
4+
}

0 commit comments

Comments
 (0)