import { Component, OnInit } from '@angular/core';
import { IObjectController } from '@objects-view/interfaces/object-controller';
import { StaticObjectController } from '@objects-view/static-object-controller';
import { ActivatedRoute, Router } from '@angular/router';
import {
  EditSaml2IdentityProviderComponent
} from '../tabs/edit-saml2-identity-provider/edit-saml2-identity-provider.component';
import { RouterLinkAction } from '@objects-view/actions/router-link-action';
import { CallbackAction } from '@objects-view/actions/callback-action';
import { ConfigService } from '@shared/config/config.service';

@Component({
  selector: 'app-saml2-identity-provider-edit',
  templateUrl: './saml2-identity-provider-edit.component.html',
  styleUrls: ['./saml2-identity-provider-edit.component.scss']
})
export class Saml2IdentityProviderEditComponent implements OnInit {
  public objectController: IObjectController = new StaticObjectController({
    header: {
      title: {
        text: $localize`Edit SAML 2 identity provider`,
      }
    },
    tabs: [
      {
        tabName: $localize`Edit SAML 2 identity provider`,
        tabIdentifier: 'edit-saml-2-identity-provider',
        component: EditSaml2IdentityProviderComponent,
      },
    ],
    detailsActions: [
      new RouterLinkAction({
        name: $localize`Cancel`,
        routerUrl: this.config.getPanelUrl(`settings/general`),
        fragment: `single-sign-on`,
        router: this.router,
      }),
      new CallbackAction({
        name: $localize`Save SAML 2 identity provider`,
      })
    ],
  });

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

  ngOnInit(): void {
    this.objectController.object = this.activatedRoute.snapshot.data.saml2IdentityProvider;
  }
}
