From c2a33da65c678618f414c3b771b39468eacba532 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Sat, 14 Sep 2019 22:17:24 +0000 Subject: [PATCH] Add ability to disable settings/reports during compile time --- CHANGELOG.md | 3 ++- README.md | 14 ++++++++++++ config/dev.env.js | 1 + config/prod.env.js | 1 + src/router/index.js | 55 +++++++++++++++++++++++++-------------------- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 276a2236..1e672e1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Unreleased] +## [1.1.0] - 2019-09-15 ### Added - add ability to configure new settings (UploadS3 bucket namespace, Rate limit for Activity pub routes, Email notifications settings, MRF Vocabulary, user bio and name length and others) +- add ability to disable certain features (settings/reports) - add sign in via PleromaFE ### Changed diff --git a/README.md b/README.md index be1dc34a..1511d32b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,20 @@ Admin UI for pleroma instance owners +## Usage + +### Development + +To run AdminFE locally execute `yarn dev` + +### Build + +To compile everything for production run `yarn build:prod`. + +#### Disabling features + +You can disable certain AdminFE features, like reports or settings by modifying `config/prod.env.js` env variable `DISABLED_FEATURES`, e.g. if you want to compile AdminFE without "Setting" you'll need to set it to: `DISABLED_FEATURES: '["settings"]'`. + ## Changelog Detailed changes for each release are documented in the [CHANGELOG](./CHANGELOG.md). diff --git a/config/dev.env.js b/config/dev.env.js index 6704d298..a9a3edd7 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -1,5 +1,6 @@ module.exports = { NODE_ENV: '"development"', ENV_CONFIG: '"dev"', + DISABLED_FEATURES: '[""]', ASSETS_PUBLIC_PATH: '/' } diff --git a/config/prod.env.js b/config/prod.env.js index e8a2016f..7acb93a2 100644 --- a/config/prod.env.js +++ b/config/prod.env.js @@ -2,5 +2,6 @@ module.exports = { NODE_ENV: '"production"', ENV_CONFIG: '"prod"', BASE_API: '"https://api-prod"', + DISABLED_FEATURES: '[""]', ASSETS_PUBLIC_PATH: '/pleroma/admin/' } diff --git a/src/router/index.js b/src/router/index.js index 7ffbb61c..90db3fd3 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -6,6 +6,35 @@ Vue.use(Router) /* Layout */ import Layout from '@/views/layout/Layout' +const disabledFeatures = process.env.DISABLED_FEATURES || [] +const settingsDisabled = disabledFeatures.includes('settings') +const settings = { + path: '/settings', + component: Layout, + children: [ + { + path: 'index', + component: () => import('@/views/settings/index'), + name: 'Settings', + meta: { title: 'settings', icon: 'settings', noCache: true } + } + ] +} + +const reportsDisabled = disabledFeatures.includes('reports') +const reports = { + path: '/reports', + component: Layout, + children: [ + { + path: 'index', + component: () => import('@/views/reports/index'), + name: 'Reports', + meta: { title: 'reports', icon: 'documentation', noCache: true } + } + ] +} + export const constantRouterMap = [ { path: '/redirect', @@ -69,30 +98,8 @@ export const asyncRouterMap = [ } ] }, - { - path: '/reports', - component: Layout, - children: [ - { - path: 'index', - component: () => import('@/views/reports/index'), - name: 'Reports', - meta: { title: 'reports', icon: 'documentation', noCache: true } - } - ] - }, - { - path: '/settings', - component: Layout, - children: [ - { - path: 'index', - component: () => import('@/views/settings/index'), - name: 'Settings', - meta: { title: 'settings', icon: 'settings', noCache: true } - } - ] - }, + ...(settingsDisabled ? [] : [settings]), + ...(reportsDisabled ? [] : [reports]), { path: '/users/:id', component: Layout,