import { Component, OnInit } from '@angular/core';
import { StaticObjectController } from '@objects-view/static-object-controller';
import { RouterLinkAction } from '@objects-view/actions/router-link-action';
import { ConfigService } from '@shared/config/config.service';
import { ActivatedRoute, Router } from '@angular/router';
import { CallbackAction } from '@objects-view/actions/callback-action';
import { ListenerCreateFormComponent } from '../tabs/listener-create-form/listener-create-form.component';

@Component({
  selector: 'app-listener-create',
  templateUrl: './listener-create.component.html',
  styleUrls: ['./listener-create.component.scss']
})
export class ListenerCreateComponent implements OnInit {
  objectController = new StaticObjectController(
    {
      header: {
        title: {
          text: $localize`Create new listener`,
        }
      },
      tabs: [
        {
          tabName: $localize`Create`,
          tabIdentifier: 'create',
          component: ListenerCreateFormComponent,
        },
      ],
      detailsActions: [
        new RouterLinkAction({
            name: $localize`Cancel`,
            routerUrl: this.config.getPanelUrl(
              'openstack/load-balancers',
              this.activatedRoute.snapshot.params.loadBalancerId,
            ),
            router: this.router,
            propagateQueryParams: ['region'],
          }
        ),
        new CallbackAction({name: $localize`Back`, internalName: 'back', propagateQueryParams: ['region'],}),
        new CallbackAction({name: $localize`Next`, internalName: 'next', propagateQueryParams: ['region'],}),
        new CallbackAction(
          {name: $localize`Create listener`, internalName: 'create', propagateQueryParams: ['region'],}
        ),
      ]
    },
    null,
    {
      createOptions: this.activatedRoute.snapshot.data.createOptions,
    }
  );

  constructor(
    public config: ConfigService,
    private router: Router,
    private activatedRoute: ActivatedRoute,
  ) {
  }

  ngOnInit(): void {
  }
}
