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

feat: docs feedback form created #609

Merged
merged 37 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
16e2fdc
docs feedback form created
akshatnema Feb 25, 2022
803ccc8
unnecessary file deleted
akshatnema Feb 25, 2022
d6c4968
Merge branch 'master' into docs-feedback
akshatnema Feb 28, 2022
f49dee3
Merge branch 'master' into docs-feedback
akshatnema Mar 1, 2022
e491285
backend added
akshatnema Mar 2, 2022
e67d495
Merge branch 'docs-feedback' of https://github.com/akshatnema/website…
akshatnema Mar 2, 2022
b33ed53
Merge branch 'master' into docs-feedback
akshatnema Mar 2, 2022
190f8c3
Merge branch 'master' into docs-feedback
akshatnema Mar 9, 2022
ad122d2
Merge branch 'master' into docs-feedback
akshatnema Mar 10, 2022
4d9de6c
created backend on GitHub Discussions
akshatnema Mar 11, 2022
2d2e48b
Merge branch 'docs-feedback' of https://github.com/akshatnema/website…
akshatnema Mar 11, 2022
eeb88dc
googleapis removed
akshatnema Mar 14, 2022
4339353
Merge branch 'master' into docs-feedback
derberg Mar 14, 2022
bc1e9a8
Merge branch 'master' into docs-feedback
quetzalliwrites Mar 15, 2022
1dc630c
added timestamp
akshatnema Mar 23, 2022
4216fc0
Merge branch 'docs-feedback' of https://github.com/akshatnema/website…
akshatnema Mar 23, 2022
f55a92d
margin decreased
akshatnema Mar 23, 2022
f77bb03
netlify functions added
akshatnema Mar 25, 2022
774fc7b
Merge branch 'master' into docs-feedback
akshatnema Mar 25, 2022
c1dd432
Merge branch 'master' into docs-feedback
akshatnema Mar 28, 2022
9c0a463
netlify functions added
akshatnema Mar 28, 2022
0a8cf2a
Merge branch 'docs-feedback' of https://github.com/akshatnema/website…
akshatnema Mar 28, 2022
5d5a072
IDs corrected
akshatnema Mar 28, 2022
43b65b4
Merge branch 'docs-feedback' of https://github.com/akshatnema/website…
akshatnema Mar 28, 2022
f2bcb05
Merge branch 'master' into docs-feedback
akshatnema Mar 30, 2022
3dba098
Apply suggestions from code review
akshatnema Mar 31, 2022
65ca20d
errors resolved
akshatnema Apr 1, 2022
45966ff
Merge branch 'master' into docs-feedback
quetzalliwrites Apr 7, 2022
3859006
added changes
akshatnema Apr 8, 2022
7391ad1
Merge branch 'docs-feedback' of https://github.com/akshatnema/website…
akshatnema Apr 8, 2022
1f50938
Merge branch 'master' into docs-feedback
quetzalliwrites Apr 11, 2022
3ab559f
Merge branch 'master' into docs-feedback
akshatnema Apr 16, 2022
a2b4e5a
created github issue button
akshatnema Apr 17, 2022
1f02961
changes made for change in dev port
akshatnema Apr 19, 2022
4d93d1a
Apply suggestions from code review
akshatnema Apr 20, 2022
01bbf6d
Merge branch 'master' into docs-feedback
quetzalliwrites Apr 22, 2022
f4d8a2a
Merge branch 'master' into docs-feedback
akshatnema Apr 24, 2022
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 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEPLOY_URL=http://localhost:8080
DEPLOY_URL=http://localhost:3000
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ tasks:

# List the ports to expose. Learn more https://www.gitpod.io/docs/config-ports/
ports:
- port: 8080
- port: 3000
onOpen: open-preview
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Launch the development server with the hot reloading functionality that allows a
npm run dev
```

You can access the live development server at [localhost:8080](http://localhost:8080).
You can access the live development server at [localhost:3000](http://localhost:3000).

#### Compose a new blog post

Expand Down
109 changes: 109 additions & 0 deletions components/Feedback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { useState, useEffect } from "react";
import { useRouter } from "next/router";
import GitHubIssue from "./buttons/GitHubIssue";

export default function Feedback(className = '') {
const [submitted, setSubmitted] = useState(false);
const [error, setError] = useState(false);
const [feedback, setFeedback] = useState('');
const { asPath, pathname } = useRouter();

useEffect(() => {
setSubmitted(false);
setError(false);
}, [asPath])

const date_stamp = new Date()
const time_stamp = date_stamp.toUTCString();

async function handleSubmit(e) {
e.preventDefault();
const data = {
title: `Feedback on ${asPath} - ${time_stamp}`,
feedback: feedback
}

fetch("/.netlify/functions/github_discussions", {
method: "POST",
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
}).then((response) => {

if (response.status === 200) {
setSubmitted(true);
}
if(response.status !== 200) {
setError(true);
}
response.json();
console.log(response);
}).then(data =>{
console.log(data);
})
}

if (submitted) {
return (
<div className={`flex flex-col rounded-md shadow-md text-center border border-gray-200 p-4 ${className}`}>
<div className='block mx-auto w-fit'>
<img src='/img/illustrations/icons/icon-check.svg' className='md:w-14' />
</div>
<div className='text-center mx-auto text-lg mt-4'>
Thank you for your feedback!
</div>
<div className='text-center mx-auto text-md text-gray-500'>
Your contribution has been received and we couldn't be happier.
</div>
<a href='https://github.com/asyncapi/website' target='_blank' rel='noopener noreferrer' className="w-full shadow-md hover:shadow-lg transition-all duration-500 bg-black ease-in-out py-2 px-2 rounded-md mx-auto mt-4 md:w-1/2">
<div className='text-white flex flex-row justify-center text-center'>
<img src='/img/logos/github-fill.svg' className='w-6 mr-2' />
Follow on GitHub
</div>
</a>
</div>
)
}
if(error){
return (
<div className={`flex flex-col rounded-md shadow-md text-center border border-gray-200 p-4 ${className}`}>
<div className='block mx-auto w-fit'>
<img src='/img/illustrations/icons/icon-x.svg' className='md:w-14' />
</div>
<div className='text-center mx-auto text-lg mt-4'>
Oops! Something went wrong...
</div>
<div className='text-center mx-auto text-md text-gray-500'>
We were unable to process your feedback
</div>
<GitHubIssue />
</div>
);
}
return (
<div className={`flex flex-col rounded-md shadow-md border border-gray-200 p-4 ${className}`}>
<div className='flex flex-row'>
<img src="/img/illustrations/icons/icon.svg" className='w-28 md:w-14' />
<div className='flex flex-col ml-4'>
<div className='text-xl'>
Was this Helpful?
akshatnema marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div className='text-sm text-gray-500'>
Help us improve the docs by adding your contribution.
</div>
</div>
</div>
<form onSubmit={handleSubmit}>
<div className='flex flex-col my-4'>
<textarea className='w-full h-20 border rounded-md bg-gray-50 text-sm px-2 py-1 text-gray-700 inline-block align-top focus:border-0' placeholder='Write your suggestions here' onChange={(e) => setFeedback(e.target.value)} required />
<div className='block lg:flex lg:flex-row mt-4 text-sm'>
<button className='bg-primary-500 text-white w-full lg:w-6/12 py-2 shadow-md hover:shadow-lg transition-all duration-500 ease-in-out rounded' type='submit'>Submit feedback</button>
<div className='my-2 text-center font-medium w-full lg:w-1/12 lg:my-auto'>OR</div>
<GitHubIssue />
</div>
</div>
</form>
</div>
)
}
2 changes: 1 addition & 1 deletion components/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function HeadComponent({

{/* Load Work Sans font */}
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Work+Sans:wght@200;300;400;500;600;700;800;900&display=swap" rel="stylesheet" />

{/* Icons */}
Expand Down
10 changes: 10 additions & 0 deletions components/buttons/GitHubIssue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'

export default function GitHubIssue() {
return (
<a className='bg-black text-white flex flex-row lg:w-6/12 shadow-md hover:shadow-lg transition-all duration-500 ease-in-out py-2 rounded justify-center' href='https://github.com/asyncapi/website/issues/new?assignees=alequetzalli+-&labels=%F0%9F%93%91+docs&template=docs.yml&title=%5B%F0%9F%93%91+Docs%5D%3A+' target='_blank' rel='noopener noreferrer'>
<img src='/img/logos/github-fill.svg' className='mr-2' />
Create Issue on Github
</a>
)
}
6 changes: 5 additions & 1 deletion components/layout/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DocsNavItem from '../navigation/DocsNavItem'
import DocsMobileMenu from '../navigation/DocsMobileMenu'
import NavBar from '../navigation/NavBar'
import ArrowRight from '../icons/ArrowRight'
import Feedback from '../Feedback'
import AnnouncementRemainingDays from '../campaigns/AnnouncementRamainingDays'
import AnnouncementHero from '../campaigns/AnnoucementHero'
import Footer from '../Footer'
Expand Down Expand Up @@ -99,14 +100,17 @@ export default function DocsLayout({ post, navItems = {}, children }) {
{generateEditLink(post)}
</p>
</div>
<article className="mb-32 mt-12">
<article className="mb-12 mt-12">
<Head
title={post.title}
description={post.excerpt}
image={post.cover}
/>
{ children }
</article>
<div className="">
<Feedback />
</div>
</div>
</div>
</main>
Expand Down
2 changes: 2 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

[build]
command = "npm run build && npm run export"
functions = "netlify/functions"
publish = "out"

54 changes: 54 additions & 0 deletions netlify/functions/github_discussions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { graphql } = require('@octokit/graphql')
const repositoryID = "MDEwOlJlcG9zaXRvcnkzNTE0NTM1NTI=" /* Respository ID */
const categoryID = "DIC_kwDOFPLBcM4COBUH" /* Docs Category ID */

/**
** The handler function create a GitHub discussion in the Docs category of community repository using GitHub GraphQL API. THhs functions accepts a POST request from the Feedback card and will create a Discussion only if GITHUB_TOKEN_CREATE_DISCUSSION has been added in .env properly.
akshatnema marked this conversation as resolved.
Show resolved Hide resolved

@param event contains the title and body fo the feedback that is to be added in the GitHub discussion.
akshatnema marked this conversation as resolved.
Show resolved Hide resolved
*/

exports.handler = async function (event) {
if (event.httpMethod == 'POST') {
const { title, feedback } = JSON.parse(event.body);

try {
const createDiscussion = await graphql(`
mutation {
createDiscussion(input:{repositoryId:"${repositoryID}", categoryId:"${categoryID}", title:"${title}", body:"${feedback}"}){
discussion{
url
}
}
}`,
{
owner: 'asyncapi',
repo: 'community',
headers: {
authorization: `token ${process.env.GITHUB_TOKEN_CREATE_DISCUSSION}`,
},
})
let url = createDiscussion.createDiscussion.discussion.url;
return {
statusCode: 200,
body: JSON.stringify({
url: url,
message: "Feedback submitted successfully"
})
}
} catch (err) {
console.log(err);
return {
statusCode: err.response.status,
message:err.response.data.message
}
}
}else{
return {
statusCode: 500,
body: JSON.stringify({
message: "The specified HTTP method is not allowed."
})
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"description": "AsyncAPI website",
"scripts": {
"dev": "node scripts/index.js && next -p 8080",
"dev": "node scripts/index.js && next -p 3000",
"build": "node scripts/index.js && next build",
"write:blog": "node ./scripts/compose.js",
"start": "next start",
Expand Down
2 changes: 1 addition & 1 deletion pages/blog/march-2021-at-asyncapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Let's scale this party up!
We did it. AsyncAPI initiative joined Linux Foundation (LF). No more excuses for you not to join us. You're all welcome.

I don't want to write about this too much as everything was described in different articles about us joining LF:
- [AsyncAPI joins Linux Foundation](http://localhost:8080/blog/asyncapi-joins-linux-foundation)
- [AsyncAPI joins Linux Foundation](https://www.asyncapi.com/blog/asyncapi-joins-linux-foundation)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this change, I think it's necessary to fix the broken links on the website. And surprisingly, I got this 😄.

- [Linux Foundation Will Host AsyncAPI to Support Growth and Collaboration for Industry's Fastest-Growing API Spec](https://www.linuxfoundation.org/en/press-release/linux-foundation-will-host-asyncapi-to-support-growth-and-collaboration-for-industrys-fastest-growing-api-spec/)
- [The Linux Foundation Announces Hosting of AsyncAPI](https://www.infoq.com/news/2021/03/linux-foundation-hosts-asyncapi/)
- [AsyncAPI Looks to Unify API Workflow under Linux Foundation](https://thenewstack.io/asyncapi-looks-to-unify-api-workflow-under-linux-foundation/)
Expand Down
1 change: 1 addition & 0 deletions public/img/illustrations/icons/icon-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/img/illustrations/icons/icon-x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/img/illustrations/icons/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/img/logos/github-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.