# New Dashboard documentation ## Getting Started New Dashboard was born as a way to redesign the current dashboard, adapting it to the new times and improving some of the UX patterns there. We chose Vue for our New Dashboard project because we are using Vue for the new CARTO frontend's projects. That way we can benefit from all the patterns and behaviours implemented in one project or another. ## How to run it Following [`Running the project` steps in CARTO Frontend's documentation](https://github.com/CartoDB/cartodb/tree/master/doc/frontend#running-the-project) is the way to run New Dashboard. Once Ruby on Rails is listening on the desired port and Webpack has finished compiling assets, everything should be ready to launch and access the dashboard in localhost:3000. However, as long as New Dashboard is under a Feature Flag, there are some additional steps to perform before being able to see New Dashboard as the main UI. ### Adding and Enabling `new-dashboard-feature` feature flag There are two steps to be performed to enable the feature flag to a given user: - Adding the feature flag ```bash $ bundle exec rake cartodb:features:add_feature_flag["new-dashboard-feature"] ``` - Enabling it to a specific user ```bash $ bundle exec rake cartodb:features:enable_feature_for_user["new-dashboard-feature","your_username"] ``` ## Command Explanation We can find some commands in [`package.json`](https://github.com/CartoDB/cartodb/blob/master/package.json) to launch tasks related to new dashboard. - `npm run start` This command will compile all assets needed to launch cartodb with Webpack. - `npm run test:new_dashboard` This command will run all new dashboard tests with Jest. You can add any Jest's CLI option to the command by appending `--` and the desired option, i.e. `-- --watch`. Please see all CLI options [here](https://jestjs.io/docs/en/cli#options) ## Folder Structure Root folder of new dashboard is `lib/assets/javascripts/new-dashboard`. You will find several folders within that one that define different aspects of our application. - **assets**\ This folder contains icons or images referenced within the application. - **components**\ Standalone components that can be composed or used within other components or pages. - **core**\ Set of common domain login separated from components. An example of this functions would be visualization functions to generate the proper visualizations' URL link. - **directives**\ Common application directives for DOM behaviour like closing dropdowns when clicking outside. - **i18n**\ Internacionalization configuration for `vue-i18n` and translation strings. - **pages**\ Page components used in Vue router to be rendered. - **plugins**\ Custom Vue plugins. There is only one right now to inject `$cartoModels` in every component to be able to use initialized UserModel and ConfigModel wherever we need them. - **router**\ Router configuration for pages within the Dashboard. It includes navigation hooks for loading data beforehand. - **store**\ State management configuration and store for the application which holds all the visualizations, user data, application configuration, etc... - **styles**\ Global styles for the application. Here we put common or styles that don't belong to any specific components, such as grid styles, button styles, and so on and so forth. - **utils**\ Set of functions to be used application-wide that perform a specific action like counting characters in an array or things like that. ## Bundles There are several bundles within the application that serve different purposes. - **Main Bundle** This bundle contains the whole application that is served in Ruby on Rails when accessing Dashboard. This bundle uses i18n, router, store, and plugins. The two bundles below are reduced bundles that are included within private pages to be able to show [Header](https://github.com/CartoDB/cartodb/issues/14312) and [Footer](https://github.com/CartoDB/cartodb/issues/14342) without copying or adapting the code to Ruby on Rails' templates. - **Header Bundle**. This bundle renders `` with the component receiving props from window variables like `user_data` or `organization_notifications`. [Header Bundle folder](https://github.com/CartoDB/cartodb/tree/master/lib/assets/javascripts/new-dashboard/bundles/header) - **Why we can't use $store within ``**\ We have a strong limitation with Vuex in this bundle because we don't want to include it to make the bundle as smaller as possible. So, we rely on component parameters to inject all the needed properties. - **Footer Bundle** This bundle renders `