Skip to content

Commit

Permalink
Hard deprecate LivePatch, LiveRedirect, Link, Context and Example
Browse files Browse the repository at this point in the history
  • Loading branch information
msaraiva committed Sep 17, 2024
1 parent 0eace5c commit ce7af7a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
13 changes: 13 additions & 0 deletions lib/surface/catalogue/example.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
defmodule Surface.Catalogue.Example do
@moduledoc """
> #### Deprecation warning {: .warning}
>
> This component has been deprecated in favor of `Surface.Catalogue.Examples`.
A generic LiveView to create a single example for catalogue tools.
## Options
Expand Down Expand Up @@ -32,7 +36,16 @@ defmodule Surface.Catalogue.Example do
"""

@moduledoc deprecated: "Use `Surface.Catalogue.Examples` instead"

defmacro __using__(opts) do
if Mix.env() != :test do
IO.warn(
"`Surface.Catalogue.Example` is deprecated. Use `Surface.Catalogue.Examples` instead",
Macro.Env.stacktrace(__CALLER__)
)
end

subject = Surface.Catalogue.fetch_subject!(opts, __MODULE__, __CALLER__)

quote do
Expand Down
11 changes: 8 additions & 3 deletions lib/surface/components/context.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
defmodule Surface.Components.Context do
@moduledoc """
> #### Soft deprecation warning {: .warning}
> #### Deprecation warning {: .warning}
>
> Using this module as a component with `<Context>` has been deprecated. Support for
> scope-aware context will be removed in `v0.13` due to the lack of built-in support for
> the feature in Liveview itself, which leads to inefficient diff-tracking when using it.
>
> Global context related functions like `Context.put/3` and `Context.get/3`, as well as the `:from_context`
> option, will be kept and recommended as their usage don't affect diff-tracking negatively.
> Global context related functions like `Context.put/3` and `Context.get/3`, as well as data/prop's
> option `:from_context`, will be kept and recommended as their usage don't affect diff-tracking
> negatively.
A built-in module and component that allows users to set and retrieve values
to/from the context.
Expand Down Expand Up @@ -116,6 +117,10 @@ defmodule Surface.Components.Context do
update_let_for_slot_entry(node, :default, let)
end

if Mix.env() != :test do
@deprecated "Use `Context.put/3`, `Context.get/3` or the data/prop's option `:from_context` instead"
end

@doc false
def render(assigns) do
~F"""
Expand Down
6 changes: 5 additions & 1 deletion lib/surface/components/link.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Surface.Components.Link do
@moduledoc """
> #### Soft deprecation warning {: .warning}
> #### Deprecation warning {: .warning}
>
> This component has been deprecated in favor of liveview's built-in `<.link>`
> and will be removed in `v0.13`. See https://hexdocs.pm/phoenix_live_view/live-navigation.html for
Expand Down Expand Up @@ -67,6 +67,10 @@ defmodule Surface.Components.Link do
"""
slot default

if Mix.env() != :test do
@deprecated "Use liveview's built-in `<.link>` instead"
end

def render(assigns) do
unless assigns[:default] || assigns[:label] || Keyword.get(assigns.opts, :label) do
raise ArgumentError, "<Link /> requires a label prop or contents in the default slot"
Expand Down
8 changes: 6 additions & 2 deletions lib/surface/components/live_patch.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Surface.Components.LivePatch do
@moduledoc """
> #### Soft deprecation warning {: .warning}
> #### Deprecation warning {: .warning}
>
> This component has been deprecated in favor of liveview's built-in `<.link>`
> and will be removed in `v0.13`. See https://hexdocs.pm/phoenix_live_view/live-navigation.html for
Expand All @@ -18,7 +18,7 @@ defmodule Surface.Components.LivePatch do
`<LiveRedirect>` instead.
"""

@moduledoc deprecated: "Use liveview's built-in `<.link>` instead"
@moduledoc deprecated: "Use Liveview's built-in `<.link>` instead"

use Surface.Component

Expand Down Expand Up @@ -47,6 +47,10 @@ defmodule Surface.Components.LivePatch do
"""
slot default

if Mix.env() != :test do
@deprecated "Use liveview's built-in `<.link>` instead"
end

def render(assigns) do
~F"""
<a
Expand Down
6 changes: 5 additions & 1 deletion lib/surface/components/live_redirect.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Surface.Components.LiveRedirect do
@moduledoc """
> #### Soft deprecation warning {: .warning}
> #### Deprecation warning {: .warning}
>
> This component has been deprecated in favor of liveview's built-in `<.link>`
> and will be removed in `v0.13`. See https://hexdocs.pm/phoenix_live_view/live-navigation.html for
Expand Down Expand Up @@ -47,6 +47,10 @@ defmodule Surface.Components.LiveRedirect do
"""
slot default

if Mix.env() != :test do
@deprecated "Use liveview's built-in `<.link>` instead"
end

def render(assigns) do
~F"""
<a
Expand Down

0 comments on commit ce7af7a

Please sign in to comment.