import { Injectable } from '@angular/core';
import { ConfigService } from '../config/config.service';

@Injectable({
  providedIn: 'root'
})
export class UiFeaturesService {
  private features = {
    staff: {
      'ui.staff': true,

      'ui.hello-user.show-email-log-link': false,

      'ui.billing.invoices.simple-journal': false,
      'ui.billing.invoices.client-link': true,

      'ui.billing.services.upgrade-downgrade': true,
      'ui.billing.services.show-client': true,
      'ui.billing.services.show-notes': true,
      'ui.billing.services.show-order': true,
      'ui.billing.services.show-product-link': true,
      'ui.billing.services.show-product-details': false,
      'ui.billing.history.cost': false,

      'ui.clients&users.active-client': false,
      'ui.clients&users.client-credit': true,
      'ui.clients&users.edit.groups': true,
      'ui.clients&users.edit.display-do-not-process': true,
      'ui.clients&users.details.display-do-not-process': true,
      'ui.clients&users.create.show-auto-order-service': true,
      'ui.clients&users.create.choose-config': true,
      'ui.clients&users.second_factor_auth': true,
      'ui.clients&users.roles.show-public': true,
      'ui.clients&users.roles.require-owner': false,
      'ui.clients&users.roles.edit-non-owned': true,

      'ui.core.allow-changing-password': true,
      'ui.core.demo-login-staff': true,
      'ui.core.register': false,

      'ui.openstack.create-as-admin': true,
      'ui.openstack.api-users.show-project': true,
      'ui.openstack.clusters.create.select-client': true,
      'ui.openstack.clusters.create-with-api-user': false,
      'ui.openstack.clusters.show-client-on-info': true,
      'ui.openstack.cluster-templates.show-client-on-info': true,
      'ui.openstack.cluster-templates.create-form.client-select': true,
      'ui.openstack.cluster-templates.create-form.hidden-checkbox': true,
      'ui.openstack.cluster-templates.create-form.public-checkbox': true,
      'ui.openstack.floating-ips.client': true,
      'ui.openstack.networks.always-allow-subnet-management': true,
      'ui.openstack.networks.auto-create.client-field': true,
      'ui.openstack.images.show-client': true,
      'ui.openstack.instances.backup_schedules.select_hour': true,
      'ui.openstack.instances.check_image_needs_sharing': true,
      'ui.openstack.instances.create_snapshot_dialog.volumes_message': true,
      'ui.openstack.instances.create_snapshot_dialog.project_select': true,
      'ui.openstack.instances.requires_port_permissions': false,
      'ui.openstack.instances.select-client': true,
      'ui.openstack.image.select-client': true,
      'ui.openstack.instances.snapshots.display_client': true,
      'ui.openstack.ports.project': true,
      'ui.openstack.routers.create.client-select': true,
      'ui.openstack.security-groups.add-rule-get-all-groups': false,
      'ui.openstack.security-groups.create.client': true,
      'ui.openstack.service.select-project': true,
      'ui.openstack.volumes.client': true,
      'ui.openstack.volumes.backups-tab.show-client': true,
      'ui.openstack.volumes.snapshots.show-project-checkbox': true,
      'ui.openstack.volumes.snapshots.show-client': true,
      'ui.openstack.volumes.backups.show-project-checkbox': true,
      'ui.openstack.volumes.backups.show-client': true,
      'ui.openstack.zones.project-link': true,

      'ui.plugins.domains.tld-link': true,

      'ui.plugins.tickets.show-created-by': true,
      'ui.plugins.tickets.show-client-link': true,
      'ui.plugins.tickets.show-user-link': true,
      'ui.plugins.tickets.show-assignee': true,
      'ui.plugins.tickets.show-priority': true,
      'ui.plugins.tickets.allow-edit-message': true,
      'ui.plugins.tickets.departament-link': true,
      'ui.plugins.tickets.insert-predefined-replies': true,
      'ui.plugins.tickets.show-remove-attachment': true,

      'ui.top-bar.operations': true,
      'ui.top-bar.plugins-notifications': true,
      'ui.top-bar.user-dropdown.user-notifications': true,
      'ui.top-bar.user-dropdown.shopping-cart': false,

      'ui.utilities.operations.user': true,
      'ui.utilities.operations.extra-info': true,
      'ui.utilities.email-messages-log.show-client': true,
      'ui.utilities.email-messages-log.show-user': true,
      'ui.utilities.email-messages-log.show-error': true,

      'ui.plugins.domains.change-registrar': true,
      'ui.plugins.domains.contact-info': true,
      'ui.plugins.domains.contacts.show-client': true,
    },
    enduser: {
      'ui.enduser': true,

      'ui.hello-user.show-email-log-link': true,

      'ui.billing.services.show-client': false,
      'ui.billing.services.show-notes': false,
      'ui.billing.services.show-product-link': false,
      'ui.billing.services.show-product-details': true,
      'ui.billing.services.upgrade-downgrade': true,

      'ui.billing.invoices.client-link': false,
      'ui.billing.invoices.simple-journal': true,

      'ui.billing.history.cost': false,

      'ui.clients&users.active-client': true,
      'ui.clients&users.second_factor_auth': true,
      'ui.clients&users.roles.show-public': false,
      'ui.clients&users.roles.require-owner': true,
      'ui.clients&users.roles.edit-non-owned': false,

      'ui.core.demo-login-enduser': true,
      'ui.core.register': true,

      'ui.openstack.api-users.show-project': false,
      'ui.openstack.clusters.create.select-client': false,
      'ui.openstack.clusters.create-with-api-user': true,
      'ui.openstack.clusters.show-client-on-info': false,
      'ui.openstack.cluster-templates.show-client-on-info': false,
      'ui.openstack.cluster-templates.create-form.client-select': false,
      'ui.openstack.cluster-templates.create-form.hidden-checkbox': false,
      'ui.openstack.cluster-templates.create-form.public-checkbox': false,
      'ui.openstack.floating-ips.client': false,
      'ui.openstack.networks.always-allow-subnet-management': false,
      'ui.openstack.networks.auto-create.client-field': false,
      'ui.openstack.images.show-client': false,
      'ui.openstack.instances.backup_schedules.select_hour': false,
      'ui.openstack.instances.check_image_needs_sharing': false,
      'ui.openstack.instances.create_snapshot_dialog.volumes_message': false,
      'ui.openstack.instances.create_snapshot_dialog.project_select': false,
      'ui.openstack.instances.requires_port_permissions': true,
      'ui.openstack.instances.select-client': false,
      'ui.openstack.instances.snapshots.display_client': false,
      'ui.openstack.ports.project': false,
      'ui.openstack.routers.create.client-select': false,
      'ui.openstack.security-groups.add-rule-get-all-groups': true,
      'ui.openstack.security-groups.create.client': false,
      'ui.openstack.volumes.client': false,
      'ui.openstack.volumes.backups-tab.show-client': false,
      'ui.openstack.volumes.backups.show-project-checkbox': false,
      'ui.openstack.volumes.backups.show-client': false,
      'ui.openstack.volumes.snapshots.show-project-checkbox': false,
      'ui.openstack.volumes.snapshots.show-client': false,

      'ui.plugins.domains.tld-link': false,

      'ui.plugins.tickets.show-created-by': false,
      'ui.plugins.tickets.show-client-link': false,
      'ui.plugins.tickets.show-user-link': false,
      'ui.plugins.tickets.show-assignee': false,
      'ui.plugins.tickets.show-priority': false,
      'ui.plugins.tickets.allow-edit-message': false,
      'ui.plugins.tickets.departament-link': false,
      'ui.plugins.tickets.insert-predefined-replies': false,

      'ui.top-bar.operations': true,
      'ui.top-bar.user-dropdown.client-details': true,
      'ui.top-bar.user-dropdown.user-notifications': true,
      'ui.top-bar.user-dropdown.shopping-cart': true,
      'ui.top-bar.plugins-notifications': true,

      'ui.utilities.operations.user': false,
      'ui.utilities.operations.extra-info': false,
      'ui.utilities.email-messages-log.show-client': false,
      'ui.utilities.email-messages-log.show-user': false,
      'ui.utilities.email-messages-log.show-error': false,

      'ui.plugins.domains.change-registrar': false,
      'ui.plugins.domains.contact-info': false,
      'ui.plugins.domains.contacts.show-client': false,
    },
  };

  constructor(
    private config: ConfigService,
  ) {
  }

  feature(featureName: string): boolean {
    if (this.features[this.config.currentConfigurationName]) {
      return !!this.features[this.config.currentConfigurationName][featureName];
    }

    return false;
  }
}
