-
Notifications
You must be signed in to change notification settings - Fork 2
Exercise7 #9
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
base: main
Are you sure you want to change the base?
Exercise7 #9
Changes from 17 commits
a921023
0bf164b
855cc93
4fffdae
f4ab920
e99c5ea
3558279
731e7da
ee4146b
67d208c
aa8894d
4dc6b84
30c1fe1
fc6da80
f4ab3f9
7486d49
517d5d8
affc585
94b1996
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ git-crypt-key | |
| *.DS_Store | ||
| */node_modules | ||
| */dist | ||
| */.nuxt-storybook | ||
| */storybook-static | ||
|
|
||
|
|
||
| # local env files | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,21 +19,33 @@ $ (webapp) npm install | |
| ### Run unit tests | ||
|
|
||
| ``` | ||
| $ (webapp) npm run test:unit | ||
| $ (webapp) npm run test | ||
| ``` | ||
|
|
||
| ### Compiles and hot-reloads for development | ||
|
|
||
| ``` | ||
| $ (webapp) npm run serve | ||
| $ (webapp) npm run dev | ||
| ``` | ||
|
|
||
| ### Compiles and minifies for production | ||
| ### Compiles and minifies for production (server build) | ||
|
|
||
| ``` | ||
| $ (webapp) npm run build | ||
| ``` | ||
|
|
||
| ### Compiles and minifies for production (static build) | ||
|
|
||
| ``` | ||
| $ (webapp) npm run generate | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running According to your |
||
| ``` | ||
|
|
||
| ### Serve in production | ||
|
|
||
| ``` | ||
| $ (webapp) npm run start | ||
| ``` | ||
|
|
||
|
Comment on lines
32
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks good! Another ⭐
|
||
| ### Run linter | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a small typo further down this file 👇 Missing $ |
||
| ``` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ type Mutation { | |
|
|
||
| extend type Post { | ||
| votes: Int! | ||
| userVote: Int | ||
| } | ||
|
|
||
| input PostInput { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Created by .ignore support plugin (hsz.mobi) | ||
| ### Node template | ||
| # Logs | ||
| /logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # Bower dependency directory (https://bower.io/) | ||
| bower_components | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # TypeScript v1 declaration files | ||
| typings/ | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variables file | ||
| .env | ||
|
|
||
| # parcel-bundler cache (https://parceljs.org/) | ||
| .cache | ||
|
|
||
| # next.js build output | ||
| .next | ||
|
|
||
| # nuxt.js build output | ||
| .nuxt | ||
|
|
||
| # Nuxt generate | ||
| dist | ||
|
|
||
| # vuepress build output | ||
| .vuepress/dist | ||
|
|
||
| # Serverless directories | ||
| .serverless | ||
|
|
||
| # IDE / Editor | ||
| .idea | ||
|
|
||
| # Service worker | ||
| sw.* | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
|
|
||
| # Vim swap files | ||
| *.swp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const { nuxifyStorybook } = require('../.nuxt-storybook/storybook/main.js') | ||
|
|
||
| module.exports = nuxifyStorybook({ | ||
| stories: [ | ||
| '../pages/*.stories.js' | ||
| ], | ||
| addons: [ | ||
| '@storybook/addon-a11y', | ||
| '@storybook/addon-links', | ||
| ] | ||
| }) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, you could have excluded this refactoring from the PR diff. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export * from '~~/.nuxt-storybook/storybook/preview.js' | ||
| export const parameters = { | ||
| actions: { argTypesRegex: '^on[A-Z].*' }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # __typename added to not break mock-apollo-client | ||
| mutation createPost($title: String!) { | ||
| createPost(post: { title: $title }) { | ||
| id | ||
| title | ||
| votes | ||
| userVote | ||
| __typename | ||
| author { | ||
| id | ||
| __typename | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # __typename added to not break mock-apollo-client | ||
| mutation deletePost($id: ID!) { | ||
| deletePost(id: $id) { | ||
| id | ||
| __typename | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| mutation downvotePost($id: ID!) { | ||
| downvotePost(id: $id) { | ||
| id | ||
| votes | ||
| userVote | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| mutation login($email: String!, $password: String!) { | ||
| login(email: $email, password: $password) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| mutation upvotePost($id: ID!) { | ||
| upvotePost(id: $id) { | ||
| id | ||
| votes | ||
| userVote | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| posts { | ||
| id | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Team @Systems-Development-and-Frameworks/lichtow has used GraphQL fragments to reduce duplication: https://graphql.org/learn/queries/#fragments |
||
| title | ||
| votes | ||
| userVote | ||
| author { | ||
| id | ||
| __typename | ||
| } | ||
| __typename | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||
| <template> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great ⭐ ⭐
|
||||||
| <div> | ||||||
| <template v-if="isAuthenticated"> | ||||||
| <span>You're logged in!</span> | ||||||
| <nuxt-link to="/">Return to home page</nuxt-link> | ||||||
| or | ||||||
| <a href="#" @click.prevent="$router.go(-1)">return to the previously browsed page</a> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to redirect authenticated users from |
||||||
| </template> | ||||||
| <form v-else @submit.prevent="onSubmit" id="form-login"> | ||||||
| <table> | ||||||
| <tbody> | ||||||
| <tr> | ||||||
| <td> | ||||||
| <label for="input-email"> E-Mail </label> | ||||||
| </td> | ||||||
| <td> | ||||||
| <input id="input-email" type="text" v-model.trim="email" placeholder="Enter your e-mail address.." | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| required/> | ||||||
| </td> | ||||||
| </tr> | ||||||
| <tr> | ||||||
| <td> | ||||||
| <label for="input-password"> Password </label> | ||||||
| </td> | ||||||
| <td> | ||||||
| <input id="input-password" type="password" v-model="password" placeholder="Enter your password.." | ||||||
| required/> | ||||||
| </td> | ||||||
| </tr> | ||||||
| <tr> | ||||||
| <td colspan="2"> | ||||||
| <input type="submit" value="Login" :disabled="!(email.length && password.length)"/> | ||||||
| </td> | ||||||
| </tr> | ||||||
| <tr v-if="submitting"> | ||||||
| <td colspan="2"> | ||||||
| Logging in... | ||||||
| </td> | ||||||
| </tr> | ||||||
| <tr v-if="error"> | ||||||
| <td colspan="2"> | ||||||
| <span id="login-error-message">{{ error }}</span> | ||||||
| </td> | ||||||
| </tr> | ||||||
| </tbody> | ||||||
| </table> | ||||||
| </form> | ||||||
| </div> | ||||||
| </template> | ||||||
|
|
||||||
| <script> | ||||||
| import login from '../apollo/mutations/login.gql' | ||||||
| import { mapActions, mapGetters } from 'vuex' | ||||||
| import { ApolloError } from '@apollo/client' | ||||||
| export default { | ||||||
| data () { | ||||||
| return { | ||||||
| submitting: false, | ||||||
| error: null, | ||||||
| email: '', | ||||||
| password: '', | ||||||
| } | ||||||
| }, | ||||||
| computed: { | ||||||
| ...mapGetters({ | ||||||
| isAuthenticated: 'auth/isAuthenticated' | ||||||
| }) | ||||||
| }, | ||||||
| methods: { | ||||||
| ...mapActions({ | ||||||
| setToken: 'auth/setToken' | ||||||
| }), | ||||||
| async onSubmit () { | ||||||
| this.error = null | ||||||
| this.submitting = true | ||||||
| try { | ||||||
| const res = await this.$apollo.mutate({ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| mutation: login, | ||||||
| variables: { | ||||||
| email: this.email, | ||||||
| password: this.password | ||||||
| } | ||||||
| }).then(({ data }) => data && data.login) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't mix |
||||||
| await this.setToken(res) | ||||||
| await this.$apolloHelpers.onLogin(res) | ||||||
| if (this.$route.params.returnPath) { | ||||||
| await this.$router.push({ | ||||||
| path: this.$route.params.returnPath | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer |
||||||
| }) | ||||||
| } | ||||||
| } catch (e) { | ||||||
| if (e instanceof ApolloError) { | ||||||
| this.error = e.graphQLErrors.join(",\n") | ||||||
| } else { | ||||||
| this.error = e | ||||||
| } | ||||||
| } finally { | ||||||
| this.submitting = false | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| </script> | ||||||
|
|
||||||
| <style> | ||||||
| form#form-login > table { | ||||||
| margin: 0 auto; | ||||||
| } | ||||||
| </style> | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about testing all branches?