In this lab, you will gate a component behind the title feature flag defined in the previous lab by using CloudBees Feature Management’s dashboard. We will then remotely configure the value of the flag to control whether the title element is visible or hidden.
microblog-frontend repository. Ensure that you are on the development branch.Posts.vue file (src/views/Posts.vue) by clicking the src folder, views folder, followed by Posts.vue, consecutively. 
sidebar flag and its state is checked using the show_sidebar function that gates the component as seen on Line 7. To use this and the title feature flags created in the flags.js file, we’ve included the import statement on Line 50. Now, we’ll create a function called show_title that will return the boolean value from Flags.title.isEnabled(). To add this functionality, first insert a comma , at the end of the show_sidebar definition on Line 63. Then, add a new line after the comma, and define the show_title to check the title flag state using Flags.title.isEnabled() as seen in the data segment below:data: function () {
return {
message: '',
posts: [],
users: [],
errors: [],
show_sidebar: Flags.sidebar.isEnabled(),
show_title: Flags.title.isEnabled()
}
},
title feature flag. This will allow the element to only be displayed when Flags.title.isEnabled() is true. Update the code on Line 5 to gate the Show New Title! text behind the show_title flag: <h1 class="title">Posts <span v-if="show_title"> - Show New Title!</span></h1>
development branch radio button. Click Commit changes.The Configurationed Fetch Handler provides a mechanism to alert the CloudBees Feature Management SDK in your application when an updated configuration, from local storage or via an asynchronous network call, has loaded. It allows us to control what happens when a new configuration is fetched, and can be used for troubleshooting by logging the fetchedResults. For the changes in a client-side defined feature flag, an action has to take place (like a page refresh) in order for the new configuration to be applied.
microblog-frontend repository on the development branch.flags.js file (navigating to src/utils/flags.js), and select the pencil icon to edit the file.console.log statements. Define the configurationFetchedHandler constant with its boolean logic cases and then add it to the options constant used to configure the Rox.setup call as seen in the flags.js file below:import Rox from 'rox-browser'
export const Flags = {
sidebar: new Rox.Flag(false),
title: new Rox.Flag(false)
}
export const configurationFetchedHandler = fetcherResults => {
console.log('The configuration status is: ' + fetcherResults.fetcherStatus)
if (fetcherResults.hasChanges && fetcherResults.fetcherStatus === 'APPLIED_FROM_NETWORK') {
window.location.reload(false)
} else if (fetcherResults.fetcherStatus === 'ERROR_FETCH_FAILED') {
console.log('Error occured! Details are: ' + fetcherResults.errorDetails)
}
}
async function initCloudBees () {
const options = {
configurationFetchedHandler: configurationFetchedHandler
}
Rox.register('default', Flags)
await Rox.setup(process.env.VUE_APP_CLOUDBEES_KEY, options)
}
initCloudBees().then(function () {
console.log('Done loading CloudBees Feature Management')
})
development branch radio button and click Commit changes.configurationFetchedHandler.For instructor led workshops please return to the workshop slides