Giter VIP home page Giter VIP logo

inertia_phoenix's People

Contributors

bigx333 avatar codacy-badger avatar dependabot-preview[bot] avatar ozziexsh avatar sztheory avatar tmartin8080 avatar zimt28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

inertia_phoenix's Issues

Only 1 flash per type is included in page data

Describe the bug

  ...
  put_flash(conn, :info, "Info flash")
  |> put_flash(:danger, "Danger flash!")
  |> put_flash(:danger, "Another danger flash!")
  |> redirect(to: "/about")
  ...

results in:

{"flash":{"danger":"Another danger flash!","info":"Info flash"}}

Expected behavior
I would expect to see an array of all flashes, and in order that they were added perhaps:

{"flash":[{"info":"Info flash"},{"danger":"Danger flash!"},{"danger":"Another danger flash!"}]}

Not sure if this is a limitation with the way Phoenix handles flashes?

Will have a go at a PR if you see this as a valid issue!

Should rendering non-existent route raise error?

Is your feature request related to a problem? Please describe.
I find that if I have a controller action like this:

  def does_not_exist(conn, _) do
    render_inertia(conn, "DoesNotExist", props: %{hello: "world"})
  end

Describe the solution you'd like
My Phoenix app renders with a 200 without error, whereas I would prefer to raise error if the template wasn't found, what do you think?

Add asset-versioning

Asset Versioning:

One common challenge with single-page apps is refreshing site assets when they've been changed. Inertia makes this easy by optionally tracking the current version of your site assets. In the event that an asset changes, Inertia will automatically make a hard page visit instead of a normal ajax visit on the next request.

https://inertiajs.com/asset-versioning

Add partial reloads

https://inertiajs.com/requests#partial-reloads

The only option allows you to request a subset of the props (data) from the server on subsequent visits to the same page. This feature is called partial reloads, and can be a helpful performance optimization if it's acceptable that some page data becomes stale. For partial reloads to be effective, be sure to use lazy evaluation server-side.

Add proper docs

Add proper docs for package using ex_doc.

  • Getting Started
  • Module/Function docs
  • Tips for React/Vue/Svelte
  • Anything else that seems important

Add JS Routes Possibly

Exploring the idea of adding a system for Phoenix routes in JS as they're so often used with frontend pages.

Seems like it would be helpful but maybe it would over-complicate the purpose of this lib.

Curious to hear what others think.

Haha, I was looking for this last week

Looks like we had the same idea at the same time! I started knocking something together on the weekend (https://github.com/totaltrash/test_phoenix_inertia), pulled out the Inertia stuff into a library just now (https://github.com/ifixsystems-au/inertia-phoenix), had a look on Hex, and found you've been busy on the weekend too!

Looking good, pretty excited about Inertia and Elixir (I'm not an Elixir developer, I was just looking for a project to do on the weekend).

Controller Testing Documentation

I've starting using this in a new project I am working on and during controller testing I made a helper that I add to my conn_case.ex that maybe other people would find useful? I can add some documentation as a PR if this is something anyone would want. If not, just putting this here in case it helps someone.

def inertia_response(conn, status \\ 200) do
    response = Phoenix.ConnTest.html_response(conn, status)

    case Regex.run(~r/data-page=\"(.+?)\"/, response) do
      [_, injected_data] ->
        injected_data |> String.replace(""", "\"") |> Jason.decode!()

      _ ->
        nil
    end
  end

Then you can use it a test like:

conn = get(conn, Routes.customer_quotations_path(conn, :index))
response = inertia_response(conn, 200)

Which gives you a map of the inertia injected data on the page:

%{
  "component" => "QuotationList",
  "props" => %{
    "quotations" => [
      %{
        "completed" => false,
        "id" => 1,
        "status" => "awaiting_quotation",
        "updated_at" => "2020-09-04T02:02:14"
      }
    ]
  },
  "url" => "/quotations",
  "version" => "1"
}

This can be useful to assert the correct component is being rendered, or assert about the props being injected into the component.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.