Skip to content

Commit

Permalink
Merge branch 'release/0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo0807 committed Jun 27, 2024
2 parents 1dd6cb1 + 54f13ee commit 6c4e6eb
Show file tree
Hide file tree
Showing 83 changed files with 45,494 additions and 45,088 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ RUN mix do deps.get, deps.compile, assets.deploy, sentry.package_source_code, re
# Stage: runtime
########################################################################

FROM alpine:3.20.0 as runtime
FROM alpine:3.20.1 as runtime

ENV APP_HOME=/opt/app
WORKDIR $APP_HOME
Expand Down
45 changes: 44 additions & 1 deletion demo/assets/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const plugin = require('tailwindcss/plugin')
const fs = require('fs')
const path = require('path')

module.exports = {
daisyui: {
Expand Down Expand Up @@ -41,6 +43,47 @@ module.exports = {
plugin(({ addVariant }) => addVariant('phx-no-feedback', ['.phx-no-feedback&', '.phx-no-feedback &'])),
plugin(({ addVariant }) => addVariant('phx-click-loading', ['.phx-click-loading&', '.phx-click-loading &'])),
plugin(({ addVariant }) => addVariant('phx-submit-loading', ['.phx-submit-loading&', '.phx-submit-loading &'])),
plugin(({ addVariant }) => addVariant('phx-change-loading', ['.phx-change-loading&', '.phx-change-loading &']))
plugin(({ addVariant }) => addVariant('phx-change-loading', ['.phx-change-loading&', '.phx-change-loading &'])),
// Embeds Heroicons (https://heroicons.com) into your app.css bundle
// See your `CoreComponents.icon/1` for more information.
//
plugin(function ({ matchComponents, theme }) {
let iconsDir = path.join(__dirname, "../deps/heroicons/optimized")
let values = {}
let icons = [
["", "/24/outline"],
["-solid", "/24/solid"],
["-mini", "/20/solid"],
["-micro", "/16/solid"]
]
icons.forEach(([suffix, dir]) => {
fs.readdirSync(path.join(iconsDir, dir)).forEach(file => {
let name = path.basename(file, ".svg") + suffix
values[name] = { name, fullPath: path.join(iconsDir, dir, file) }
})
})
matchComponents({
"hero": ({ name, fullPath }) => {
let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "")
let size = theme("spacing.6")
if (name.endsWith("-mini")) {
size = theme("spacing.5")
} else if (name.endsWith("-micro")) {
size = theme("spacing.4")
}
return {
[`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`,
"-webkit-mask": `var(--hero-${name})`,
"mask": `var(--hero-${name})`,
"mask-repeat": "no-repeat",
"background-color": "currentColor",
"vertical-align": "middle",
"display": "inline-block",
"width": size,
"height": size
}
}
}, { values })
})
]
}
10 changes: 5 additions & 5 deletions demo/lib/demo/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ defmodule Demo.Address do
@primary_key {:id, :binary_id, autogenerate: true}

schema "addresses" do
field(:street, :string)
field(:zip, :string)
field(:city, :string)
field(:country, Ecto.Enum, values: [:de, :at, :ch])
field(:full_address, :string, virtual: true)
field :street, :string
field :zip, :string
field :city, :string
field :country, Ecto.Enum, values: [:de, :at, :ch]
field :full_address, :string, virtual: true

timestamps()
end
Expand Down
4 changes: 2 additions & 2 deletions demo/lib/demo/film_review.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ defmodule Demo.FilmReview do
@primary_key {:id, :binary_id, autogenerate: true}

schema "film_reviews" do
field(:title, :string)
field(:overview, :string)
field :title, :string
field :overview, :string
end

@required_fields ~w[title overview]a
Expand Down
5 changes: 2 additions & 3 deletions demo/lib/demo/invoice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ defmodule Demo.Invoice do
@primary_key {:id, :binary_id, autogenerate: true}

schema "invoices" do
field(:company, :string)
field :company, :string

field(:amount, Backpex.Ecto.Amount.Type,
field :amount, Backpex.Ecto.Amount.Type,
currency: :EUR,
opts: [separator: ".", delimiter: ",", symbol_on_right: true, symbol_space: true]
)

timestamps()
end
Expand Down
19 changes: 10 additions & 9 deletions demo/lib/demo/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ defmodule Demo.Post do
@primary_key {:id, :binary_id, autogenerate: true}

schema "posts" do
field(:title, :string)
field(:body, :string)
field(:published, :boolean, default: false)
field(:show_likes, :boolean, virtual: true)
field(:likes, :integer, default: 0)

belongs_to(:user, Demo.User, type: :binary_id)
belongs_to(:category, Demo.Category, type: :binary_id)
many_to_many(:tags, Demo.Tag, join_through: Demo.PostsTags, on_replace: :delete)
field :title, :string
field :body, :string
field :published, :boolean, default: false
field :show_likes, :boolean, virtual: true
field :likes, :integer, default: 0

belongs_to :user, Demo.User, type: :id
belongs_to :category, Demo.Category, type: :binary_id

many_to_many :tags, Demo.Tag, join_through: Demo.PostsTags, on_replace: :delete

timestamps()
end
Expand Down
4 changes: 2 additions & 2 deletions demo/lib/demo/posts_tags.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ defmodule Demo.PostsTags do
@primary_key {:id, :binary_id, autogenerate: true}

schema "posts_tags" do
belongs_to(:post, Post, type: :binary_id)
belongs_to(:tag, Tag, type: :binary_id)
belongs_to :post, Post, type: :binary_id
belongs_to :tag, Tag, type: :binary_id

timestamps()
end
Expand Down
13 changes: 6 additions & 7 deletions demo/lib/demo/product.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ defmodule Demo.Product do
@primary_key {:id, :binary_id, autogenerate: true}

schema "products" do
field(:name, :string)
field(:quantity, :integer)
field(:manufacturer, :string)
field(:images, {:array, :string})
field :name, :string
field :quantity, :integer
field :manufacturer, :string
field :images, {:array, :string}

field(:price, Backpex.Ecto.Amount.Type,
field :price, Backpex.Ecto.Amount.Type,
currency: :EUR,
opts: [separator: ".", delimiter: ",", symbol_on_right: true, symbol_space: true]
)

has_many(:suppliers, Supplier, on_replace: :delete, on_delete: :delete_all)
has_many :suppliers, Supplier, on_replace: :delete, on_delete: :delete_all

timestamps()
end
Expand Down
1 change: 1 addition & 0 deletions demo/lib/demo/supplier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule Demo.Supplier do
schema "suppliers" do
field :name, :string
field :url, :string

belongs_to :product, Demo.Product, type: :binary_id

timestamps()
Expand Down
2 changes: 1 addition & 1 deletion demo/lib/demo/tag.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Demo.Tag do
schema "tags" do
field :name, :string

many_to_many(:posts, Demo.Post, join_through: Demo.PostsTags, on_replace: :delete)
many_to_many :posts, Demo.Post, join_through: Demo.PostsTags, on_replace: :delete

timestamps()
end
Expand Down
29 changes: 13 additions & 16 deletions demo/lib/demo/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ defmodule Demo.User do
alias Demo.Post
alias Demo.UsersAddresses

@primary_key {:id, :binary_id, autogenerate: true}

schema "users" do
field(:username, :string)
field(:first_name, :string)
field(:last_name, :string)
field(:full_name, :string, virtual: true)
field(:age, :integer)
field(:role, Ecto.Enum, values: [:user, :admin])
field(:permissions, {:array, :string})
field(:avatar, :string)
field(:deleted_at, :utc_datetime)

has_many(:posts, Post, on_replace: :nilify)

has_many(:users_addresses, UsersAddresses, on_replace: :delete, on_delete: :delete_all)
has_many(:addresses, through: [:users_addresses, :address])
field :username, :string
field :first_name, :string
field :last_name, :string
field :full_name, :string, virtual: true
field :age, :integer
field :role, Ecto.Enum, values: [:user, :admin]
field :permissions, {:array, :string}
field :avatar, :string
field :deleted_at, :utc_datetime

has_many :posts, Post, on_replace: :nilify
has_many :users_addresses, UsersAddresses, on_replace: :delete, on_delete: :delete_all
has_many :addresses, through: [:users_addresses, :address]

embeds_many :social_links, SocialLink, on_replace: :delete do
field :label, :string
Expand Down
9 changes: 5 additions & 4 deletions demo/lib/demo/users_addresses.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ defmodule Demo.UsersAddresses do
@primary_key {:id, :binary_id, autogenerate: true}

schema "users_addresses" do
belongs_to(:user, User, type: :binary_id)
belongs_to(:address, Address, type: :binary_id)
field(:type, Ecto.Enum, values: [:shipping, :billing])
field(:primary, :boolean, default: false)
belongs_to :user, User, type: :id
belongs_to :address, Address, type: :binary_id

field :type, Ecto.Enum, values: [:shipping, :billing]
field :primary, :boolean, default: false

timestamps()
end
Expand Down
20 changes: 10 additions & 10 deletions demo/lib/demo_web/components/layouts/admin.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
<Backpex.HTML.Layout.topbar_dropdown>
<:label>
<label tabindex="0" class="btn btn-square btn-ghost">
<Heroicons.user class="h-8 w-8" />
<Backpex.HTML.CoreComponents.icon name="hero-user" class="h-8 w-8" />
</label>
</:label>
<li>
<.link navigate="/" class="flex justify-between text-red-600 hover:bg-gray-100">
<p>Logout</p>
<Heroicons.arrow_right_on_rectangle class="h-5 w-5" />
<Backpex.HTML.CoreComponents.icon name="hero-arrow-right-on-rectangle" class="h-5 w-5" />
</.link>
</li>
</Backpex.HTML.Layout.topbar_dropdown>
</:topbar>
<:sidebar>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/users">
<Heroicons.user class="h-5 w-5" /> Users
<Backpex.HTML.CoreComponents.icon name="hero-user" class="h-5 w-5" /> Users
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/addresses">
<Heroicons.building_office_2 class="h-5 w-5" /> Addresses
<Backpex.HTML.CoreComponents.icon name="hero-building-office-2" class="h-5 w-5" /> Addresses
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/products">
<Heroicons.shopping_bag class="h-5 w-5" /> Products
<Backpex.HTML.CoreComponents.icon name="hero-shopping-bag" class="h-5 w-5" /> Products
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/invoices">
<Heroicons.document_text class="h-5 w-5" /> Invoices
<Backpex.HTML.CoreComponents.icon name="hero-document-text" class="h-5 w-5" /> Invoices
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/film-reviews">
<Heroicons.film class="h-5 w-5" /> Film Reviews
<Backpex.HTML.CoreComponents.icon name="hero-film" class="h-5 w-5" /> Film Reviews
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_section id="blog">
<:label>Blog</:label>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/posts">
<Heroicons.book_open class="h-5 w-5" /> Posts
<Backpex.HTML.CoreComponents.icon name="hero-book-open" class="h-5 w-5" /> Posts
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/categories">
<Heroicons.tag class="h-5 w-5" /> Categories
<Backpex.HTML.CoreComponents.icon name="hero-tag" class="h-5 w-5" /> Categories
</Backpex.HTML.Layout.sidebar_item>
<Backpex.HTML.Layout.sidebar_item current_url={@current_url} navigate="/admin/tags">
<Heroicons.tag class="h-5 w-5" /> Tags
<Backpex.HTML.CoreComponents.icon name="hero-tag" class="h-5 w-5" /> Tags
</Backpex.HTML.Layout.sidebar_item>
</Backpex.HTML.Layout.sidebar_section>
</:sidebar>
Expand Down
9 changes: 7 additions & 2 deletions demo/lib/demo_web/item_actions/duplicate_tag.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ defmodule DemoWeb.ItemActions.DuplicateTag do
@impl Backpex.ItemAction
def icon(assigns) do
~H"""
<Heroicons.document_duplicate class="h-5 w-5 cursor-pointer transition duration-75 hover:scale-110 hover:text-green-600" />
<Backpex.HTML.CoreComponents.icon
name="hero-document-duplicate"
class="h-5 w-5 cursor-pointer transition duration-75 hover:scale-110 hover:text-green-600"
/>
"""
end

Expand Down Expand Up @@ -49,7 +52,9 @@ defmodule DemoWeb.ItemActions.DuplicateTag do
end

@impl Backpex.ItemAction
def handle(socket, _items, params) do
def handle(socket, _items, data) do
params = Map.from_struct(data)

result =
%Demo.Tag{}
|> Demo.Tag.create_changeset(params, target: nil, assigns: socket.assigns)
Expand Down
7 changes: 5 additions & 2 deletions demo/lib/demo_web/item_actions/soft_delete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ defmodule DemoWeb.ItemActions.SoftDelete do
@impl Backpex.ItemAction
def icon(assigns) do
~H"""
<Heroicons.trash class="h-5 w-5 cursor-pointer transition duration-75 hover:scale-110 hover:text-red-600" />
<Backpex.HTML.CoreComponents.icon
name="hero-trash"
class="h-5 w-5 cursor-pointer transition duration-75 hover:scale-110 hover:text-red-600"
/>
"""
end

Expand Down Expand Up @@ -55,7 +58,7 @@ defmodule DemoWeb.ItemActions.SoftDelete do
end

@impl Backpex.ItemAction
def handle(socket, items, _params) do
def handle(socket, items, _data) do
datetime = DateTime.truncate(DateTime.utc_now(), :second)

socket =
Expand Down
2 changes: 1 addition & 1 deletion demo/lib/demo_web/live/film_review_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule DemoWeb.FilmReviewLive do
def render_resource_slot(assigns, :index, :before_page_title) do
~H"""
<div class="alert my-4 bg-blue-100 text-sm text-blue-800">
<Heroicons.information_circle class="h-5 w-5" />
<Backpex.HTML.CoreComponents.icon name="hero-information-circle" class="h-5 w-5" />
<span>
This resource uses the full-text search functionality. The search accepts web search query operators. For example, a dash (-) excludes words.
</span>
Expand Down
2 changes: 1 addition & 1 deletion demo/lib/demo_web/live/home_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ defmodule DemoWeb.HomeLive.Index do
<dl class="mt-20 grid grid-cols-1 gap-12 sm:grid-cols-2 sm:gap-x-6 lg:grid-cols-4 lg:gap-x-8">
<div :for={feature <- @feature} class="relative">
<dt>
<Heroicons.check class="text-primary absolute mt-1 h-6 w-6" />
<Backpex.HTML.CoreComponents.icon name="hero-check" class="text-primary absolute mt-1 h-6 w-6" />
<p class="ml-10 text-lg font-semibold leading-8 text-gray-900">
<%= feature.title %>
</p>
Expand Down
6 changes: 3 additions & 3 deletions demo/lib/demo_web/live/home_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
<h1 class="mt-10 text-4xl font-bold tracking-tight text-gray-900 sm:text-6xl">
Phoenix Admin Panel built with
<em class="text-primary-800 cursor-help leading-none tracking-wide">
<em class="text-primary-800 cursor-help whitespace-nowrap leading-none tracking-wide">
<abbr
:for={tech <- ["Phoenix Framework", "Elixir", "Tailwind CSS", "Alpine.js", "LiveView"]}
title={tech}
Expand All @@ -35,7 +35,7 @@
>
GitHub
</.link>
<Heroicons.arrow_right class="ml-2 h-4 w-4" />
<Backpex.HTML.CoreComponents.icon name="hero-arrow_right" class="ml-2 h-4 w-4" />
</div>
<div :if={not @form_hidden?} class="bg-white py-8 sm:py-12 lg:py-16">
<h2 class="text-xl font-bold tracking-tight text-gray-900 sm:text-lg">
Expand All @@ -47,7 +47,7 @@
</.form>

<div :if={not @subscribed?} class="alert my-4 bg-blue-100 text-sm text-blue-800">
<Heroicons.information_circle class="h-5 w-5" />
<Backpex.HTML.CoreComponents.icon name="hero-information-circle" class="h-5 w-5" />
<p>
You successfully subscribed to the Backpex newsletter. Please check your inbox to confirm your email address!
</p>
Expand Down
4 changes: 2 additions & 2 deletions demo/lib/demo_web/live/product_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ defmodule DemoWeb.ProductLive do
defp list_existing_files(%{images: images} = _item) when is_list(images), do: images
defp list_existing_files(_item), do: []

defp put_upload_change(_socket, change, item, uploaded_entries, removed_entries, action) do
defp put_upload_change(_socket, params, item, uploaded_entries, removed_entries, action) do
existing_files = list_existing_files(item) -- removed_entries

new_entries =
Expand All @@ -131,7 +131,7 @@ defmodule DemoWeb.ProductLive do

files = existing_files ++ Enum.map(new_entries, fn entry -> file_name(entry) end)

Map.put(change, "images", files)
Map.put(params, "images", files)
end

# sobelow_skip ["Traversal"]
Expand Down
Loading

0 comments on commit 6c4e6eb

Please sign in to comment.