From 348e9198b67145e92810144fdc2806a1e2add69d Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Sun, 10 Oct 2021 21:53:54 +0200 Subject: [PATCH] Add share link to project page --- .../frontend/portfolio/project-page.spec.js | 1 - client/src/components/icons/ShareIcon.vue | 10 ++++ .../components/portfolio/ProjectActions.vue | 55 ++++++++----------- client/src/components/portfolio/ShareLink.vue | 43 +++++++++++++++ client/src/components/ui/WidgetPopover.vue | 8 ++- .../src/graphql/gql/queries/projectQuery.gql | 1 - .../src/mixins/update-project-share-state.js | 32 +++++++++++ client/src/pages/portfolio/project.vue | 50 ++++++++++++----- 8 files changed, 150 insertions(+), 50 deletions(-) create mode 100644 client/src/components/icons/ShareIcon.vue create mode 100644 client/src/components/portfolio/ShareLink.vue create mode 100644 client/src/mixins/update-project-share-state.js diff --git a/client/cypress/integration/frontend/portfolio/project-page.spec.js b/client/cypress/integration/frontend/portfolio/project-page.spec.js index e3e469e3..fefaff9e 100644 --- a/client/cypress/integration/frontend/portfolio/project-page.spec.js +++ b/client/cypress/integration/frontend/portfolio/project-page.spec.js @@ -101,7 +101,6 @@ describe('Project Page', () => { cy.getByDataCy('project-actions').click(); cy.getByDataCy('delete-project').should('exist'); cy.getByDataCy('edit-project').should('exist'); - cy.getByDataCy('share-project').should('exist'); }); describe('Project Entry', () => { diff --git a/client/src/components/icons/ShareIcon.vue b/client/src/components/icons/ShareIcon.vue new file mode 100644 index 00000000..0a04014f --- /dev/null +++ b/client/src/components/icons/ShareIcon.vue @@ -0,0 +1,10 @@ + diff --git a/client/src/components/portfolio/ProjectActions.vue b/client/src/components/portfolio/ProjectActions.vue index a515cd2b..62a16ca2 100644 --- a/client/src/components/portfolio/ProjectActions.vue +++ b/client/src/components/portfolio/ProjectActions.vue @@ -23,14 +23,14 @@ + @click="updateProjectShareState(id, true)">Projekt teilen @@ -42,12 +42,27 @@ import Ellipses from '@/components/icons/Ellipses.vue'; import WidgetPopover from '@/components/ui/WidgetPopover'; import DELETE_PROJECT_MUTATION from '@/graphql/gql/mutations/deleteProject.gql'; -import PROJECT_QUERY from '@/graphql/gql/queries/projectQuery.gql'; import PROJECTS_QUERY from '@/graphql/gql/queries/allProjects.gql'; -import UPDATE_PROJECT_SHARED_STATE_MUTATION from '@/graphql/gql/mutations/updateProjectSharedState.gql'; + +import updateProjectShareState from '@/mixins/update-project-share-state'; export default { - props: ['id', 'final'], + props: { + id: { + type: String, + default: '', + }, + final: { + type: Boolean, + default: false, + }, + shareButtons: { + type: Boolean, + default: true, + }, + }, + + mixins: [updateProjectShareState], components: { Ellipses, @@ -89,32 +104,6 @@ export default { this.$router.push('/portfolio'); }); }, - updateShareState(id, state) { - const project = this; - this.$apollo.mutate({ - mutation: UPDATE_PROJECT_SHARED_STATE_MUTATION, - variables: { - input: { - id: this.id, - shared: state, - }, - }, - update(store, {data: {updateProjectSharedState: {shared, errors}}}) { - if (!errors) { - const query = PROJECT_QUERY; - const variables = { - id: project.id, - }; - const data = store.readQuery({query, variables}); - - if (data) { - data.project.final = shared; - store.writeQuery({query, variables, data}); - } - } - }, - }); - }, }, }; diff --git a/client/src/components/portfolio/ShareLink.vue b/client/src/components/portfolio/ShareLink.vue new file mode 100644 index 00000000..124f1c0b --- /dev/null +++ b/client/src/components/portfolio/ShareLink.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/client/src/components/ui/WidgetPopover.vue b/client/src/components/ui/WidgetPopover.vue index 340a5beb..93e3a1c0 100644 --- a/client/src/components/ui/WidgetPopover.vue +++ b/client/src/components/ui/WidgetPopover.vue @@ -11,7 +11,13 @@