From 51a765ae72ade8e446f885d0a93f8df6fe2c7fa0 Mon Sep 17 00:00:00 2001 From: Noah Schechter <100018299+noah-schechter@users.noreply.github.com> Date: Mon, 2 Sep 2024 06:54:01 +0000 Subject: [PATCH 1/5] Add in-platform API docs --- .../api_documentation_component.ex | 186 ++++++++++++++++++ .../platform_web/live/projects_live/show.ex | 5 + 2 files changed, 191 insertions(+) create mode 100644 platform/lib/platform_web/live/projects_live/api_documentation_component.ex diff --git a/platform/lib/platform_web/live/projects_live/api_documentation_component.ex b/platform/lib/platform_web/live/projects_live/api_documentation_component.ex new file mode 100644 index 000000000..ba92f64d5 --- /dev/null +++ b/platform/lib/platform_web/live/projects_live/api_documentation_component.ex @@ -0,0 +1,186 @@ +defmodule PlatformWeb.ProjectLive.APIDoc do + use PlatformWeb, :live_component + + alias Platform.Projects + alias Platform.Material.Attribute + + def update(%{project: project} = assigns, socket) do + IO.inspect(project.name) + attributes = Platform.Material.Attribute.active_attributes(project: project) + attribute_labels = Map.new(attributes, &{&1.name, &1.label}) + + grouped_attributes = group_attributes(attributes, project) + + {:ok, + socket + |> assign(assigns) + |> assign(:grouped_attributes, grouped_attributes) + |> assign(:attribute_labels, attribute_labels) + |> assign(:project, project)} + end + + def render(assigns) do + ~H""" +
API Details
++ The Atlos API uses API-specific identifers, rather than interface names, to refer to attributes, metadata, and even the project itself. Learn more in our + + + API documentation. + + +
++ + <%= cond do %> + <% group == :metadata -> %> + Metadata + <% group == :project -> %> + Project + <% true -> %> + <%= group.name %> + <% end %> + +
++ <%= cond do %> + <% group == :metadata -> %> + Use the API to access or update incident metadata in the same way as other attributes. + <% group == :project -> %> + Use this identifier to refer to this project in the API. + <% true -> %> + <%= group.description %> + <% end %> +
+- - <%= cond do %> - <% group == :metadata -> %> - Metadata - <% group == :project -> %> - Project - <% true -> %> - <%= group.name %> + + <%= if group == :metadata do %> + Metadata + <% else %> + <%= group.name %> <% end %>
- <%= cond do %> - <% group == :metadata -> %> - Use the API to access or update incident metadata in the same way as other attributes. - <% group == :project -> %> - Use this identifier to refer to this project in the API. - <% true -> %> - <%= group.description %> + <%= if group == :metadata do %> + Use the API to access or update incident metadata in the same way as other attributes. + <% else %> + <%= group.description %> <% end %>