2024-01-26 12:47:56 +08:00
|
|
|
defmodule LivebookWeb.FileSystemComponents do
|
2023-02-23 02:34:54 +08:00
|
|
|
use LivebookWeb, :html
|
2022-03-18 06:33:18 +08:00
|
|
|
|
|
|
|
alias Livebook.FileSystem
|
|
|
|
|
2023-08-11 17:52:19 +08:00
|
|
|
@doc """
|
|
|
|
Formats the given file system into a short name.
|
|
|
|
"""
|
2023-09-30 02:24:37 +08:00
|
|
|
def file_system_name(file_system_module)
|
2023-08-11 17:52:19 +08:00
|
|
|
|
2023-09-30 02:24:37 +08:00
|
|
|
def file_system_name(FileSystem.Local), do: "Disk"
|
|
|
|
def file_system_name(FileSystem.S3), do: "S3"
|
2023-08-11 17:52:19 +08:00
|
|
|
|
2022-03-18 06:33:18 +08:00
|
|
|
@doc """
|
|
|
|
Formats the given file system into a descriptive label.
|
|
|
|
"""
|
|
|
|
def file_system_label(file_system)
|
|
|
|
|
2023-08-11 17:52:19 +08:00
|
|
|
def file_system_label(%FileSystem.Local{}), do: "Disk"
|
2022-03-18 06:33:18 +08:00
|
|
|
def file_system_label(%FileSystem.S3{} = fs), do: fs.bucket_url
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Renders an icon representing the given file system.
|
|
|
|
"""
|
|
|
|
def file_system_icon(assigns)
|
|
|
|
|
|
|
|
def file_system_icon(%{file_system: %FileSystem.Local{}} = assigns) do
|
|
|
|
~H"""
|
|
|
|
<.remix_icon icon="hard-drive-2-line leading-none" />
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
def file_system_icon(%{file_system: %FileSystem.S3{}} = assigns) do
|
|
|
|
~H"""
|
|
|
|
<i class="not-italic">
|
|
|
|
<span class="text-[0.75em] font-semibold align-middle">S3</span>
|
|
|
|
</i>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
end
|