Skip to content

Commit 658c105

Browse files
committed
feat: delete page
1 parent faa1f38 commit 658c105

24 files changed

+2123
-2952
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ npm-debug.log*
2929
/repo
3030
/data
3131
/uploads
32+
/content
3233
*.sqlite
3334

3435
# IDE exclude

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [2.0.0-beta.12] - 2018-01-27
66
### Added
77
- Added Patreon link in Contribute admin page
8-
- Added Theme Code Injection feature
8+
- Added Theme Code Injection functionality
99
- Added Theme CSS Injection code minification
10+
- Added Page Delete functionality
1011

1112
### Fixed
1213
- Fixed root admin refresh token fail
1314
- Fixed error page metadata title warning
1415

1516
### Changed
1617
- Moved Insert Media button in Markdown editor
18+
- Use semver for DB migrations ordering
1719

1820
## [2.0.0-beta.11] - 2018-01-20
1921
- First beta release

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ docker-dev-rebuild: ## Rebuild dockerized dev image
3535

3636
docker-dev-clean: ## Clean DB, redis and data folders
3737
rm -rf ./data
38-
docker-compose -f ./dev/docker/docker-compose.yml -p wiki --project-directory . exec db psql --dbname=wiki --username=postgres --command='DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public'
38+
docker-compose -f ./dev/docker/docker-compose.yml -p wiki --project-directory . exec db psql --dbname=wiki --username=wikijs --command='DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public'
3939
docker-compose -f ./dev/docker/docker-compose.yml -p wiki --project-directory . exec redis redis-cli flushall
4040

41+
docker-dev-bash: ## Rebuild dockerized dev image
42+
docker-compose -f ./dev/docker/docker-compose.yml -p wiki --project-directory . exec wiki bash
43+
4144
docker-build: ## Run assets generation build in docker
4245
docker-compose -f ./dev/docker/docker-compose.yml -p wiki --project-directory . run wiki yarn build
4346
docker-compose -f ./dev/docker/docker-compose.yml -p wiki --project-directory . down

client/components/admin.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export default {
203203
<style lang='scss'>
204204
205205
.admin {
206-
&.theme--light {
206+
&.theme--light .application--wrap {
207207
background-color: lighten(mc('grey', '200'), 2%);
208208
}
209209
}

client/components/admin/admin-groups-edit-permissions.vue

+14
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ export default {
7979
restrictedForSystem: false,
8080
disabled: false
8181
},
82+
{
83+
permission: 'read:source',
84+
hint: 'Can view pages source, as specified in the Page Rules',
85+
warning: false,
86+
restrictedForSystem: false,
87+
disabled: false
88+
},
89+
{
90+
permission: 'read:history',
91+
hint: 'Can view pages history, as specified in the Page Rules',
92+
warning: false,
93+
restrictedForSystem: false,
94+
disabled: false
95+
},
8296
{
8397
permission: 'read:assets',
8498
hint: 'Can view / use assets (such as images and files), as specified in the Page Rules',

client/components/admin/admin-groups-edit-rules.vue

+2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ export default {
206206
{ text: 'Create Pages', value: 'write:pages', icon: 'insert_drive_file' },
207207
{ text: 'Edit + Move Pages', value: 'manage:pages', icon: 'insert_drive_file' },
208208
{ text: 'Delete Pages', value: 'delete:pages', icon: 'insert_drive_file' },
209+
{ text: 'View Pages Source', value: 'read:source', icon: 'code' },
210+
{ text: 'View Pages History', value: 'read:history', icon: 'restore' },
209211
{ text: 'Read / Use Assets', value: 'read:assets', icon: 'camera' },
210212
{ text: 'Upload Assets', value: 'write:assets', icon: 'camera' },
211213
{ text: 'Edit + Delete Assets', value: 'manage:assets', icon: 'camera' },

client/components/common/nav-header.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
span Login
132132

133133
page-selector(mode='create', v-model='newPageModal', :open-handler='pageNewCreate')
134+
page-delete(v-model='deletePageModal', v-if='path && path.length')
134135
</template>
135136

136137
<script>
@@ -139,6 +140,9 @@ import _ from 'lodash'
139140
import Cookies from 'js-cookie'
140141
141142
export default {
143+
components: {
144+
PageDelete: () => import('./page-delete.vue')
145+
},
142146
props: {
143147
dense: {
144148
type: Boolean,
@@ -155,7 +159,8 @@ export default {
155159
searchIsLoading: false,
156160
searchIsShown: true,
157161
search: '',
158-
newPageModal: false
162+
newPageModal: false,
163+
deletePageModal: false
159164
}
160165
},
161166
computed: {
@@ -233,11 +238,7 @@ export default {
233238
})
234239
},
235240
pageDelete () {
236-
this.$store.commit('showNotification', {
237-
style: 'indigo',
238-
message: `Coming soon...`,
239-
icon: 'directions_boat'
240-
})
241+
this.deletePageModal = true
241242
},
242243
assets () {
243244
this.$store.commit('showNotification', {
+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<template lang='pug'>
2+
v-dialog(v-model='isShown', max-width='550', persistent)
3+
v-card.wiki-form
4+
.dialog-header.is-short.is-red
5+
v-icon.mr-2(color='white') highlight_off
6+
span Delete Page
7+
v-card-text
8+
.body-2 Are you sure you want to delete page #[span.red--text.text--darken-2 {{pageTitle}}]?
9+
.caption The page can be restored from the administration area.
10+
v-chip.mt-3.ml-0.mr-1(label, color='red lighten-4', disabled, small)
11+
.caption.red--text.text--darken-2 {{pageLocale.toUpperCase()}}
12+
v-chip.mt-3.mx-0(label, color='red lighten-5', disabled, small)
13+
span.red--text.text--darken-2 /{{pagePath}}
14+
v-card-chin
15+
v-spacer
16+
v-btn(flat, @click='discard', :disabled='loading') Cancel
17+
v-btn(color='red darken-2', @click='deletePage', :loading='loading').white--text Delete
18+
</template>
19+
20+
<script>
21+
import _ from 'lodash'
22+
import { get } from 'vuex-pathify'
23+
24+
import deletePageMutation from 'gql/common/common-pages-mutation-delete.gql'
25+
26+
export default {
27+
props: {
28+
value: {
29+
type: Boolean,
30+
default: false
31+
}
32+
},
33+
data() {
34+
return {
35+
loading: false
36+
}
37+
},
38+
computed: {
39+
isShown: {
40+
get() { return this.value },
41+
set(val) { this.$emit('input', val) }
42+
},
43+
pageTitle: get('page/title'),
44+
pagePath: get('page/path'),
45+
pageLocale: get('page/locale'),
46+
pageId: get('page/id')
47+
},
48+
watch: {
49+
isShown(newValue, oldValue) {
50+
if (newValue) {
51+
document.body.classList.add('page-deleted-pending')
52+
}
53+
}
54+
},
55+
methods: {
56+
discard() {
57+
document.body.classList.remove('page-deleted-pending')
58+
this.isShown = false
59+
},
60+
async deletePage() {
61+
this.loading = true
62+
this.$store.commit(`loadingStart`, 'page-delete')
63+
this.$nextTick(async () => {
64+
try {
65+
const resp = await this.$apollo.mutate({
66+
mutation: deletePageMutation,
67+
variables: {
68+
id: this.pageId
69+
}
70+
})
71+
if (_.get(resp, 'data.pages.delete.responseResult.succeeded', false)) {
72+
this.isShown = false
73+
_.delay(() => {
74+
document.body.classList.add('page-deleted')
75+
_.delay(() => {
76+
window.location.assign('/')
77+
}, 1200)
78+
}, 400)
79+
} else {
80+
throw new Error(_.get(resp, 'data.pages.delete.responseResult.message', 'An unexpected error occured.'))
81+
}
82+
} catch (err) {
83+
this.$store.commit('pushGraphError', err)
84+
}
85+
this.$store.commit(`loadingStop`, 'page-delete')
86+
this.loading = false
87+
})
88+
}
89+
}
90+
}
91+
</script>
92+
93+
<style lang='scss'>
94+
body.page-deleted-pending {
95+
.application {
96+
background-color: mc('grey', '900');
97+
}
98+
.application--wrap {
99+
transform: translateZ(-5vw) rotateX(2deg);
100+
border-radius: 7px;
101+
overflow: hidden;
102+
}
103+
}
104+
body.page-deleted {
105+
.application--wrap {
106+
transform: translateZ(-1000vw) rotateX(60deg);
107+
opacity: 0;
108+
}
109+
}
110+
</style>

client/components/editor.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
outline
1515
color='blue'
1616
@click.native.stop='openPropsModal'
17-
:class='{ "is-icon": $vuetify.breakpoint.mdAndDown, "mx-0": !welcomeMode, "ml-0": !welcomeMode }'
17+
:class='{ "is-icon": $vuetify.breakpoint.mdAndDown, "mx-0": !welcomeMode, "ml-0": welcomeMode }'
1818
)
1919
v-icon(color='blue', :left='$vuetify.breakpoint.lgAndUp') sort_by_alpha
2020
span.white--text(v-if='$vuetify.breakpoint.lgAndUp') {{ $t('editor:page') }}
@@ -282,6 +282,10 @@ export default {
282282
.editor {
283283
background-color: mc('grey', '900') !important;
284284
min-height: 100vh;
285+
286+
.application--wrap {
287+
background-color: mc('grey', '900');
288+
}
285289
}
286290
287291
.atom-spinner.is-inline {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mutation($id: Int!) {
2+
pages {
3+
delete(id: $id) {
4+
responseResult {
5+
succeeded
6+
errorCode
7+
slug
8+
message
9+
}
10+
}
11+
}
12+
}

client/scss/base/base.scss

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
html {
22
box-sizing: border-box;
33
height: 100%;
4+
perspective: 50vw;
5+
background-color: mc('grey', '900');
46
}
57
*, *:before, *:after {
68
box-sizing: inherit;
@@ -19,6 +21,17 @@ html {
1921
}
2022
}
2123

24+
.application--wrap {
25+
transition: all 1.2s ease;
26+
transform-style: preserve-3d;
27+
transform-origin: 50% 50%;
28+
background-color: #FFF;
29+
30+
@at-root .theme--dark & {
31+
background-color: mc('grey', '900');
32+
}
33+
}
34+
2235

2336
@for $i from 0 through 25 {
2437
.radius-#{$i} {

client/themes/default/components/page.vue

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ export default {
132132
StatusIndicator
133133
},
134134
props: {
135+
pageId: {
136+
type: Number,
137+
default: 0
138+
},
135139
locale: {
136140
type: String,
137141
default: 'en'
@@ -229,6 +233,7 @@ export default {
229233
this.$store.commit('page/SET_CREATED_AT', this.createdAt)
230234
this.$store.commit('page/SET_DESCRIPTION', this.description)
231235
this.$store.commit('page/SET_IS_PUBLISHED', this.isPublished)
236+
this.$store.commit('page/SET_ID', this.pageId)
232237
this.$store.commit('page/SET_LOCALE', this.locale)
233238
this.$store.commit('page/SET_PATH', this.path)
234239
this.$store.commit('page/SET_TAGS', this.tags)

dev/docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM node:10-alpine
55
LABEL maintainer "requarks.io"
66

77
RUN apk update && \
8-
apk add bash curl git python make g++ --no-cache && \
8+
apk add bash curl git python make g++ nano --no-cache && \
99
mkdir -p /wiki
1010

1111
WORKDIR /wiki

dev/examples/docker-compose.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -- DEV DOCKER-COMPOSE --
2-
# -- DO NOT USE IN PRODUCTION! --
3-
41
version: "3"
52
services:
63

0 commit comments

Comments
 (0)