Unverified Commit 97bcc56c authored by NGPixel's avatar NGPixel

fix: various fixes + profile editing block

parent 0eee0519
...@@ -244,10 +244,10 @@ export class Tree extends Model { ...@@ -244,10 +244,10 @@ export class Tree extends Model {
} }
// Check for collision // Check for collision
const existingFolder = await WIKI.db.knex('tree').where({ const existingFolder = await WIKI.db.knex('tree').select('id').where({
siteId: siteId, siteId: siteId,
localeCode: locale, localeCode: locale,
folderPath: parentPath, folderPath: encodeTreePath(parentPath),
fileName: pathName fileName: pathName
}).first() }).first()
if (existingFolder) { if (existingFolder) {
...@@ -261,7 +261,7 @@ export class Tree extends Model { ...@@ -261,7 +261,7 @@ export class Tree extends Model {
const parentPathParts = parentPath.split('.') const parentPathParts = parentPath.split('.')
for (let i = 1; i <= parentPathParts.length; i++) { for (let i = 1; i <= parentPathParts.length; i++) {
const ancestor = { const ancestor = {
folderPath: dropRight(parentPathParts, i).join('.'), folderPath: encodeTreePath(dropRight(parentPathParts, i).join('.')),
fileName: nth(parentPathParts, i * -1) fileName: nth(parentPathParts, i * -1)
} }
expectedAncestors.push(ancestor) expectedAncestors.push(ancestor)
...@@ -296,7 +296,7 @@ export class Tree extends Model { ...@@ -296,7 +296,7 @@ export class Tree extends Model {
// Create folder // Create folder
const fullPath = parentPath ? `${decodeTreePath(parentPath)}/${pathName}` : pathName const fullPath = parentPath ? `${decodeTreePath(parentPath)}/${pathName}` : pathName
const folder = await WIKI.db.knex('tree').insert({ const folder = await WIKI.db.knex('tree').insert({
folderPath: parentPath, folderPath: encodeTreePath(parentPath),
fileName: pathName, fileName: pathName,
type: 'folder', type: 'folder',
title: title, title: title,
......
...@@ -25,16 +25,19 @@ export default { ...@@ -25,16 +25,19 @@ export default {
}, },
async install () { async install () {
try { try {
const { stdout, stderr } = await exec('node install.js', { // TODO: https://pptr.dev/browsers-api/
cwd: path.join(WIKI.SERVERPATH, 'node_modules/puppeteer-core'), // const { stdout, stderr } = await exec('node install.js', {
timeout: 300000, // cwd: path.join(WIKI.SERVERPATH, 'node_modules/puppeteer-core'),
windowsHide: true // timeout: 300000,
}) // windowsHide: true
this.isInstalled = true // })
WIKI.logger.info(stdout) // this.isInstalled = true
WIKI.logger.warn(stderr) // WIKI.logger.info(stdout)
// WIKI.logger.warn(stderr)
throw new Error('Not implemented yet.')
} catch (err) { } catch (err) {
WIKI.logger.error(err) WIKI.logger.error(err)
throw err
} }
} }
} }
...@@ -111,7 +111,6 @@ const { t } = useI18n() ...@@ -111,7 +111,6 @@ const { t } = useI18n()
// METHODS // METHODS
function create (editor) { function create (editor) {
// window.location.assign('/_edit/new')
pageStore.pageCreate({ editor }) pageStore.pageCreate({ editor })
} }
......
...@@ -14,6 +14,16 @@ q-card.page-properties-dialog ...@@ -14,6 +14,16 @@ q-card.page-properties-dialog
q-toolbar.bg-primary.text-white.flex q-toolbar.bg-primary.text-white.flex
.text-subtitle2 {{t('editor.props.pageProperties')}} .text-subtitle2 {{t('editor.props.pageProperties')}}
q-space q-space
q-btn.q-mr-sm(
dense
flat
rounded
color='white'
icon='las la-question-circle'
:href='siteStore.docsBase + `/editor/properties`'
target='_blank'
type='a'
)
q-btn( q-btn(
icon='las la-times' icon='las la-times'
dense dense
......
...@@ -236,7 +236,7 @@ async function save () { ...@@ -236,7 +236,7 @@ async function save () {
}) })
} }
async function treeLazyLoad (nodeId, { done, fail }) { async function treeLazyLoad (nodeId, isCurrent, { done, fail }) {
await loadTree({ await loadTree({
parentId: nodeId, parentId: nodeId,
types: ['folder', 'page'] types: ['folder', 'page']
......
...@@ -1666,6 +1666,7 @@ ...@@ -1666,6 +1666,7 @@
"profile.avatar": "Avatar", "profile.avatar": "Avatar",
"profile.avatarClearFailed": "Failed to clear profile picture.", "profile.avatarClearFailed": "Failed to clear profile picture.",
"profile.avatarClearSuccess": "Profile picture cleared successfully.", "profile.avatarClearSuccess": "Profile picture cleared successfully.",
"profile.avatarUploadDisabled": "Your avatar is set by your organization and cannot be changed.",
"profile.avatarUploadFailed": "Failed to upload user profile picture.", "profile.avatarUploadFailed": "Failed to upload user profile picture.",
"profile.avatarUploadHint": "For best results, use a 180x180 image of type JPG or PNG.", "profile.avatarUploadHint": "For best results, use a 180x180 image of type JPG or PNG.",
"profile.avatarUploadSuccess": "Profile picture uploaded successfully.", "profile.avatarUploadSuccess": "Profile picture uploaded successfully.",
...@@ -1682,6 +1683,8 @@ ...@@ -1682,6 +1683,8 @@
"profile.dateFormatHint": "Set your preferred format to display dates.", "profile.dateFormatHint": "Set your preferred format to display dates.",
"profile.displayName": "Display Name", "profile.displayName": "Display Name",
"profile.displayNameHint": "Your full name; shown when authoring content (e.g. pages, comments, etc.).", "profile.displayNameHint": "Your full name; shown when authoring content (e.g. pages, comments, etc.).",
"profile.editDisabledDescription": "Your wiki administrator has disabled profile editing.",
"profile.editDisabledTitle": "Profile info is managed by your organization.",
"profile.email": "Email Address", "profile.email": "Email Address",
"profile.emailHint": "The email address used for login.", "profile.emailHint": "The email address used for login.",
"profile.groups": "Groups", "profile.groups": "Groups",
......
<template lang="pug"> <template lang="pug">
q-page.q-py-md(:style-fn='pageStyle') q-page.q-py-md(:style-fn='pageStyle')
.text-header {{t('profile.avatar')}} .text-header {{t('profile.avatar')}}
.row.q-gutter-lg.q-mt-xl.align-center .row.q-gutter-lg.q-mt-xl
.col.text-center .col.text-center
q-avatar.profile-avatar-circ( q-avatar.profile-avatar-circ(
size='180px' size='180px'
...@@ -17,7 +17,7 @@ q-page.q-py-md(:style-fn='pageStyle') ...@@ -17,7 +17,7 @@ q-page.q-py-md(:style-fn='pageStyle')
v-else, v-else,
name='las la-user' name='las la-user'
) )
.col .col.self-center(v-if='canEdit')
.text-body1 {{ t('profile.avatarUploadTitle') }} .text-body1 {{ t('profile.avatarUploadTitle') }}
.text-caption {{ t('profile.avatarUploadHint') }} .text-caption {{ t('profile.avatarUploadHint') }}
.q-mt-md .q-mt-md
...@@ -37,6 +37,8 @@ q-page.q-py-md(:style-fn='pageStyle') ...@@ -37,6 +37,8 @@ q-page.q-py-md(:style-fn='pageStyle')
@click='clearImage' @click='clearImage'
:disable='!userStore.hasAvatar' :disable='!userStore.hasAvatar'
) )
.col.self-center(v-else)
.text-caption.text-negative {{ t('profile.avatarUploadDisabled') }}
q-inner-loading(:showing='state.loading > 0') q-inner-loading(:showing='state.loading > 0')
</template> </template>
...@@ -46,8 +48,9 @@ import gql from 'graphql-tag' ...@@ -46,8 +48,9 @@ import gql from 'graphql-tag'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useMeta, useQuasar } from 'quasar' import { useMeta, useQuasar } from 'quasar'
import { reactive } from 'vue' import { computed, reactive } from 'vue'
import { useSiteStore } from 'src/stores/site'
import { useUserStore } from 'src/stores/user' import { useUserStore } from 'src/stores/user'
// QUASAR // QUASAR
...@@ -56,6 +59,7 @@ const $q = useQuasar() ...@@ -56,6 +59,7 @@ const $q = useQuasar()
// STORES // STORES
const siteStore = useSiteStore()
const userStore = useUserStore() const userStore = useUserStore()
// I18N // I18N
...@@ -75,6 +79,8 @@ const state = reactive({ ...@@ -75,6 +79,8 @@ const state = reactive({
assetTimestamp: (new Date()).toISOString() assetTimestamp: (new Date()).toISOString()
}) })
const canEdit = computed(() => siteStore.features?.profile)
// METHODS // METHODS
function pageStyle (offset, height) { function pageStyle (offset, height) {
......
<template lang="pug"> <template lang="pug">
q-page.q-py-md(:style-fn='pageStyle') q-page.q-py-md(:style-fn='pageStyle')
.text-header {{t('profile.myInfo')}} .text-header {{t('profile.myInfo')}}
q-item(v-if='!canEdit')
q-item-section
q-card.bg-negative.text-white.rounded-borders(flat)
q-card-section.items-center(horizontal)
q-card-section.col-auto.q-pr-none
q-icon(name='las la-ban', size='sm')
q-card-section
span {{ t('profile.editDisabledTitle') }}
.text-caption.text-red-1 {{ t('profile.editDisabledDescription') }}
q-item q-item
blueprint-icon(icon='contact') blueprint-icon(icon='contact')
q-item-section q-item-section
...@@ -13,6 +22,7 @@ q-page.q-py-md(:style-fn='pageStyle') ...@@ -13,6 +22,7 @@ q-page.q-py-md(:style-fn='pageStyle')
dense dense
hide-bottom-space hide-bottom-space
:aria-label='t(`profile.displayName`)' :aria-label='t(`profile.displayName`)'
:readonly='!canEdit'
) )
q-separator.q-my-sm(inset) q-separator.q-my-sm(inset)
q-item q-item
...@@ -41,6 +51,7 @@ q-page.q-py-md(:style-fn='pageStyle') ...@@ -41,6 +51,7 @@ q-page.q-py-md(:style-fn='pageStyle')
dense dense
hide-bottom-space hide-bottom-space
:aria-label='t(`profile.location`)' :aria-label='t(`profile.location`)'
:readonly='!canEdit'
) )
q-separator.q-my-sm(inset) q-separator.q-my-sm(inset)
q-item q-item
...@@ -55,6 +66,7 @@ q-page.q-py-md(:style-fn='pageStyle') ...@@ -55,6 +66,7 @@ q-page.q-py-md(:style-fn='pageStyle')
dense dense
hide-bottom-space hide-bottom-space
:aria-label='t(`profile.jobTitle`)' :aria-label='t(`profile.jobTitle`)'
:readonly='!canEdit'
) )
q-separator.q-my-sm(inset) q-separator.q-my-sm(inset)
q-item q-item
...@@ -69,6 +81,7 @@ q-page.q-py-md(:style-fn='pageStyle') ...@@ -69,6 +81,7 @@ q-page.q-py-md(:style-fn='pageStyle')
dense dense
hide-bottom-space hide-bottom-space
:aria-label='t(`profile.pronouns`)' :aria-label='t(`profile.pronouns`)'
:readonly='!canEdit'
) )
.text-header.q-mt-lg {{t('profile.preferences')}} .text-header.q-mt-lg {{t('profile.preferences')}}
q-item q-item
...@@ -164,7 +177,7 @@ import gql from 'graphql-tag' ...@@ -164,7 +177,7 @@ import gql from 'graphql-tag'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useMeta, useQuasar } from 'quasar' import { useMeta, useQuasar } from 'quasar'
import { onMounted, reactive } from 'vue' import { computed, onMounted, reactive } from 'vue'
import { useSiteStore } from 'src/stores/site' import { useSiteStore } from 'src/stores/site'
import { useUserStore } from 'src/stores/user' import { useUserStore } from 'src/stores/user'
...@@ -230,6 +243,8 @@ const cvdChoices = [ ...@@ -230,6 +243,8 @@ const cvdChoices = [
] ]
const timezones = Intl.supportedValuesOf('timeZone') const timezones = Intl.supportedValuesOf('timeZone')
const canEdit = computed(() => siteStore.features?.profile)
// METHODS // METHODS
function pageStyle (offset, height) { function pageStyle (offset, height) {
......
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { cloneDeep, initial, last, pick, transform } from 'lodash-es' import { cloneDeep, dropRight, initial, last, pick, transform } from 'lodash-es'
import { DateTime } from 'luxon' import { DateTime } from 'luxon'
import { useSiteStore } from './site' import { useSiteStore } from './site'
...@@ -291,7 +291,8 @@ export const usePageStore = defineStore('page', { ...@@ -291,7 +291,8 @@ export const usePageStore = defineStore('page', {
// -> Default Page Path // -> Default Page Path
let newPath = path let newPath = path
if (!path && path !== '') { if (!path && path !== '') {
newPath = this.path.length < 2 ? 'new-page' : `${this.path}/new-page` const parentPath = dropRight(this.path.split('/'), 1).join('/')
newPath = parentPath ? `${parentPath}/new-page` : 'new-page'
} }
// -> Set Default Page Data // -> Set Default Page Data
......
...@@ -27,6 +27,7 @@ export const useSiteStore = defineStore('site', { ...@@ -27,6 +27,7 @@ export const useSiteStore = defineStore('site', {
overlay: null, overlay: null,
overlayOpts: {}, overlayOpts: {},
features: { features: {
profile: false,
ratingsMode: 'off', ratingsMode: 'off',
reasonForChange: 'required', reasonForChange: 'required',
search: false search: false
...@@ -97,6 +98,7 @@ export const useSiteStore = defineStore('site', { ...@@ -97,6 +98,7 @@ export const useSiteStore = defineStore('site', {
contentLicense contentLicense
footerExtra footerExtra
features { features {
profile
ratingsMode ratingsMode
reasonForChange reasonForChange
search search
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment