Commit fb7a1b5b authored by Savas Vedova's avatar Savas Vedova

Display the unavailable state when user has no access

- Refactor props destructuring
parent a256e32a
...@@ -5,6 +5,7 @@ import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants'; ...@@ -5,6 +5,7 @@ import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import FirstClassProjectSecurityDashboard from './components/first_class_project_security_dashboard.vue'; import FirstClassProjectSecurityDashboard from './components/first_class_project_security_dashboard.vue';
import FirstClassGroupSecurityDashboard from './components/first_class_group_security_dashboard.vue'; import FirstClassGroupSecurityDashboard from './components/first_class_group_security_dashboard.vue';
import FirstClassInstanceSecurityDashboard from './components/first_class_instance_security_dashboard.vue'; import FirstClassInstanceSecurityDashboard from './components/first_class_instance_security_dashboard.vue';
import UnavailableState from './components/unavailable_state.vue';
import createStore from './store'; import createStore from './store';
import createRouter from './store/router'; import createRouter from './store/router';
import projectsPlugin from './store/plugins/projects'; import projectsPlugin from './store/plugins/projects';
...@@ -21,27 +22,35 @@ export default ( ...@@ -21,27 +22,35 @@ export default (
dashboardType = isRequired('No dashboard type was passed to the security dashboard initializer'), dashboardType = isRequired('No dashboard type was passed to the security dashboard initializer'),
/* eslint-enable @gitlab/require-i18n-strings */ /* eslint-enable @gitlab/require-i18n-strings */
) => { ) => {
if (el.dataset.isUnavailable) {
return new Vue({
el,
render(createElement) {
return createElement(UnavailableState, {
props: {
link: el.dataset.dashboardDocumentation,
svgPath: el.dataset.emptyStateSvgPath,
},
});
},
});
}
Vue.use(VueApollo); Vue.use(VueApollo);
const apolloProvider = new VueApollo({ const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(), defaultClient: createDefaultClient(),
}); });
const {
dashboardDocumentation,
emptyStateSvgPath,
hasPipelineData,
securityDashboardHelpPath,
projectAddEndpoint,
projectListEndpoint,
} = el.dataset;
const props = { const props = {
emptyStateSvgPath, emptyStateSvgPath: el.dataset.emptyStateSvgPath,
dashboardDocumentation, dashboardDocumentation: el.dataset.dashboardDocumentation,
hasPipelineData: Boolean(hasPipelineData), hasPipelineData: Boolean(el.dataset.hasPipelineData),
securityDashboardHelpPath, securityDashboardHelpPath: el.dataset.securityDashboardHelpPath,
projectAddEndpoint, projectAddEndpoint: el.dataset.projectAddEndpoint,
projectListEndpoint, projectListEndpoint: el.dataset.projectListEndpoint,
}; };
let component; let component;
if (dashboardType === DASHBOARD_TYPES.PROJECT) { if (dashboardType === DASHBOARD_TYPES.PROJECT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment