syntax = "proto3";

package com.wixpress.appservice.api;

import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "wix/api/annotations.proto";
import "components_catalog_common.proto";

// A component that enables extending a Wix dashboard menu.
message BackOfficeExtensionMenuItem {
  // Platform that hosts the modal.
  // 
  // Must be `"BUSINESS_MANAGER"`.
  BackOfficeHostingPlatforms hosting_platform = 1;

  // Slot ID for the plugin's container.
  string extends = 2 [(wix.api.format) = GUID];

  // Extension description.
  google.protobuf.StringValue description = 3;

  // Extension title.
  string title = 4 [(wix.api.translatable) = {
    type: SHORT_TEXT
    grouping: "title"
  }];


  // Menu item subtitle.
  google.protobuf.StringValue subtitle = 5 [(wix.api.translatable) = {
    type: SHORT_TEXT
    grouping: "subtitle"
  }, (wix.api.maxLength) = 200];

  // [Wix Design System icon](https://www.wix-pages.com/wix-design-system-employees/?path=/story/foundations-icons--icons).
  // Use the full size key. The icon will be rendered in an appropriate size.
  google.protobuf.StringValue icon_key = 6 [(wix.api.minLength) = 3, (wix.api.maxLength) = 50];
  
  // Required permission to view the extension.
  string required_permission = 7 [(wix.api.field_exposure) = INTERNAL];

  // Sentry error reporting DSN (internal)
  ErrorReporting error_reporting = 8 [(wix.api.field_exposure) = INTERNAL];

  // Action that takes places when the menu item is clicked.
  MenuAction action = 9;

  message MenuAction {
    oneof action {
      NavigateToPageAction navigate_to_page = 1;
      OpenModalAction open_modal = 2;
    }
  }

  message NavigateToPageAction {
    // ID for the target [page](https://dev.wix.com/docs/sdk/host-modules/dashboard/page-ids).
    string page_id = 1 [(wix.api.format) = GUID];
    // Relative URL to append to the base page URL. May include path segments, search params, and hash.
    google.protobuf.StringValue relative_url = 2;
  }

  message OpenModalAction {
    // ID of the modal to open.
    string component_id = 1 [(wix.api.format) = GUID];
    // Modal parameters.
    map<string, string> component_params = 2;
  }
}