export default {
  props: {
    objectName: String,
    disabled: Boolean,
    title: String,
    type: { type: String, default: "default" },
  },
  methods: {
    renderText() {
      return [
        <a-icon type="cloud-upload" />,
        this.title || this.$t("BATCH_IMPORT"),
      ];
    },
    handleClick() {
      const { fullPath, query = {} } = this.$route;

      this.$router.push({
        path: "/batch-import",
        query: {
          prevUrl: fullPath,
          objectName: this.objectName || undefined,
          ...query,
        },
      });
    },
  },
  render() {
    const defaultText = this.$scopedSlots.default
      ? this.$scopedSlots.default()
      : this.renderText();
    const props = {
      props: {
        ...this.$props,
      },
      on: {
        click: this.handleClick,
      },
    };
    return (
      <a-button {...props} class="btn__blue-2">
        {defaultText}
      </a-button>
    );
  },
};
