fix visibility issues with multiple users

This commit is contained in:
shibao 2025-02-15 04:24:53 +00:00
parent 3e686fa199
commit 6c2aba84ef
32 changed files with 187 additions and 413 deletions

View File

@ -1,3 +1,6 @@
# v0.1.19
- Fix visibility issues with multiple users
# v0.1.18 # v0.1.18
- Update deps - Update deps
- Fix content not escaping HTML properly - Fix content not escaping HTML properly

View File

@ -22,16 +22,16 @@ defmodule Memex.Contexts do
@spec list_contexts(search :: String.t() | nil, User.t()) :: [Context.t()] @spec list_contexts(search :: String.t() | nil, User.t()) :: [Context.t()]
def list_contexts(search \\ nil, user) def list_contexts(search \\ nil, user)
def list_contexts(search, %{id: user_id}) when search in [nil, ""] do def list_contexts(search, %{id: user_id}) when user_id |> is_binary() and search in [nil, ""] do
Repo.all(from c in Context, where: c.user_id == ^user_id, order_by: c.slug) Repo.all(from c in Context, order_by: c.slug)
end end
def list_contexts(search, %{id: user_id}) when search |> is_binary() do def list_contexts(search, %{id: user_id})
when user_id |> is_binary() and search |> is_binary() do
trimmed_search = String.trim(search) trimmed_search = String.trim(search)
Repo.all( Repo.all(
from c in Context, from c in Context,
where: c.user_id == ^user_id,
where: where:
fragment( fragment(
"search @@ websearch_to_tsquery('english', ?)", "search @@ websearch_to_tsquery('english', ?)",
@ -103,12 +103,8 @@ defmodule Memex.Contexts do
""" """
@spec get_context!(Context.id(), User.t()) :: Context.t() @spec get_context!(Context.id(), User.t()) :: Context.t()
def get_context!(id, %{id: user_id}) do def get_context!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!( Repo.one!(from c in Context, where: c.id == ^id)
from c in Context,
where: c.id == ^id,
where: c.user_id == ^user_id or c.visibility in [:public, :unlisted]
)
end end
def get_context!(id, _invalid_user) do def get_context!(id, _invalid_user) do
@ -134,12 +130,8 @@ defmodule Memex.Contexts do
""" """
@spec get_context_by_slug(Context.slug(), User.t()) :: Context.t() | nil @spec get_context_by_slug(Context.slug(), User.t()) :: Context.t() | nil
def get_context_by_slug(slug, %{id: user_id}) do def get_context_by_slug(slug, %{id: user_id}) when user_id |> is_binary() do
Repo.one( Repo.one(from c in Context, where: c.slug == ^slug)
from c in Context,
where: c.slug == ^slug,
where: c.user_id == ^user_id or c.visibility in [:public, :unlisted]
)
end end
def get_context_by_slug(slug, _invalid_user) do def get_context_by_slug(slug, _invalid_user) do
@ -194,23 +186,16 @@ defmodule Memex.Contexts do
## Examples ## Examples
iex> delete_context(%Context{user_id: 123}, %User{id: 123})
{:ok, %Context{}}
iex> delete_context(%Context{user_id: 123}, %User{role: :admin})
{:ok, %Context{}}
iex> delete_context(%Context{}, %User{id: 123}) iex> delete_context(%Context{}, %User{id: 123})
{:ok, %Context{}}
iex> delete_context(%Context{}, nil)
{:error, %Ecto.Changeset{}} {:error, %Ecto.Changeset{}}
""" """
@spec delete_context(Context.t(), User.t()) :: @spec delete_context(Context.t(), User.t()) ::
{:ok, Context.t()} | {:error, Context.changeset()} {:ok, Context.t()} | {:error, Context.changeset()}
def delete_context(%Context{user_id: user_id} = context, %{id: user_id}) do def delete_context(%Context{} = context, %{id: user_id}) when user_id |> is_binary() do
context |> Repo.delete()
end
def delete_context(%Context{} = context, %{role: :admin}) do
context |> Repo.delete() context |> Repo.delete()
end end
@ -228,13 +213,4 @@ defmodule Memex.Contexts do
def change_context(%Context{} = context, attrs \\ %{}, user) do def change_context(%Context{} = context, attrs \\ %{}, user) do
context |> Context.update_changeset(attrs, user) context |> Context.update_changeset(attrs, user)
end end
@spec owner_or_admin?(Context.t(), User.t()) :: boolean()
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
def owner_or_admin?(_context, %{role: :admin}), do: true
def owner_or_admin?(_context, _other_user), do: false
@spec owner?(Context.t(), User.t()) :: boolean()
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
def owner?(_context, _other_user), do: false
end end

View File

@ -63,8 +63,9 @@ defmodule Memex.Contexts.Context do
end end
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset() @spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = note, attrs, %User{id: user_id}) do def update_changeset(%__MODULE__{} = context, attrs, %User{id: user_id})
note when user_id |> is_binary() do
context
|> cast(attrs, [:slug, :content, :tags, :visibility]) |> cast(attrs, [:slug, :content, :tags, :visibility])
|> cast_tags_string(attrs) |> cast_tags_string(attrs)
|> validate_format(:slug, ~r/^[\p{L}\p{N}\-]+$/, |> validate_format(:slug, ~r/^[\p{L}\p{N}\-]+$/,

View File

@ -31,7 +31,6 @@ defmodule Memex.Notes do
Repo.all( Repo.all(
from n in Note, from n in Note,
where: n.user_id == ^user_id,
where: where:
fragment( fragment(
"search @@ websearch_to_tsquery('english', ?)", "search @@ websearch_to_tsquery('english', ?)",
@ -102,12 +101,8 @@ defmodule Memex.Notes do
""" """
@spec get_note!(Note.id(), User.t()) :: Note.t() @spec get_note!(Note.id(), User.t()) :: Note.t()
def get_note!(id, %{id: user_id}) do def get_note!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!( Repo.one!(from n in Note, where: n.id == ^id)
from n in Note,
where: n.id == ^id,
where: n.user_id == ^user_id or n.visibility in [:public, :unlisted]
)
end end
def get_note!(id, _invalid_user) do def get_note!(id, _invalid_user) do
@ -133,12 +128,8 @@ defmodule Memex.Notes do
""" """
@spec get_note_by_slug(Note.slug(), User.t()) :: Note.t() | nil @spec get_note_by_slug(Note.slug(), User.t()) :: Note.t() | nil
def get_note_by_slug(slug, %{id: user_id}) do def get_note_by_slug(slug, %{id: user_id}) when user_id |> is_binary() do
Repo.one( Repo.one(from n in Note, where: n.slug == ^slug)
from n in Note,
where: n.slug == ^slug,
where: n.user_id == ^user_id or n.visibility in [:public, :unlisted]
)
end end
def get_note_by_slug(slug, _invalid_user) do def get_note_by_slug(slug, _invalid_user) do
@ -192,22 +183,15 @@ defmodule Memex.Notes do
## Examples ## Examples
iex> delete_note(%Note{user_id: 123}, %User{id: 123})
{:ok, %Note{}}
iex> delete_note(%Note{}, %User{role: :admin})
{:ok, %Note{}}
iex> delete_note(%Note{}, %User{id: 123}) iex> delete_note(%Note{}, %User{id: 123})
{:ok, %Note{}}
iex> delete_note(%Note{}, nil)
{:error, %Ecto.Changeset{}} {:error, %Ecto.Changeset{}}
""" """
@spec delete_note(Note.t(), User.t()) :: {:ok, Note.t()} | {:error, Note.changeset()} @spec delete_note(Note.t(), User.t()) :: {:ok, Note.t()} | {:error, Note.changeset()}
def delete_note(%Note{user_id: user_id} = note, %{id: user_id}) do def delete_note(%Note{} = note, %{id: user_id}) when user_id |> is_binary() do
note |> Repo.delete()
end
def delete_note(%Note{} = note, %{role: :admin}) do
note |> Repo.delete() note |> Repo.delete()
end end
@ -228,13 +212,4 @@ defmodule Memex.Notes do
def change_note(%Note{} = note, attrs \\ %{}, user) do def change_note(%Note{} = note, attrs \\ %{}, user) do
note |> Note.update_changeset(attrs, user) note |> Note.update_changeset(attrs, user)
end end
@spec owner_or_admin?(Note.t(), User.t()) :: boolean()
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
def owner_or_admin?(_context, %{role: :admin}), do: true
def owner_or_admin?(_context, _other_user), do: false
@spec owner?(Note.t(), User.t()) :: boolean()
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
def owner?(_context, _other_user), do: false
end end

View File

@ -62,7 +62,8 @@ defmodule Memex.Notes.Note do
end end
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset() @spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = note, attrs, %User{id: user_id}) do def update_changeset(%__MODULE__{} = note, attrs, %User{id: user_id})
when user_id |> is_binary() do
note note
|> cast(attrs, [:slug, :content, :tags, :visibility]) |> cast(attrs, [:slug, :content, :tags, :visibility])
|> cast_tags_string(attrs) |> cast_tags_string(attrs)

View File

@ -22,16 +22,17 @@ defmodule Memex.Pipelines do
@spec list_pipelines(search :: String.t() | nil, User.t()) :: [Pipeline.t()] @spec list_pipelines(search :: String.t() | nil, User.t()) :: [Pipeline.t()]
def list_pipelines(search \\ nil, user) def list_pipelines(search \\ nil, user)
def list_pipelines(search, %{id: user_id}) when search in [nil, ""] do def list_pipelines(search, %{id: user_id})
Repo.all(from p in Pipeline, where: p.user_id == ^user_id, order_by: p.slug) when user_id |> is_binary() and search in [nil, ""] do
Repo.all(from p in Pipeline, order_by: p.slug)
end end
def list_pipelines(search, %{id: user_id}) when search |> is_binary() do def list_pipelines(search, %{id: user_id})
when user_id |> is_binary() and search |> is_binary() do
trimmed_search = String.trim(search) trimmed_search = String.trim(search)
Repo.all( Repo.all(
from p in Pipeline, from p in Pipeline,
where: p.user_id == ^user_id,
where: where:
fragment( fragment(
"search @@ websearch_to_tsquery('english', ?)", "search @@ websearch_to_tsquery('english', ?)",
@ -102,12 +103,8 @@ defmodule Memex.Pipelines do
""" """
@spec get_pipeline!(Pipeline.id(), User.t()) :: Pipeline.t() @spec get_pipeline!(Pipeline.id(), User.t()) :: Pipeline.t()
def get_pipeline!(id, %{id: user_id}) do def get_pipeline!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!( Repo.one!(from p in Pipeline, where: p.id == ^id)
from p in Pipeline,
where: p.id == ^id,
where: p.user_id == ^user_id or p.visibility in [:public, :unlisted]
)
end end
def get_pipeline!(id, _invalid_user) do def get_pipeline!(id, _invalid_user) do
@ -133,12 +130,8 @@ defmodule Memex.Pipelines do
""" """
@spec get_pipeline_by_slug(Pipeline.slug(), User.t()) :: Pipeline.t() | nil @spec get_pipeline_by_slug(Pipeline.slug(), User.t()) :: Pipeline.t() | nil
def get_pipeline_by_slug(slug, %{id: user_id}) do def get_pipeline_by_slug(slug, %{id: user_id}) when user_id |> is_binary() do
Repo.one( Repo.one(from p in Pipeline, where: p.slug == ^slug)
from p in Pipeline,
where: p.slug == ^slug,
where: p.user_id == ^user_id or p.visibility in [:public, :unlisted]
)
end end
def get_pipeline_by_slug(slug, _invalid_user) do def get_pipeline_by_slug(slug, _invalid_user) do
@ -193,23 +186,16 @@ defmodule Memex.Pipelines do
## Examples ## Examples
iex> delete_pipeline(%Pipeline{user_id: 123}, %User{id: 123})
{:ok, %Pipeline{}}
iex> delete_pipeline(%Pipeline{}, %User{role: :admin})
{:ok, %Pipeline{}}
iex> delete_pipeline(%Pipeline{}, %User{id: 123}) iex> delete_pipeline(%Pipeline{}, %User{id: 123})
{:ok, %Pipeline{}}
iex> delete_pipeline(%Pipeline{}, nil)
{:error, %Ecto.Changeset{}} {:error, %Ecto.Changeset{}}
""" """
@spec delete_pipeline(Pipeline.t(), User.t()) :: @spec delete_pipeline(Pipeline.t(), User.t()) ::
{:ok, Pipeline.t()} | {:error, Pipeline.changeset()} {:ok, Pipeline.t()} | {:error, Pipeline.changeset()}
def delete_pipeline(%Pipeline{user_id: user_id} = pipeline, %{id: user_id}) do def delete_pipeline(%Pipeline{} = pipeline, %{id: user_id}) when user_id |> is_binary() do
pipeline |> Repo.delete()
end
def delete_pipeline(%Pipeline{} = pipeline, %{role: :admin}) do
pipeline |> Repo.delete() pipeline |> Repo.delete()
end end
@ -230,13 +216,4 @@ defmodule Memex.Pipelines do
def change_pipeline(%Pipeline{} = pipeline, attrs \\ %{}, user) do def change_pipeline(%Pipeline{} = pipeline, attrs \\ %{}, user) do
pipeline |> Pipeline.update_changeset(attrs, user) pipeline |> Pipeline.update_changeset(attrs, user)
end end
@spec owner_or_admin?(Pipeline.t(), User.t()) :: boolean()
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
def owner_or_admin?(_context, %{role: :admin}), do: true
def owner_or_admin?(_context, _other_user), do: false
@spec owner?(Pipeline.t(), User.t()) :: boolean()
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
def owner?(_context, _other_user), do: false
end end

View File

@ -65,7 +65,8 @@ defmodule Memex.Pipelines.Pipeline do
end end
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset() @spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = pipeline, attrs, %User{id: user_id}) do def update_changeset(%__MODULE__{} = pipeline, attrs, %User{id: user_id})
when user_id |> is_binary() do
pipeline pipeline
|> cast(attrs, [:slug, :description, :tags, :visibility]) |> cast(attrs, [:slug, :description, :tags, :visibility])
|> cast_tags_string(attrs) |> cast_tags_string(attrs)

View File

@ -44,9 +44,12 @@ defmodule Memex.Pipelines.Steps.Step do
@doc false @doc false
@spec create_changeset(attrs :: map(), position :: non_neg_integer(), Pipeline.t(), User.t()) :: @spec create_changeset(attrs :: map(), position :: non_neg_integer(), Pipeline.t(), User.t()) ::
changeset() changeset()
def create_changeset(attrs, position, %Pipeline{id: pipeline_id, user_id: user_id}, %User{ def create_changeset(
id: user_id attrs,
}) do position,
%Pipeline{id: pipeline_id, user_id: user_id},
%User{id: user_id}
) do
%__MODULE__{} %__MODULE__{}
|> cast(attrs, [:title, :content]) |> cast(attrs, [:title, :content])
|> change(pipeline_id: pipeline_id, user_id: user_id, position: position) |> change(pipeline_id: pipeline_id, user_id: user_id, position: position)
@ -55,22 +58,16 @@ defmodule Memex.Pipelines.Steps.Step do
@spec update_changeset(t(), attrs :: map(), User.t()) :: @spec update_changeset(t(), attrs :: map(), User.t()) ::
changeset() changeset()
def update_changeset( def update_changeset(%__MODULE__{} = step, attrs, %User{id: user_id})
%{user_id: user_id} = step, when user_id |> is_binary() do
attrs,
%User{id: user_id}
) do
step step
|> cast(attrs, [:title, :content]) |> cast(attrs, [:title, :content])
|> validate_required([:title, :user_id, :position]) |> validate_required([:title, :user_id, :position])
end end
@spec position_changeset(t(), position :: non_neg_integer(), User.t()) :: changeset() @spec position_changeset(t(), position :: non_neg_integer(), User.t()) :: changeset()
def position_changeset( def position_changeset(%__MODULE__{} = step, position, %User{id: user_id})
%{user_id: user_id} = step, when user_id |> is_binary() do
position,
%User{id: user_id}
) do
step step
|> change(position: position) |> change(position: position)
|> validate_required([:title, :user_id, :position]) |> validate_required([:title, :user_id, :position])

View File

@ -21,11 +21,10 @@ defmodule Memex.Pipelines.Steps do
""" """
@spec list_steps(Pipeline.t(), User.t()) :: [Step.t()] @spec list_steps(Pipeline.t(), User.t()) :: [Step.t()]
def list_steps(%{id: pipeline_id}, %{id: user_id}) do def list_steps(%{id: pipeline_id}, %{id: user_id}) when user_id |> is_binary() do
Repo.all( Repo.all(
from s in Step, from s in Step,
where: s.pipeline_id == ^pipeline_id, where: s.pipeline_id == ^pipeline_id,
where: s.user_id == ^user_id,
order_by: s.position order_by: s.position
) )
end end
@ -62,8 +61,8 @@ defmodule Memex.Pipelines.Steps do
""" """
@spec get_step!(Step.id(), User.t()) :: Step.t() @spec get_step!(Step.id(), User.t()) :: Step.t()
def get_step!(id, %{id: user_id}) do def get_step!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!(from n in Step, where: n.id == ^id, where: n.user_id == ^user_id) Repo.one!(from n in Step, where: n.id == ^id)
end end
def get_step!(id, _invalid_user) do def get_step!(id, _invalid_user) do
@ -119,22 +118,15 @@ defmodule Memex.Pipelines.Steps do
## Examples ## Examples
iex> delete_step(%Step{user_id: 123}, %User{id: 123})
{:ok, %Step{}}
iex> delete_step(%Step{}, %User{role: :admin})
{:ok, %Step{}}
iex> delete_step(%Step{}, %User{id: 123}) iex> delete_step(%Step{}, %User{id: 123})
{:ok, %Step{}}
iex> delete_step(%Step{}, nil)
{:error, %Ecto.Changeset{}} {:error, %Ecto.Changeset{}}
""" """
@spec delete_step(Step.t(), User.t()) :: {:ok, Step.t()} | {:error, Step.changeset()} @spec delete_step(Step.t(), User.t()) :: {:ok, Step.t()} | {:error, Step.changeset()}
def delete_step(%Step{user_id: user_id} = step, %{id: user_id}) do def delete_step(%Step{} = step, %{id: user_id}) when user_id |> is_binary() do
delete_step(step)
end
def delete_step(%Step{} = step, %{role: :admin}) do
delete_step(step) delete_step(step)
end end
@ -181,10 +173,11 @@ defmodule Memex.Pipelines.Steps do
def reorder_step(%Step{position: 0} = step, :up, _user), do: {:error, step} def reorder_step(%Step{position: 0} = step, :up, _user), do: {:error, step}
def reorder_step( def reorder_step(
%Step{position: position, pipeline_id: pipeline_id, user_id: user_id} = step, %Step{position: position, pipeline_id: pipeline_id} = step,
:up, :up,
%{id: user_id} = user %{id: user_id} = user
) do )
when user_id |> is_binary() do
Multi.new() Multi.new()
|> Multi.update_all( |> Multi.update_all(
:reorder_steps, :reorder_steps,
@ -207,10 +200,11 @@ defmodule Memex.Pipelines.Steps do
end end
def reorder_step( def reorder_step(
%Step{pipeline_id: pipeline_id, position: position, user_id: user_id} = step, %Step{pipeline_id: pipeline_id, position: position} = step,
:down, :down,
%{id: user_id} = user %{id: user_id} = user
) do )
when user_id |> is_binary() do
Multi.new() Multi.new()
|> Multi.one( |> Multi.one(
:step_count, :step_count,

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl"> <div class="flex flex-col justify-center items-start mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl"> <h1 class="text-xl">
<%= gettext("contexts") %> <%= gettext("contexts") %>
</h1> </h1>
@ -9,7 +9,7 @@
as={:search} as={:search}
phx-change="search" phx-change="search"
phx-submit="search" phx-submit="search"
class="self-stretch flex flex-col items-stretch" class="flex flex-col items-stretch self-stretch"
> >
<%= text_input(f, :search_term, <%= text_input(f, :search_term,
class: "input input-primary", class: "input input-primary",
@ -33,14 +33,14 @@
> >
<:actions :let={context}> <:actions :let={context}>
<.link <.link
:if={Contexts.owner?(context, @current_user)} :if={@current_user}
patch={~p"/contexts/#{context}/edit"} patch={~p"/contexts/#{context}/edit"}
aria-label={dgettext("actions", "edit %{context_slug}", context_slug: context.slug)} aria-label={dgettext("actions", "edit %{context_slug}", context_slug: context.slug)}
> >
<%= dgettext("actions", "edit") %> <%= dgettext("actions", "edit") %>
</.link> </.link>
<.link <.link
:if={Contexts.owner_or_admin?(context, @current_user)} :if={@current_user}
href="#" href="#"
phx-click="delete" phx-click="delete"
phx-value-id={context.id} phx-value-id={context.id}

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl"> <div class="flex flex-col justify-center items-stretch mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl"> <h1 class="text-xl">
<%= @context.slug %> <%= @context.slug %>
</h1> </h1>
@ -15,16 +15,12 @@
<%= gettext("Visibility: %{visibility}", visibility: @context.visibility) %> <%= gettext("Visibility: %{visibility}", visibility: @context.visibility) %>
</p> </p>
<div class="self-end flex space-x-4"> <div class="flex self-end space-x-4">
<.link <.link :if={@current_user} class="btn btn-primary" patch={~p"/context/#{@context}/edit"}>
:if={Contexts.owner?(@context, @current_user)}
class="btn btn-primary"
patch={~p"/context/#{@context}/edit"}
>
<%= dgettext("actions", "edit") %> <%= dgettext("actions", "edit") %>
</.link> </.link>
<button <button
:if={Contexts.owner_or_admin?(@context, @current_user)} :if={@current_user}
type="button" type="button"
class="btn btn-primary" class="btn btn-primary"
phx-click="delete" phx-click="delete"

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl"> <div class="flex flex-col justify-center items-start mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl"> <h1 class="text-xl">
<%= gettext("notes") %> <%= gettext("notes") %>
</h1> </h1>
@ -9,7 +9,7 @@
as={:search} as={:search}
phx-change="search" phx-change="search"
phx-submit="search" phx-submit="search"
class="self-stretch flex flex-col items-stretch" class="flex flex-col items-stretch self-stretch"
> >
<%= text_input(f, :search_term, <%= text_input(f, :search_term,
class: "input input-primary", class: "input input-primary",
@ -33,14 +33,14 @@
> >
<:actions :let={note}> <:actions :let={note}>
<.link <.link
:if={Notes.owner?(note, @current_user)} :if={@current_user}
patch={~p"/notes/#{note}/edit"} patch={~p"/notes/#{note}/edit"}
aria-label={dgettext("actions", "edit %{note_slug}", note_slug: note.slug)} aria-label={dgettext("actions", "edit %{note_slug}", note_slug: note.slug)}
> >
<%= dgettext("actions", "edit") %> <%= dgettext("actions", "edit") %>
</.link> </.link>
<.link <.link
:if={Notes.owner_or_admin?(note, @current_user)} :if={@current_user}
href="#" href="#"
phx-click="delete" phx-click="delete"
phx-value-id={note.id} phx-value-id={note.id}

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl"> <div class="flex flex-col justify-center items-stretch mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl"> <h1 class="text-xl">
<%= @note.slug %> <%= @note.slug %>
</h1> </h1>
@ -15,16 +15,12 @@
<%= gettext("Visibility: %{visibility}", visibility: @note.visibility) %> <%= gettext("Visibility: %{visibility}", visibility: @note.visibility) %>
</p> </p>
<div class="self-end flex space-x-4"> <div class="flex self-end space-x-4">
<.link <.link :if={@current_user} class="btn btn-primary" patch={~p"/note/#{@note}/edit"}>
:if={Notes.owner?(@note, @current_user)}
class="btn btn-primary"
patch={~p"/note/#{@note}/edit"}
>
<%= dgettext("actions", "edit") %> <%= dgettext("actions", "edit") %>
</.link> </.link>
<button <button
:if={Notes.owner_or_admin?(@note, @current_user)} :if={@current_user}
type="button" type="button"
class="btn btn-primary" class="btn btn-primary"
phx-click="delete" phx-click="delete"

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl"> <div class="flex flex-col justify-center items-start mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl"> <h1 class="text-xl">
<%= gettext("pipelines") %> <%= gettext("pipelines") %>
</h1> </h1>
@ -9,7 +9,7 @@
as={:search} as={:search}
phx-change="search" phx-change="search"
phx-submit="search" phx-submit="search"
class="self-stretch flex flex-col items-stretch" class="flex flex-col items-stretch self-stretch"
> >
<%= text_input(f, :search_term, <%= text_input(f, :search_term,
class: "input input-primary", class: "input input-primary",
@ -33,14 +33,14 @@
> >
<:actions :let={pipeline}> <:actions :let={pipeline}>
<.link <.link
:if={Pipelines.owner?(pipeline, @current_user)} :if={@current_user}
patch={~p"/pipelines/#{pipeline}/edit"} patch={~p"/pipelines/#{pipeline}/edit"}
aria-label={dgettext("actions", "edit %{pipeline_slug}", pipeline_slug: pipeline.slug)} aria-label={dgettext("actions", "edit %{pipeline_slug}", pipeline_slug: pipeline.slug)}
> >
<%= dgettext("actions", "edit") %> <%= dgettext("actions", "edit") %>
</.link> </.link>
<.link <.link
:if={Pipelines.owner_or_admin?(pipeline, @current_user)} :if={@current_user}
href="#" href="#"
phx-click="delete" phx-click="delete"
phx-value-id={pipeline.id} phx-value-id={pipeline.id}

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl"> <div class="flex flex-col justify-center items-stretch mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl"> <h1 class="text-xl">
<%= @pipeline.slug %> <%= @pipeline.slug %>
</h1> </h1>
@ -15,16 +15,12 @@
<%= gettext("Visibility: %{visibility}", visibility: @pipeline.visibility) %> <%= gettext("Visibility: %{visibility}", visibility: @pipeline.visibility) %>
</p> </p>
<div class="pb-4 self-end flex space-x-4"> <div class="flex self-end pb-4 space-x-4">
<.link <.link :if={@current_user} class="btn btn-primary" patch={~p"/pipeline/#{@pipeline}/edit"}>
:if={Pipelines.owner?(@pipeline, @current_user)}
class="btn btn-primary"
patch={~p"/pipeline/#{@pipeline}/edit"}
>
<%= dgettext("actions", "edit") %> <%= dgettext("actions", "edit") %>
</.link> </.link>
<button <button
:if={Pipelines.owner_or_admin?(@pipeline, @current_user)} :if={@current_user}
type="button" type="button"
class="btn btn-primary" class="btn btn-primary"
phx-click="delete" phx-click="delete"
@ -37,7 +33,7 @@
<hr class="hr" /> <hr class="hr" />
<h2 class="pt-2 self-center text-lg"> <h2 class="self-center pt-2 text-lg">
<%= gettext("steps:") %> <%= gettext("steps:") %>
</h2> </h2>
@ -52,29 +48,29 @@
<%= gettext("%{position}. %{title}", position: position + 1, title: title) %> <%= gettext("%{position}. %{title}", position: position + 1, title: title) %>
</h3> </h3>
<%= if Pipelines.owner?(@pipeline, @current_user) do %> <%= if @current_user do %>
<div class="flex justify-between items-center space-x-4"> <div class="flex justify-between items-center space-x-4">
<%= if position <= 0 do %> <%= if position <= 0 do %>
<i class="fas text-xl fa-chevron-up cursor-not-allowed opacity-25"></i> <i class="text-xl opacity-25 cursor-not-allowed fas fa-chevron-up"></i>
<% else %> <% else %>
<button <button
type="button" type="button"
class="cursor-pointer flex justify-center items-center" class="flex justify-center items-center cursor-pointer"
phx-click="reorder_step" phx-click="reorder_step"
phx-value-direction="up" phx-value-direction="up"
phx-value-step-id={step_id} phx-value-step-id={step_id}
aria-label={dgettext("actions", "move %{step_title} up", step_title: step.title)} aria-label={dgettext("actions", "move %{step_title} up", step_title: step.title)}
> >
<i class="fas text-xl fa-chevron-up"></i> <i class="text-xl fas fa-chevron-up"></i>
</button> </button>
<% end %> <% end %>
<%= if position >= length(@steps) - 1 do %> <%= if position >= length(@steps) - 1 do %>
<i class="fas text-xl fa-chevron-down cursor-not-allowed opacity-25"></i> <i class="text-xl opacity-25 cursor-not-allowed fas fa-chevron-down"></i>
<% else %> <% else %>
<button <button
type="button" type="button"
class="cursor-pointer flex justify-center items-center" class="flex justify-center items-center cursor-pointer"
phx-click="reorder_step" phx-click="reorder_step"
phx-value-direction="down" phx-value-direction="down"
phx-value-step-id={step_id} phx-value-step-id={step_id}
@ -82,7 +78,7 @@
dgettext("actions", "move %{step_title} down", step_title: step.title) dgettext("actions", "move %{step_title} down", step_title: step.title)
} }
> >
<i class="fas text-xl fa-chevron-down"></i> <i class="text-xl fas fa-chevron-down"></i>
</button> </button>
<% end %> <% end %>
@ -113,7 +109,7 @@
<% end %> <% end %>
<.link <.link
:if={Pipelines.owner?(@pipeline, @current_user)} :if={@current_user}
class="self-end btn btn-primary" class="self-end btn btn-primary"
patch={~p"/pipeline/#{@pipeline}/add_step"} patch={~p"/pipeline/#{@pipeline}/add_step"}
> >

View File

@ -4,7 +4,7 @@ defmodule Memex.MixProject do
def project do def project do
[ [
app: :memex, app: :memex,
version: "0.1.18", version: "0.1.19",
elixir: "1.18.1", elixir: "1.18.1",
elixirc_paths: elixirc_paths(Mix.env()), elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,

View File

@ -40,12 +40,12 @@ msgid "create invite"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:50 #: lib/memex_web/live/context_live/index.html.heex:50
#: lib/memex_web/live/context_live/show.html.heex:34 #: lib/memex_web/live/context_live/show.html.heex:30
#: lib/memex_web/live/note_live/index.html.heex:50 #: lib/memex_web/live/note_live/index.html.heex:50
#: lib/memex_web/live/note_live/show.html.heex:34 #: lib/memex_web/live/note_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/index.html.heex:52 #: lib/memex_web/live/pipeline_live/index.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:34 #: lib/memex_web/live/pipeline_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/show.html.heex:105 #: lib/memex_web/live/pipeline_live/show.html.heex:101
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete" msgid "delete"
msgstr "" msgstr ""
@ -56,12 +56,12 @@ msgid "delete user"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:40 #: lib/memex_web/live/context_live/index.html.heex:40
#: lib/memex_web/live/context_live/show.html.heex:24 #: lib/memex_web/live/context_live/show.html.heex:20
#: lib/memex_web/live/note_live/index.html.heex:40 #: lib/memex_web/live/note_live/index.html.heex:40
#: lib/memex_web/live/note_live/show.html.heex:24 #: lib/memex_web/live/note_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/index.html.heex:40 #: lib/memex_web/live/pipeline_live/index.html.heex:40
#: lib/memex_web/live/pipeline_live/show.html.heex:24 #: lib/memex_web/live/pipeline_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/show.html.heex:94 #: lib/memex_web/live/pipeline_live/show.html.heex:90
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit" msgid "edit"
msgstr "" msgstr ""
@ -112,7 +112,7 @@ msgstr ""
msgid "save" msgid "save"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:120 #: lib/memex_web/live/pipeline_live/show.html.heex:116
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "add step" msgid "add step"
msgstr "" msgstr ""
@ -145,24 +145,24 @@ msgid "copy invite link for %{invite_name}"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:48 #: lib/memex_web/live/context_live/index.html.heex:48
#: lib/memex_web/live/context_live/show.html.heex:32 #: lib/memex_web/live/context_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{context_slug}" msgid "delete %{context_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/note_live/index.html.heex:48 #: lib/memex_web/live/note_live/index.html.heex:48
#: lib/memex_web/live/note_live/show.html.heex:32 #: lib/memex_web/live/note_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{note_slug}" msgid "delete %{note_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/index.html.heex:49 #: lib/memex_web/live/pipeline_live/index.html.heex:49
#: lib/memex_web/live/pipeline_live/show.html.heex:32 #: lib/memex_web/live/pipeline_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{pipeline_slug}" msgid "delete %{pipeline_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:103 #: lib/memex_web/live/pipeline_live/show.html.heex:99
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{step_title}" msgid "delete %{step_title}"
msgstr "" msgstr ""
@ -187,7 +187,7 @@ msgstr ""
msgid "edit %{pipeline_slug}" msgid "edit %{pipeline_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:92 #: lib/memex_web/live/pipeline_live/show.html.heex:88
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit %{step_title}" msgid "edit %{step_title}"
msgstr "" msgstr ""
@ -197,12 +197,12 @@ msgstr ""
msgid "edit invite for %{invite_name}" msgid "edit invite for %{invite_name}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:82 #: lib/memex_web/live/pipeline_live/show.html.heex:78
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "move %{step_title} down" msgid "move %{step_title} down"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:66 #: lib/memex_web/live/pipeline_live/show.html.heex:62
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "move %{step_title} up" msgid "move %{step_title} up"
msgstr "" msgstr ""

View File

@ -40,12 +40,12 @@ msgid "create invite"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:50 #: lib/memex_web/live/context_live/index.html.heex:50
#: lib/memex_web/live/context_live/show.html.heex:34 #: lib/memex_web/live/context_live/show.html.heex:30
#: lib/memex_web/live/note_live/index.html.heex:50 #: lib/memex_web/live/note_live/index.html.heex:50
#: lib/memex_web/live/note_live/show.html.heex:34 #: lib/memex_web/live/note_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/index.html.heex:52 #: lib/memex_web/live/pipeline_live/index.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:34 #: lib/memex_web/live/pipeline_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/show.html.heex:105 #: lib/memex_web/live/pipeline_live/show.html.heex:101
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete" msgid "delete"
msgstr "" msgstr ""
@ -56,12 +56,12 @@ msgid "delete user"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:40 #: lib/memex_web/live/context_live/index.html.heex:40
#: lib/memex_web/live/context_live/show.html.heex:24 #: lib/memex_web/live/context_live/show.html.heex:20
#: lib/memex_web/live/note_live/index.html.heex:40 #: lib/memex_web/live/note_live/index.html.heex:40
#: lib/memex_web/live/note_live/show.html.heex:24 #: lib/memex_web/live/note_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/index.html.heex:40 #: lib/memex_web/live/pipeline_live/index.html.heex:40
#: lib/memex_web/live/pipeline_live/show.html.heex:24 #: lib/memex_web/live/pipeline_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/show.html.heex:94 #: lib/memex_web/live/pipeline_live/show.html.heex:90
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit" msgid "edit"
msgstr "" msgstr ""
@ -112,7 +112,7 @@ msgstr ""
msgid "save" msgid "save"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:120 #: lib/memex_web/live/pipeline_live/show.html.heex:116
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "add step" msgid "add step"
msgstr "" msgstr ""
@ -145,24 +145,24 @@ msgid "copy invite link for %{invite_name}"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:48 #: lib/memex_web/live/context_live/index.html.heex:48
#: lib/memex_web/live/context_live/show.html.heex:32 #: lib/memex_web/live/context_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{context_slug}" msgid "delete %{context_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/note_live/index.html.heex:48 #: lib/memex_web/live/note_live/index.html.heex:48
#: lib/memex_web/live/note_live/show.html.heex:32 #: lib/memex_web/live/note_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{note_slug}" msgid "delete %{note_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/index.html.heex:49 #: lib/memex_web/live/pipeline_live/index.html.heex:49
#: lib/memex_web/live/pipeline_live/show.html.heex:32 #: lib/memex_web/live/pipeline_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{pipeline_slug}" msgid "delete %{pipeline_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:103 #: lib/memex_web/live/pipeline_live/show.html.heex:99
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{step_title}" msgid "delete %{step_title}"
msgstr "" msgstr ""
@ -187,7 +187,7 @@ msgstr ""
msgid "edit %{pipeline_slug}" msgid "edit %{pipeline_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:92 #: lib/memex_web/live/pipeline_live/show.html.heex:88
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit %{step_title}" msgid "edit %{step_title}"
msgstr "" msgstr ""
@ -197,12 +197,12 @@ msgstr ""
msgid "edit invite for %{invite_name}" msgid "edit invite for %{invite_name}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:82 #: lib/memex_web/live/pipeline_live/show.html.heex:78
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "move %{step_title} down" msgid "move %{step_title} down"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:66 #: lib/memex_web/live/pipeline_live/show.html.heex:62
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "move %{step_title} up" msgid "move %{step_title} up"
msgstr "" msgstr ""

View File

@ -422,7 +422,7 @@ msgstr ""
msgid "what is this?" msgid "what is this?"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:52 #: lib/memex_web/live/pipeline_live/show.html.heex:48
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{position}. %{title}" msgid "%{position}. %{title}"
msgstr "" msgstr ""
@ -447,12 +447,12 @@ msgstr ""
msgid "add step to %{slug}" msgid "add step to %{slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:46 #: lib/memex_web/live/pipeline_live/show.html.heex:42
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "no steps" msgid "no steps"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:41 #: lib/memex_web/live/pipeline_live/show.html.heex:37
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "steps:" msgid "steps:"
msgstr "" msgstr ""

View File

@ -47,11 +47,11 @@ msgid "must have the @ sign and no spaces"
msgstr "" msgstr ""
#: lib/memex/contexts/context.ex:58 #: lib/memex/contexts/context.ex:58
#: lib/memex/contexts/context.ex:71 #: lib/memex/contexts/context.ex:72
#: lib/memex/notes/note.ex:57 #: lib/memex/notes/note.ex:57
#: lib/memex/notes/note.ex:70 #: lib/memex/notes/note.ex:71
#: lib/memex/pipelines/pipeline.ex:60 #: lib/memex/pipelines/pipeline.ex:60
#: lib/memex/pipelines/pipeline.ex:73 #: lib/memex/pipelines/pipeline.ex:74
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted" msgid "invalid format: only numbers, letters and hyphen are accepted"
msgstr "" msgstr ""
@ -140,9 +140,9 @@ msgstr ""
msgid "user confirmation link is invalid or it has expired." msgid "user confirmation link is invalid or it has expired."
msgstr "" msgstr ""
#: lib/memex/contexts/context.ex:84 #: lib/memex/contexts/context.ex:85
#: lib/memex/notes/note.ex:83 #: lib/memex/notes/note.ex:84
#: lib/memex/pipelines/pipeline.ex:86 #: lib/memex/pipelines/pipeline.ex:87
#, elixir-autogen, elixir-format, fuzzy #, elixir-autogen, elixir-format, fuzzy
msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited" msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited"
msgstr "" msgstr ""

View File

@ -66,12 +66,12 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:47 #: lib/memex_web/live/context_live/index.html.heex:47
#: lib/memex_web/live/context_live/show.html.heex:31 #: lib/memex_web/live/context_live/show.html.heex:27
#: lib/memex_web/live/note_live/index.html.heex:47 #: lib/memex_web/live/note_live/index.html.heex:47
#: lib/memex_web/live/note_live/show.html.heex:31 #: lib/memex_web/live/note_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/index.html.heex:47 #: lib/memex_web/live/pipeline_live/index.html.heex:47
#: lib/memex_web/live/pipeline_live/show.html.heex:31 #: lib/memex_web/live/pipeline_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/show.html.heex:102 #: lib/memex_web/live/pipeline_live/show.html.heex:98
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "are you sure?" msgid "are you sure?"
msgstr "" msgstr ""

View File

@ -420,7 +420,7 @@ msgstr ""
msgid "what is this?" msgid "what is this?"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:52 #: lib/memex_web/live/pipeline_live/show.html.heex:48
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{position}. %{title}" msgid "%{position}. %{title}"
msgstr "" msgstr ""
@ -445,12 +445,12 @@ msgstr ""
msgid "add step to %{slug}" msgid "add step to %{slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:46 #: lib/memex_web/live/pipeline_live/show.html.heex:42
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "no steps" msgid "no steps"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:41 #: lib/memex_web/live/pipeline_live/show.html.heex:37
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "steps:" msgid "steps:"
msgstr "" msgstr ""

View File

@ -41,12 +41,12 @@ msgid "create invite"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:50 #: lib/memex_web/live/context_live/index.html.heex:50
#: lib/memex_web/live/context_live/show.html.heex:34 #: lib/memex_web/live/context_live/show.html.heex:30
#: lib/memex_web/live/note_live/index.html.heex:50 #: lib/memex_web/live/note_live/index.html.heex:50
#: lib/memex_web/live/note_live/show.html.heex:34 #: lib/memex_web/live/note_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/index.html.heex:52 #: lib/memex_web/live/pipeline_live/index.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:34 #: lib/memex_web/live/pipeline_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/show.html.heex:105 #: lib/memex_web/live/pipeline_live/show.html.heex:101
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete" msgid "delete"
msgstr "" msgstr ""
@ -57,12 +57,12 @@ msgid "delete user"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:40 #: lib/memex_web/live/context_live/index.html.heex:40
#: lib/memex_web/live/context_live/show.html.heex:24 #: lib/memex_web/live/context_live/show.html.heex:20
#: lib/memex_web/live/note_live/index.html.heex:40 #: lib/memex_web/live/note_live/index.html.heex:40
#: lib/memex_web/live/note_live/show.html.heex:24 #: lib/memex_web/live/note_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/index.html.heex:40 #: lib/memex_web/live/pipeline_live/index.html.heex:40
#: lib/memex_web/live/pipeline_live/show.html.heex:24 #: lib/memex_web/live/pipeline_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/show.html.heex:94 #: lib/memex_web/live/pipeline_live/show.html.heex:90
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit" msgid "edit"
msgstr "" msgstr ""
@ -113,7 +113,7 @@ msgstr ""
msgid "save" msgid "save"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:120 #: lib/memex_web/live/pipeline_live/show.html.heex:116
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "add step" msgid "add step"
msgstr "" msgstr ""
@ -146,24 +146,24 @@ msgid "copy invite link for %{invite_name}"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:48 #: lib/memex_web/live/context_live/index.html.heex:48
#: lib/memex_web/live/context_live/show.html.heex:32 #: lib/memex_web/live/context_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{context_slug}" msgid "delete %{context_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/note_live/index.html.heex:48 #: lib/memex_web/live/note_live/index.html.heex:48
#: lib/memex_web/live/note_live/show.html.heex:32 #: lib/memex_web/live/note_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{note_slug}" msgid "delete %{note_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/index.html.heex:49 #: lib/memex_web/live/pipeline_live/index.html.heex:49
#: lib/memex_web/live/pipeline_live/show.html.heex:32 #: lib/memex_web/live/pipeline_live/show.html.heex:28
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{pipeline_slug}" msgid "delete %{pipeline_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:103 #: lib/memex_web/live/pipeline_live/show.html.heex:99
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "delete %{step_title}" msgid "delete %{step_title}"
msgstr "" msgstr ""
@ -188,7 +188,7 @@ msgstr ""
msgid "edit %{pipeline_slug}" msgid "edit %{pipeline_slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:92 #: lib/memex_web/live/pipeline_live/show.html.heex:88
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "edit %{step_title}" msgid "edit %{step_title}"
msgstr "" msgstr ""
@ -198,12 +198,12 @@ msgstr ""
msgid "edit invite for %{invite_name}" msgid "edit invite for %{invite_name}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:82 #: lib/memex_web/live/pipeline_live/show.html.heex:78
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "move %{step_title} down" msgid "move %{step_title} down"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:66 #: lib/memex_web/live/pipeline_live/show.html.heex:62
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "move %{step_title} up" msgid "move %{step_title} up"
msgstr "" msgstr ""

View File

@ -421,7 +421,7 @@ msgstr ""
msgid "what is this?" msgid "what is this?"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:52 #: lib/memex_web/live/pipeline_live/show.html.heex:48
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "%{position}. %{title}" msgid "%{position}. %{title}"
msgstr "" msgstr ""
@ -446,12 +446,12 @@ msgstr ""
msgid "add step to %{slug}" msgid "add step to %{slug}"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:46 #: lib/memex_web/live/pipeline_live/show.html.heex:42
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "no steps" msgid "no steps"
msgstr "" msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:41 #: lib/memex_web/live/pipeline_live/show.html.heex:37
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "steps:" msgid "steps:"
msgstr "" msgstr ""

View File

@ -48,11 +48,11 @@ msgid "must have the @ sign and no spaces"
msgstr "" msgstr ""
#: lib/memex/contexts/context.ex:58 #: lib/memex/contexts/context.ex:58
#: lib/memex/contexts/context.ex:71 #: lib/memex/contexts/context.ex:72
#: lib/memex/notes/note.ex:57 #: lib/memex/notes/note.ex:57
#: lib/memex/notes/note.ex:70 #: lib/memex/notes/note.ex:71
#: lib/memex/pipelines/pipeline.ex:60 #: lib/memex/pipelines/pipeline.ex:60
#: lib/memex/pipelines/pipeline.ex:73 #: lib/memex/pipelines/pipeline.ex:74
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted" msgid "invalid format: only numbers, letters and hyphen are accepted"
msgstr "" msgstr ""
@ -141,9 +141,9 @@ msgstr ""
msgid "user confirmation link is invalid or it has expired." msgid "user confirmation link is invalid or it has expired."
msgstr "" msgstr ""
#: lib/memex/contexts/context.ex:84 #: lib/memex/contexts/context.ex:85
#: lib/memex/notes/note.ex:83 #: lib/memex/notes/note.ex:84
#: lib/memex/pipelines/pipeline.ex:86 #: lib/memex/pipelines/pipeline.ex:87
#, elixir-autogen, elixir-format, fuzzy #, elixir-autogen, elixir-format, fuzzy
msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited" msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited"
msgstr "" msgstr ""

View File

@ -67,12 +67,12 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:47 #: lib/memex_web/live/context_live/index.html.heex:47
#: lib/memex_web/live/context_live/show.html.heex:31 #: lib/memex_web/live/context_live/show.html.heex:27
#: lib/memex_web/live/note_live/index.html.heex:47 #: lib/memex_web/live/note_live/index.html.heex:47
#: lib/memex_web/live/note_live/show.html.heex:31 #: lib/memex_web/live/note_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/index.html.heex:47 #: lib/memex_web/live/pipeline_live/index.html.heex:47
#: lib/memex_web/live/pipeline_live/show.html.heex:31 #: lib/memex_web/live/pipeline_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/show.html.heex:102 #: lib/memex_web/live/pipeline_live/show.html.heex:98
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "are you sure?" msgid "are you sure?"
msgstr "" msgstr ""

View File

@ -47,11 +47,11 @@ msgid "must have the @ sign and no spaces"
msgstr "" msgstr ""
#: lib/memex/contexts/context.ex:58 #: lib/memex/contexts/context.ex:58
#: lib/memex/contexts/context.ex:71 #: lib/memex/contexts/context.ex:72
#: lib/memex/notes/note.ex:57 #: lib/memex/notes/note.ex:57
#: lib/memex/notes/note.ex:70 #: lib/memex/notes/note.ex:71
#: lib/memex/pipelines/pipeline.ex:60 #: lib/memex/pipelines/pipeline.ex:60
#: lib/memex/pipelines/pipeline.ex:73 #: lib/memex/pipelines/pipeline.ex:74
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted" msgid "invalid format: only numbers, letters and hyphen are accepted"
msgstr "" msgstr ""
@ -140,9 +140,9 @@ msgstr ""
msgid "user confirmation link is invalid or it has expired." msgid "user confirmation link is invalid or it has expired."
msgstr "" msgstr ""
#: lib/memex/contexts/context.ex:84 #: lib/memex/contexts/context.ex:85
#: lib/memex/notes/note.ex:83 #: lib/memex/notes/note.ex:84
#: lib/memex/pipelines/pipeline.ex:86 #: lib/memex/pipelines/pipeline.ex:87
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited" msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited"
msgstr "" msgstr ""

View File

@ -66,12 +66,12 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
msgstr "" msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:47 #: lib/memex_web/live/context_live/index.html.heex:47
#: lib/memex_web/live/context_live/show.html.heex:31 #: lib/memex_web/live/context_live/show.html.heex:27
#: lib/memex_web/live/note_live/index.html.heex:47 #: lib/memex_web/live/note_live/index.html.heex:47
#: lib/memex_web/live/note_live/show.html.heex:31 #: lib/memex_web/live/note_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/index.html.heex:47 #: lib/memex_web/live/pipeline_live/index.html.heex:47
#: lib/memex_web/live/pipeline_live/show.html.heex:31 #: lib/memex_web/live/pipeline_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/show.html.heex:102 #: lib/memex_web/live/pipeline_live/show.html.heex:98
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "are you sure?" msgid "are you sure?"
msgstr "" msgstr ""

View File

@ -25,10 +25,6 @@ defmodule Memex.ContextsTest do
%{slug: "chickens", content: "bananas stuff", tags: ["life", "decisions"]} %{slug: "chickens", content: "bananas stuff", tags: ["life", "decisions"]}
|> context_fixture(user) |> context_fixture(user)
_shouldnt_return =
%{slug: "dog", content: "banana treat stuff", visibility: :private}
|> context_fixture(user_fixture())
# slug # slug
assert Contexts.list_contexts("dog", user) == [context_a] assert Contexts.list_contexts("dog", user) == [context_a]
assert Contexts.list_contexts("dogs", user) == [context_a] assert Contexts.list_contexts("dogs", user) == [context_a]
@ -72,15 +68,6 @@ defmodule Memex.ContextsTest do
} }
|> context_fixture(user) |> context_fixture(user)
_shouldnt_return =
%{
slug: "dog",
content: "treats bananas stuff",
tags: ["home", "life", "decisions"],
visibility: :private
}
|> context_fixture(user)
# slug # slug
assert Contexts.list_public_contexts("dog") == [context_a] assert Contexts.list_public_contexts("dog") == [context_a]
assert Contexts.list_public_contexts("dogs") == [context_a] assert Contexts.list_public_contexts("dogs") == [context_a]
@ -110,21 +97,6 @@ defmodule Memex.ContextsTest do
assert Contexts.get_context!(context.id, user) == context assert Contexts.get_context!(context.id, user) == context
end end
test "get_context!/1 only returns unlisted or public contexts for other users", %{user: user} do
another_user = user_fixture()
context = context_fixture(%{visibility: :public}, another_user)
assert Contexts.get_context!(context.id, user) == context
context = context_fixture(%{visibility: :unlisted}, another_user)
assert Contexts.get_context!(context.id, user) == context
context = context_fixture(%{visibility: :private}, another_user)
assert_raise Ecto.NoResultsError, fn ->
Contexts.get_context!(context.id, user)
end
end
test "get_context_by_slug/1 returns the context with given id", %{user: user} do test "get_context_by_slug/1 returns the context with given id", %{user: user} do
context = context_fixture(%{slug: "a", visibility: :public}, user) context = context_fixture(%{slug: "a", visibility: :public}, user)
assert Contexts.get_context_by_slug("a", user) == context assert Contexts.get_context_by_slug("a", user) == context
@ -136,20 +108,6 @@ defmodule Memex.ContextsTest do
assert Contexts.get_context_by_slug("c", user) == context assert Contexts.get_context_by_slug("c", user) == context
end end
test "get_context_by_slug/1 only returns unlisted or public contexts for other users", %{
user: user
} do
another_user = user_fixture()
context = context_fixture(%{slug: "a", visibility: :public}, another_user)
assert Contexts.get_context_by_slug("a", user) == context
context = context_fixture(%{slug: "b", visibility: :unlisted}, another_user)
assert Contexts.get_context_by_slug("b", user) == context
context_fixture(%{slug: "c", visibility: :private}, another_user)
assert Contexts.get_context_by_slug("c", user) |> is_nil()
end
test "create_context/1 with valid data creates a context", %{user: user} do test "create_context/1 with valid data creates a context", %{user: user} do
valid_attrs = %{ valid_attrs = %{
content: "some content", content: "some content",

View File

@ -14,7 +14,6 @@ defmodule Memex.NotesTest do
note_a = note_fixture(%{slug: "a", visibility: :public}, user) note_a = note_fixture(%{slug: "a", visibility: :public}, user)
note_b = note_fixture(%{slug: "b", visibility: :unlisted}, user) note_b = note_fixture(%{slug: "b", visibility: :unlisted}, user)
note_c = note_fixture(%{slug: "c", visibility: :private}, user) note_c = note_fixture(%{slug: "c", visibility: :private}, user)
_shouldnt_return = note_fixture(%{visibility: :private}, user_fixture())
assert Notes.list_notes(user) == [note_a, note_b, note_c] assert Notes.list_notes(user) == [note_a, note_b, note_c]
end end
@ -27,10 +26,6 @@ defmodule Memex.NotesTest do
%{slug: "chickens", content: "bananas stuff", tags: ["life", "decisions"]} %{slug: "chickens", content: "bananas stuff", tags: ["life", "decisions"]}
|> note_fixture(user) |> note_fixture(user)
_shouldnt_return =
%{slug: "dog", content: "banana treat stuff", visibility: :private}
|> note_fixture(user_fixture())
# slug # slug
assert Notes.list_notes("dog", user) == [note_a] assert Notes.list_notes("dog", user) == [note_a]
assert Notes.list_notes("dogs", user) == [note_a] assert Notes.list_notes("dogs", user) == [note_a]
@ -74,15 +69,6 @@ defmodule Memex.NotesTest do
} }
|> note_fixture(user) |> note_fixture(user)
_shouldnt_return =
%{
slug: "dog",
content: "treats bananas stuff",
tags: ["home", "life", "decisions"],
visibility: :private
}
|> note_fixture(user)
# slug # slug
assert Notes.list_public_notes("dog") == [note_a] assert Notes.list_public_notes("dog") == [note_a]
assert Notes.list_public_notes("dogs") == [note_a] assert Notes.list_public_notes("dogs") == [note_a]
@ -112,21 +98,6 @@ defmodule Memex.NotesTest do
assert Notes.get_note!(note.id, user) == note assert Notes.get_note!(note.id, user) == note
end end
test "get_note!/1 only returns unlisted or public notes for other users", %{user: user} do
another_user = user_fixture()
note = note_fixture(%{visibility: :public}, another_user)
assert Notes.get_note!(note.id, user) == note
note = note_fixture(%{visibility: :unlisted}, another_user)
assert Notes.get_note!(note.id, user) == note
note = note_fixture(%{visibility: :private}, another_user)
assert_raise Ecto.NoResultsError, fn ->
Notes.get_note!(note.id, user)
end
end
test "get_note_by_slug/1 returns the note with given id", %{user: user} do test "get_note_by_slug/1 returns the note with given id", %{user: user} do
note = note_fixture(%{slug: "a", visibility: :public}, user) note = note_fixture(%{slug: "a", visibility: :public}, user)
assert Notes.get_note_by_slug("a", user) == note assert Notes.get_note_by_slug("a", user) == note
@ -138,20 +109,6 @@ defmodule Memex.NotesTest do
assert Notes.get_note_by_slug("c", user) == note assert Notes.get_note_by_slug("c", user) == note
end end
test "get_note_by_slug/1 only returns unlisted or public notes for other users", %{
user: user
} do
another_user = user_fixture()
note = note_fixture(%{slug: "a", visibility: :public}, another_user)
assert Notes.get_note_by_slug("a", user) == note
note = note_fixture(%{slug: "b", visibility: :unlisted}, another_user)
assert Notes.get_note_by_slug("b", user) == note
note_fixture(%{slug: "c", visibility: :private}, another_user)
assert Notes.get_note_by_slug("c", user) |> is_nil()
end
test "create_note/1 with valid data creates a note", %{user: user} do test "create_note/1 with valid data creates a note", %{user: user} do
valid_attrs = %{ valid_attrs = %{
content: "some content", content: "some content",

View File

@ -25,10 +25,6 @@ defmodule Memex.PipelinesTest do
%{slug: "chickens", description: "bananas stuff", tags: ["life", "decisions"]} %{slug: "chickens", description: "bananas stuff", tags: ["life", "decisions"]}
|> pipeline_fixture(user) |> pipeline_fixture(user)
_shouldnt_return =
%{slug: "dog", description: "banana treat stuff", visibility: :private}
|> pipeline_fixture(user_fixture())
# slug # slug
assert Pipelines.list_pipelines("dog", user) == [pipeline_a] assert Pipelines.list_pipelines("dog", user) == [pipeline_a]
assert Pipelines.list_pipelines("dogs", user) == [pipeline_a] assert Pipelines.list_pipelines("dogs", user) == [pipeline_a]
@ -72,15 +68,6 @@ defmodule Memex.PipelinesTest do
} }
|> pipeline_fixture(user) |> pipeline_fixture(user)
_shouldnt_return =
%{
slug: "dog",
description: "treats bananas stuff",
tags: ["home", "life", "decisions"],
visibility: :private
}
|> pipeline_fixture(user)
# slug # slug
assert Pipelines.list_public_pipelines("dog") == [pipeline_a] assert Pipelines.list_public_pipelines("dog") == [pipeline_a]
assert Pipelines.list_public_pipelines("dogs") == [pipeline_a] assert Pipelines.list_public_pipelines("dogs") == [pipeline_a]
@ -110,23 +97,6 @@ defmodule Memex.PipelinesTest do
assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline
end end
test "get_pipeline!/1 only returns unlisted or public pipelines for other users", %{
user: user
} do
another_user = user_fixture()
pipeline = pipeline_fixture(%{visibility: :public}, another_user)
assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline
pipeline = pipeline_fixture(%{visibility: :unlisted}, another_user)
assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline
pipeline = pipeline_fixture(%{visibility: :private}, another_user)
assert_raise Ecto.NoResultsError, fn ->
Pipelines.get_pipeline!(pipeline.id, user)
end
end
test "get_pipeline_by_slug/1 returns the pipeline with given id", %{user: user} do test "get_pipeline_by_slug/1 returns the pipeline with given id", %{user: user} do
pipeline = pipeline_fixture(%{slug: "a", visibility: :public}, user) pipeline = pipeline_fixture(%{slug: "a", visibility: :public}, user)
assert Pipelines.get_pipeline_by_slug("a", user) == pipeline assert Pipelines.get_pipeline_by_slug("a", user) == pipeline
@ -138,20 +108,6 @@ defmodule Memex.PipelinesTest do
assert Pipelines.get_pipeline_by_slug("c", user) == pipeline assert Pipelines.get_pipeline_by_slug("c", user) == pipeline
end end
test "get_pipeline_by_slug/1 only returns unlisted or public pipelines for other users", %{
user: user
} do
another_user = user_fixture()
pipeline = pipeline_fixture(%{slug: "a", visibility: :public}, another_user)
assert Pipelines.get_pipeline_by_slug("a", user) == pipeline
pipeline = pipeline_fixture(%{slug: "b", visibility: :unlisted}, another_user)
assert Pipelines.get_pipeline_by_slug("b", user) == pipeline
pipeline_fixture(%{slug: "c", visibility: :private}, another_user)
assert Pipelines.get_pipeline_by_slug("c", user) |> is_nil()
end
test "create_pipeline/1 with valid data creates a pipeline", %{user: user} do test "create_pipeline/1 with valid data creates a pipeline", %{user: user} do
valid_attrs = %{ valid_attrs = %{
description: "some description", description: "some description",

View File

@ -25,16 +25,6 @@ defmodule Memex.StepsTest do
assert Steps.get_step!(step.id, user) == step assert Steps.get_step!(step.id, user) == step
end end
test "get_step!/2 only returns unlisted or public steps for other users", %{user: user} do
another_user = user_fixture()
another_pipeline = pipeline_fixture(another_user)
step = step_fixture(0, another_pipeline, another_user)
assert_raise Ecto.NoResultsError, fn ->
Steps.get_step!(step.id, user)
end
end
test "create_step/4 with valid data creates a step", %{pipeline: pipeline, user: user} do test "create_step/4 with valid data creates a step", %{pipeline: pipeline, user: user} do
valid_attrs = %{ valid_attrs = %{
content: "some content", content: "some content",