import { DateField } from '@dvn/core/doldurma/src/fields/date';
import { TextField } from '@dvn/core/doldurma/src/fields/text';
import { ListFetchState } from '@dvn/core/models/list-fetch-state';
import { Component, h, Host, Prop, State } from '@stencil/core';
import { RawDataField } from '@dvn/core/doldurma/src/fields/raw-data';
export class KimlikSAMLConfigList {
  constructor() {
    this.list = ListFetchState.init();
  }
  componentWillLoad() {
    this.fetchList();
  }
  async fetchList() {
    const { list } = this;
    this.list = this.list.beforeFetch();
    const response = await this.apiKimlik.getSAMLConfigs().catch(error => {
      this.list = list.afterFetchError(error);
    });
    if (!response)
      return;
    this.list = list.afterFetch(response, false);
  }
  render() {
    const { list } = this;
    return (h(Host, { class: "container d-flex flex-grow-1 flex-column" },
      h("dvn-list-view-table", { config: {
          actions: [
            {
              ui: {
                name: 'edit',
                buttonType: 'icon-button',
                iconName: 'uil uil-pen',
                view: 'flat',
              },
            },
            {
              ui: {
                name: 'clone',
                buttonType: 'icon-button',
                iconName: 'uil uil-copy',
                view: 'flat',
              },
            },
            {
              ui: {
                name: 'delete',
                buttonType: 'icon-button',
                iconName: 'uil uil-trash',
                view: 'flat',
                tint: 'danger',
              },
            },
          ],
          fields: [
            { fieldId: 'name' },
            { fieldId: '_created' },
            { fieldId: '_id' },
          ]
        }, fields: [
          new TextField('name', 'Name'),
          new DateField('_created', 'Creation Date'),
          new RawDataField('_id', 'ID'),
        ], items: (list.data || []).sort((a, b) => { var _a; return (_a = a.name) === null || _a === void 0 ? void 0 : _a.localeCompare(b.name); }), isEndReached: list.isEndReached(), isProgressing: list.isPending, error: list.error ? 'Fetching list failed' : undefined, onRetry: () => this.fetchList(), scrollToFit: true })));
  }
  static get is() { return "kimlik-saml-config-list"; }
  static get properties() { return {
    "apiKimlik": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "KimlikApi",
        "resolved": "KimlikApi",
        "references": {
          "KimlikApi": {
            "location": "import",
            "path": "../../api/kimlik-api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "list": {}
  }; }
}
