Skip to content

Commit

Permalink
feat: locales availability + IE display mode
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Jul 13, 2019
1 parent ca06a15 commit b6f1e18
Show file tree
Hide file tree
Showing 31 changed files with 1,015 additions and 71 deletions.
57 changes: 55 additions & 2 deletions .babelrc
Expand Up @@ -16,13 +16,66 @@
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
"@babel/plugin-proposal-throw-expressions",
[
"prismjs", {
"languages": [
"markup",
"css",
"clike",
"javascript",
"c",
"bash",
"basic",
"cpp",
"csharp",
"arduino",
"ruby",
"elixir",
"fsharp",
"go",
"graphql",
"handlebars",
"haskell",
"ini",
"java",
"json",
"kotlin",
"latex",
"less",
"makefile",
"markdown",
"matlab",
"nginx",
"objectivec",
"perl",
"php",
"powershell",
"pug",
"python",
"typescript",
"rust",
"scss",
"scala",
"smalltalk",
"sql",
"stylus",
"swift",
"vbnet",
"yaml"
],
"plugins": ["line-numbers"],
"theme": "dark",
"css": true
}
]
],
"presets": [
[
"@babel/preset-env", {
"useBuiltIns": "entry",
"corejs": 3
"corejs": 3,
"debug": true
}
]
]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,6 +19,7 @@ npm-debug.log*
# Generated assets
/assets
server/views/master.pug
server/views/legacy.pug
server/views/setup.pug

# Webpack
Expand Down
93 changes: 70 additions & 23 deletions client/components/admin/admin-locale.vue
Expand Up @@ -52,8 +52,6 @@
v-toolbar(color='primary', dark, dense, flat)
v-toolbar-title
.subheading {{ $t('admin:locale.namespacing') }}
v-spacer
v-chip(label, color='white', small).primary--text coming soon
v-card-text
v-switch(
v-model='namespacing'
Expand Down Expand Up @@ -102,28 +100,35 @@
v-card.animated.fadeInUp.wait-p4s
v-toolbar(color='teal', dark, dense, flat)
v-toolbar-title
.subheading {{ $t('admin:locale.download') }}
v-list(two-line, dense)
template(v-for='(lc, idx) in locales')
v-list-tile(:key='lc.code')
v-list-tile-avatar
v-avatar.teal.white--text(size='40') {{lc.code.toUpperCase()}}
v-list-tile-content
v-list-tile-title(v-html='lc.name')
v-list-tile-sub-title(v-html='lc.nativeName')
v-list-tile-action(v-if='lc.isRTL')
v-chip(label, small, :class='$vuetify.dark ? `text--lighten-5` : `text--darken-2`').caption.grey--text RTL
v-list-tile-action(v-if='lc.isInstalled && lc.installDate < lc.updatedAt')
v-btn(icon, @click='download(lc)')
v-icon.blue--text cached
v-list-tile-action(v-else-if='lc.isInstalled')
.subheading {{ $t('admin:locale.downloadTitle') }}
v-data-table(
:headers='headers',
:items='locales',
hide-actions,
item-key='code',
:rows-per-page-items='[-1]'
)
template(v-slot:items='lc')
td
v-chip.white--text(label, color='teal', small) {{lc.item.code}}
td
strong {{lc.item.name}}
td
span {{ lc.item.nativeName }}
td.text-xs-center
v-icon(v-if='lc.item.isRTL') check
td
.d-flex.align-center.pl-4
.caption.mr-2(:class='lc.item.availability <= 33 ? `red--text` : (lc.item.availability <= 66) ? `orange--text` : `green--text`') {{lc.item.availability}}%
v-progress-circular(:value='lc.item.availability', width='2', size='20', :color='lc.item.availability <= 33 ? `red` : (lc.item.availability <= 66) ? `orange` : `green`')
td.text-xs-center
v-progress-circular(v-if='lc.item.isDownloading', indeterminate, color='blue', size='20', :width='2')
v-btn(v-else-if='lc.item.isInstalled && lc.item.installDate < lc.item.updatedAt', icon, @click='download(lc.item)')
v-icon.blue--text cached
v-btn(v-else-if='lc.item.isInstalled', icon, @click='download(lc.item)')
v-icon.green--text check
v-list-tile-action(v-else-if='lc.isDownloading')
v-progress-circular(indeterminate, color='blue', size='20', :width='3')
v-list-tile-action(v-else)
v-btn(icon, @click='download(lc)')
v-icon.grey--text cloud_download
v-divider.my-0(inset, v-if='idx < locales.length - 1')
v-btn(v-else, icon, @click='download(lc.item)')
v-icon.grey--text cloud_download
v-card.wiki-form.mt-3.animated.fadeInUp.wait-p5s
v-toolbar(color='teal', dark, dense, flat)
v-toolbar-title
Expand Down Expand Up @@ -158,6 +163,46 @@ export default {
computed: {
installedLocales() {
return _.filter(this.locales, ['isInstalled', true])
},
headers() {
return [
{
text: this.$t('admin:locale.code'),
align: 'left',
value: 'code',
width: 10
},
{
text: this.$t('admin:locale.name'),
align: 'left',
value: 'name'
},
{
text: this.$t('admin:locale.nativeName'),
align: 'left',
value: 'nativeName'
},
{
text: this.$t('admin:locale.rtl'),
align: 'center',
value: 'isRTL',
sortable: false,
width: 10
},
{
text: this.$t('admin:locale.availability'),
align: 'center',
value: 'availability',
width: 100
},
{
text: this.$t('admin:locale.download'),
align: 'center',
value: 'code',
sortable: false,
width: 100
}
]
}
},
methods: {
Expand All @@ -173,6 +218,8 @@ export default {
if (resp.succeeded) {
lc.isDownloading = false
lc.isInstalled = true
lc.updatedAt = new Date().toISOString()
lc.installDate = lc.updatedAt
this.$store.commit('showNotification', {
message: `Locale ${lc.name} has been installed successfully.`,
style: 'success',
Expand Down
4 changes: 2 additions & 2 deletions client/components/admin/admin-utilities-auth.vue
Expand Up @@ -3,14 +3,14 @@
v-toolbar(flat, color='primary', dark, dense)
.subheading {{ $t('admin:utilities.authTitle') }}
v-card-text
v-subheader.pl-0 Generate New Authentication Public / Private Key Certificates
v-subheader.pl-0.primary--text Generate New Authentication Public / Private Key Certificates
.body-1 This will invalidate all current session tokens and cause all users to be logged out.
.body-1.red--text You will need to log back in after the operation.
v-btn(outline, color='primary', @click='regenCerts', :disabled='loading').ml-0.mt-3
v-icon(left) build
span Proceed
v-divider.my-3
v-subheader.pl-0 Reset Guest User
v-subheader.pl-0.primary--text Reset Guest User
.body-1 This will reset the guest user to its default parameters and permissions.
v-btn(outline, color='primary', @click='resetGuest', :disabled='loading').ml-0.mt-3
v-icon(left) build
Expand Down
4 changes: 2 additions & 2 deletions client/components/admin/admin-utilities-cache.vue
Expand Up @@ -3,13 +3,13 @@
v-toolbar(flat, color='primary', dark, dense)
.subheading {{ $t('admin:utilities.cacheTitle') }}
v-card-text
v-subheader.pl-0 Flush Pages and Assets Cache
v-subheader.pl-0.primary--text Flush Pages and Assets Cache
.body-1 Pages and Assets are cached to disk for better performance. You can flush the cache to force all content to be fetched from the DB again.
v-btn(outline, color='primary', @click='flushCache', :disabled='loading').ml-0.mt-3
v-icon(left) build
span Proceed
v-divider.my-3
v-subheader.pl-0 Flush Temporary Uploads
v-subheader.pl-0.primary--text Flush Temporary Uploads
.body-1 New uploads are temporarily saved to disk while they are being processed. They are automatically deleted after processing, but you can force an immediate cleanup using this tool.
.body-1.red--text Note that performing this action while an upload is in progress can result in a failed upload.
v-btn(outline, color='primary', @click='flushUploads', :disabled='loading').ml-0.mt-3
Expand Down
68 changes: 68 additions & 0 deletions client/components/admin/admin-utilities-content.vue
@@ -0,0 +1,68 @@
<template lang='pug'>
v-card
v-toolbar(flat, color='primary', dark, dense)
.subheading {{ $t('admin:utilities.contentTitle') }}
v-card-text
v-subheader.pl-0.primary--text Migrate all pages to base language
.body-1 If you created content before selecting a different locale and activating the namespacing capabilities, you may want to transfer all content to the base locale.
.body-1.red--text: strong This operation is destructive and cannot be reversed! Make sure you have proper backups!
.body-1.mt-3 Based on your current configuration, all pages will be migrated to the locale #[v-chip(label, small): strong {{currentLocale.toUpperCase()}}]
.body-1.mt-3 Pages that are already in the target locale will not be touched. If a page already exists at the target, the source page will not be modified as it would create a conflict. If you want to overwrite the target content, you must first delete that page.
v-btn(outline, color='primary', @click='migrateToLocale', :disabled='loading').ml-0.mt-3
v-icon(left) build
span Proceed
</template>

<script>
import _ from 'lodash'
import utilityContentMigrateLocaleMutation from 'gql/admin/utilities/utilities-mutation-content-migratelocale.gql'
/* global siteLang */
export default {
data: () => {
return {
loading: false
}
},
computed: {
currentLocale() {
return siteConfig.lang
}
},
methods: {
async migrateToLocale() {
this.loading = true
this.$store.commit(`loadingStart`, 'admin-utilities-content-migratelocale')
try {
const respRaw = await this.$apollo.mutate({
mutation: utilityContentMigrateLocaleMutation,
variables: {
targetLocale: siteConfig.lang
}
})
const resp = _.get(respRaw, 'data.pages.migrateToLocale.responseResult', {})
if (resp.succeeded) {
this.$store.commit('showNotification', {
message: 'Migrated all content to target locale successfully.',
style: 'success',
icon: 'check'
})
} else {
throw new Error(resp.message)
}
} catch (err) {
this.$store.commit('pushGraphError', err)
}
this.$store.commit(`loadingStop`, 'admin-utilities-content-migratelocale')
this.loading = false
}
}
}
</script>

<style lang='scss'>
</style>
7 changes: 7 additions & 0 deletions client/components/admin/admin-utilities.vue
Expand Up @@ -35,6 +35,7 @@
export default {
components: {
UtilityAuth: () => import(/* webpackChunkName: "admin" */ './admin-utilities-auth.vue'),
UtilityContent: () => import(/* webpackChunkName: "admin" */ './admin-utilities-content.vue'),
UtilityCache: () => import(/* webpackChunkName: "admin" */ './admin-utilities-cache.vue'),
UtilityImportv1: () => import(/* webpackChunkName: "admin" */ './admin-utilities-importv1.vue'),
UtilityTelemetry: () => import(/* webpackChunkName: "admin" */ './admin-utilities-telemetry.vue')
Expand All @@ -49,6 +50,12 @@ export default {
i18nKey: 'auth',
isAvailable: true
},
{
key: 'UtilityContent',
icon: 'insert_drive_file',
i18nKey: 'content',
isAvailable: true
},
{
key: 'UtilityCache',
icon: 'invert_colors',
Expand Down
4 changes: 2 additions & 2 deletions client/components/common/search-results.vue
Expand Up @@ -91,7 +91,7 @@ export default {
return this.response.suggestions ? this.response.suggestions : []
},
paginationLength() {
return this.response.totalHits > 0 ? 0 : Math.ceil(this.response.totalHits / 10)
return (this.response.totalHits > 0) ? 0 : Math.ceil(this.response.totalHits / 10)
}
},
watch: {
Expand All @@ -107,7 +107,7 @@ export default {
},
mounted() {
this.$root.$on('searchMove', (dir) => {
this.cursor += (dir === 'up' ? -1 : 1)
this.cursor += ((dir === 'up') ? -1 : 1)
if (this.cursor < -1) {
this.cursor = -1
} else if (this.cursor > this.results.length + this.suggestions.length - 1) {
Expand Down
2 changes: 1 addition & 1 deletion client/components/editor/editor-markdown.vue
Expand Up @@ -190,7 +190,7 @@ import mdMark from 'markdown-it-mark'
import mdImsize from 'markdown-it-imsize'
// Prism (Syntax Highlighting)
import Prism from '@/libs/prism/prism.js'
import Prism from 'prismjs'
// ========================================
// INIT
Expand Down
1 change: 1 addition & 0 deletions client/graph/admin/locale/locale-query-list.gql
@@ -1,6 +1,7 @@
{
localization {
locales {
availability
code
createdAt
isInstalled
Expand Down
@@ -0,0 +1,12 @@
mutation {
pages {
migrateToLocale {
responseResult {
succeeded
errorCode
slug
message
}
}
}
}
3 changes: 3 additions & 0 deletions client/index-legacy.js
@@ -0,0 +1,3 @@
require('./scss/legacy.scss')

window.WIKI = null
3 changes: 2 additions & 1 deletion client/index-setup.js
@@ -1,4 +1,5 @@
require('@babel/polyfill')
require('core-js/stable')
require('regenerator-runtime/runtime')

require('vuetify/src/stylus/main.styl')
require('./scss/app.scss')
Expand Down
2 changes: 1 addition & 1 deletion client/scss/app.scss
Expand Up @@ -18,7 +18,7 @@
@import 'layout/md2';

// @import '../libs/twemoji/twemoji-awesome';
@import '../libs/prism/prism.css';
// @import '../libs/prism/prism.css';
@import '~vue-tour/dist/vue-tour.css';
@import '~vue-status-indicator/styles.css';
@import '~xterm/dist/xterm.css';
Expand Down

0 comments on commit b6f1e18

Please sign in to comment.