From d9aa168f7665de46c89c40addce217ac04781209 Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Wed, 29 Jul 2020 13:26:10 -0700 Subject: Remove envConstants.js file Removing because current implementations are not using this file but directly referencing process.env.VUE_APP_* value instead. Also removing reference to this file in the env documentation along with the conditional template rendering section. The conditional template pattern is something that should be avoided and currently researching ways to dynamically generate navigation items so we can avoid this pattern. Signed-off-by: Yoshie Muranaka Change-Id: Icbb92c423dac2b9b353c3701c330c3b9bfb00d7a --- src/env/env.md | 58 ----------------------------------------------------- src/envConstants.js | 5 ----- 2 files changed, 63 deletions(-) delete mode 100644 src/envConstants.js diff --git a/src/env/env.md b/src/env/env.md index 573809df..f07375a8 100644 --- a/src/env/env.md +++ b/src/env/env.md @@ -6,7 +6,6 @@ This document provides instructions for how to add environment specific modifica - [Store](#store) - [Router](#router) - [Theming](#theming) -- [Conditional template rendering](#conditional-template-rendering) - [Local development](#local-development) - [Production build](#production-build) @@ -100,63 +99,6 @@ $theme-colors: ( ); ``` -## Conditional template rendering - -For features that show or hide chunks of code in the template/markup, use the src/`envConstants.js` file, to determine which features are enabled/disabled depending on the `VUE_APP_ENV_NAME` value. - ->Avoid complex v-if/v-else logic in the templates. If a template is being **heavily** modified, consider creating a separate View and [updating the router definition](#router). - -1. Add the environment specific feature name and value in the `envConstants.js` file -2. Import the ENV_CONSTANTS object in the component needing conditional rendering -3. Use v-if/else as needed in the component template - -Example for adding conditional navigation item to AppNavigation.vue component: - -`src/envConstants.js` - -``` -const envName = process.env.VUE_APP_ENV_NAME; - -export const ENV_CONSTANTS = { - name: envName || 'openbmc', - hmcEnabled: envName === 'openpower' ? true : false -}; - -``` - -`src/components/AppNavigation/AppNavigation.vue` - - -``` - - - - -``` - ## Local development 1. Add the same `VUE_APP_ENV_NAME` key value pair to your `env.development.local` file. diff --git a/src/envConstants.js b/src/envConstants.js deleted file mode 100644 index f9a4c3c6..00000000 --- a/src/envConstants.js +++ /dev/null @@ -1,5 +0,0 @@ -const envName = process.env.VUE_APP_ENV_NAME; - -export const ENV_CONSTANTS = { - name: envName || 'openbmc' -}; -- cgit v1.2.3