Skip to content

Commit

Permalink
Add some helpful configuration info to README.md (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgraff authored Jul 30, 2023
1 parent a99ace2 commit 3718aaa
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Ensure your apis are configured in `config.exs`
config :my_app, ash_apis: [MyApp.Foo, MyApp.Bar]
```

Add the admin extension to each api you want to show in the admin dashboard, and configure it to show
Add the admin extension to each api you want to show in AshAdmin dashboard, and configure it to show. See [`AshAdmin.Api`](https://hexdocs.pm/ash_admin/AshAdmin.Api.html) for more configuration options.

```elixir
# In your Api(s)
use Ash.Api,
extensions: [AshAdmin.Api]

Expand All @@ -38,7 +39,19 @@ admin do
end
```

Modify your router to add ash admin at whatever path you'd like to serve it at.
Resources in each Api will be automagically included in AshAdmin. See [`AshAdmin.Resource`](https://hexdocs.pm/ash_admin/AshAdmin.Resource.html) for more resource configuration options. Specifically, if you app has an actor you will want to configure that. Ash Admin allows you to change actors and therefore doesn't rely on `Ash.set_actor`

```elixir
# In your resource that acts as an actor (e.g. User)
use Ash.Resource,
extensions: [AshAdmin.Resource]

admin do
actor?(true)
end
```

Modify your router to add AshAdmin at whatever path you'd like to serve it at.

```elixir
defmodule MyAppWeb.Router do
Expand All @@ -60,6 +73,8 @@ defmodule MyAppWeb.Router do
end
```

**Note: there is no builtin security for your AshAdmin (except your apps normal policies). In most cases you will want to secure your AshAdmin routes in some way to prevent them from being public**

Now start your project (usually by running `mix phx.server` in a terminal) and visit `/admin` in your browser (or whatever path you gave to `ash_admin` in your router).

### Content Security Policy
Expand All @@ -84,6 +99,10 @@ This will allow AshAdmin-generated inline CSS and JS blocks to execute normally.

See the documentation in [`AshAdmin.Resource`](https://hexdocs.pm/ash_admin/AshAdmin.Resource.html) and [`AshAdmin.Api`](https://hexdocs.pm/ash_admin/AshAdmin.Api.html) for information on the available configuration.

## Troubleshooting

If your Admin UI is not responding as expected. Check your browser's developer console for content-security-policy violations (see above).

## Development

To work on ash_admin, you'll want to be able to run the dev app. You'll need to have postgres setup locally, at which point you can do the following:
Expand Down

0 comments on commit 3718aaa

Please sign in to comment.