Skip to content

Commit

Permalink
Merge pull request #831 from eyra/link-panl-integration
Browse files Browse the repository at this point in the history
Link panl integration
  • Loading branch information
mellelieuwes authored Jun 11, 2024
2 parents 21f007e + 3823dae commit 162928d
Show file tree
Hide file tree
Showing 731 changed files with 12,035 additions and 41,452 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ logfile
/mix_home/
/core/config/dev.secret.exs
/core/docker.env
/core/playground.exs
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ repos:
hooks:
- id: trailing-whitespace
- id: check-added-large-files
exclude: "core/priv/static/landing_page/img/uu.svg"
- id: check-merge-conflict
- id: no-commit-to-branch
args: [-b, master]
Expand Down
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@
},
"css.validate": false,
"less.validate": false,
"scss.validate": false
"scss.validate": false,
"elixirLS.projectDir": "core",
"emmet.includeLanguages": {
"phoenix-heex": "html"
},
"tailwindCSS.includeLanguages": {
"elixir": "html",
"phoenix-heex": "html"
},
"editor.tabCompletion": "on"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Project implementing a SaaS platform based on interlinked modules called Systems
* Banking
* Bookkeeping
* Budget
* Campaign
* Advert
* Assignment
* Lab
* Questionnaire
Expand Down
9 changes: 1 addition & 8 deletions core/.dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
[
# https://github.com/phoenixframework/phoenix/issues/5437, fixed in Phoenix 1.7.3 or higher
{"systems/benchmark/export_controller.ex", :no_return},
{"systems/benchmark/export_controller.ex", :call},
# issue with HTTPPoison not supporting HTTP method :mkcol
{"systems/storage/yoda/client.ex", :no_return},
{"systems/storage/yoda/client.ex", :call},
# Deprecated fiunction raises exception
{"systems/assignment/_director.ex", :no_return},
{"systems/assignment/_private.ex", :no_return},
{"systems/campaign/builders/promotion_landing_page.ex", :no_return}
{"systems/benchmark/export_controller.ex", :call}
]
16 changes: 8 additions & 8 deletions core/assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ module.exports = {
"platform-footer": "62px",
"footer-sm": "64px",
"footer-lg": "96px",
header1: "100px",
"header1-sm": "170px",
"header1-lg": "370px",
header2: "100px",
"header2-sm": "100px",
"header2-lg": "183px",
hero1: "100px",
"hero1-sm": "170px",
"hero1-lg": "360px",
hero2: "100px",
"hero2-sm": "100px",
"hero2-lg": "183px",
logo: "32px",
"logo-sm": "48px",
"lab-day-popup-list": "392px",
"image-header": "375px",
"image-header-sm": "500px",
"image-card": "200px",
"image-card": "212px",
"image-preview": "90px",
"image-preview-sm": "150px",
"image-preview-circle": "120px",
Expand Down Expand Up @@ -249,7 +249,7 @@ module.exports = {
},
maxHeight: {
dropdown: "317px",
header1: "376px",
hero1: "376px",
form: "400px",
mailto: "128px",
"wysiwyg-editor": "960px",
Expand Down
23 changes: 6 additions & 17 deletions core/bundles/next/bundle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,17 @@ defmodule Next.Bundle do
def routes do
if include?() do
quote do
scope "/", Next do
pipe_through([:browser])
get("/", Home.LandingPageController, :show)
end

scope "/", Next do
pipe_through([:browser, :redirect_if_user_is_authenticated])
live("/user/signin", User.Signin)
get("/user/session", User.SessionController, :new)
post("/user/session", User.SessionController, :create)
live("/user/signin", Account.SigninPage)
live("/user/signin/:user_type", Account.SigninPage)
get("/user/session", Account.SessionController, :new)
post("/user/session", Account.SessionController, :create)
end

scope "/", Next do
pipe_through([:browser])
delete("/user/session", User.SessionController, :delete)
end

scope "/", Next do
pipe_through([:browser, :require_authenticated_user])
live("/console", Console.Page)
live("/next", Console.Page)
delete("/user/session", Account.SessionController, :delete)
end
end
end
Expand All @@ -35,8 +25,7 @@ defmodule Next.Bundle do
def grants do
if include?() do
quote do
grant_access(Next.Console.Page, [:member])
grant_access(Next.User.Signin, [:visitor, :member])
grant_access(Next.Account.SigninPage, [:visitor, :member])
end
end
end
Expand Down
9 changes: 5 additions & 4 deletions core/bundles/next/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ config :core,
website_menu_builder: Next.Layouts.Website.MenuBuilder,
stripped_menu_builder: Next.Layouts.Stripped.MenuBuilder

config :core, CoreWeb.UserAuth,
researcher_signed_in_page: "/project",
participant_signed_in_page: "/project"
config :core, Systems.Account.UserAuth,
creator_signed_in_page: "/project",
member_signed_in_page: "/"

config :core, :features,
sign_in_with_apple: false,
member_google_sign_in: false,
surfconext_sign_in: true,
member_google_sign_in: true,
password_sign_in: true,
notification_mails: false,
debug_expire_force: false,
Expand Down
51 changes: 51 additions & 0 deletions core/bundles/next/lib/account/creator_signin_view.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
defmodule Next.Account.CreatorSigninView do
use CoreWeb, :live_component

import Frameworks.Pixel.Line
import Systems.Account.UserForm
alias Systems.Account.User

@impl true
def update(%{blocks: blocks, email: email}, socket) do
{
:ok,
socket
|> assign(blocks: blocks, email: email)
|> update_password_form()
}
end

defp update_password_form(%{assigns: %{email: email}} = socket) do
attrs =
if User.valid_email?(email) do
%{"email" => email}
else
%{}
end

assign(socket, :password_form, to_form(attrs))
end

@impl true
def render(assigns) do
~H"""
<div>
<%= for block <- @blocks do %>
<%= if block == :surfconext do %>
<Text.body_small><%= raw(dgettext("eyra-next", "surfconext.signin.body")) %></Text.body_small>
<.spacing value="XS" />
<.surfconext_signin />
<% end %>
<%= if block == :password do %>
<.password_signin for={@password_form} user_type={:creator}/>
<% end %>
<%= if block == :seperator do %>
<.spacing value="S" />
<.line />
<.spacing value="M" />
<% end %>
<% end %>
</div>
"""
end
end
50 changes: 50 additions & 0 deletions core/bundles/next/lib/account/participant_signin_view.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
defmodule Next.Account.ParticipantSigninView do
use CoreWeb, :live_component

import Frameworks.Pixel.Line
import Systems.Account.UserForm

alias Systems.Account.User

@impl true
def update(%{blocks: blocks, email: email}, socket) do
{
:ok,
socket
|> assign(email: email, blocks: blocks)
|> update_password_form()
}
end

defp update_password_form(%{assigns: %{email: email}} = socket) do
attrs =
if User.valid_email?(email) do
%{"email" => email}
else
%{}
end

assign(socket, :password_form, to_form(attrs))
end

@impl true
def render(assigns) do
~H"""
<div>
<%= for block <- @blocks do %>
<%= if block == :google do %>
<.google_signin />
<% end %>
<%= if block == :password do %>
<.password_signin for={@password_form} user_type={:participant}/>
<% end %>
<%= if block == :seperator do %>
<.spacing value="S" />
<.line />
<.spacing value="M" />
<% end %>
<% end %>
</div>
"""
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
defmodule Next.User.SessionController do
defmodule Next.Account.SessionController do
use CoreWeb, :controller
import CoreWeb.Gettext

alias Systems.Account

plug(:setup_sign_in_with_apple, :core when action != :delete)

defp setup_sign_in_with_apple(conn, otp_app) do
Expand Down Expand Up @@ -29,8 +31,8 @@ defmodule Next.User.SessionController do
def create(conn, %{"email" => email, "password" => password} = user_params) do
require_feature(:password_sign_in)

if user = Core.Accounts.get_user_by_email_and_password(email, password) do
CoreWeb.UserAuth.log_in_user(conn, user, false, user_params)
if user = Account.Public.get_user_by_email_and_password(email, password) do
Account.UserAuth.log_in_user(conn, user, false, user_params)
else
message = dgettext("eyra-user", "Invalid email or password")

Expand All @@ -47,6 +49,6 @@ defmodule Next.User.SessionController do
def delete(conn, _params) do
conn
|> put_flash(:info, dgettext("eyra-user", "Signed out successfully"))
|> CoreWeb.UserAuth.log_out_user()
|> Account.UserAuth.log_out_user()
end
end
58 changes: 58 additions & 0 deletions core/bundles/next/lib/account/signin_page.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
defmodule Next.Account.SigninPage do
use CoreWeb, :live_view
import CoreWeb.Layouts.Stripped.Html
import CoreWeb.Layouts.Stripped.Composer
import Frameworks.Pixel.Line

alias Frameworks.Pixel.Tabbar

alias Next.Account.SigninPageBuilder

@impl true
def mount(params, _session, socket) do
user_type = Map.get(params, "user_type", "participant")
initial_tab = Map.get(params, "tab", user_type)
tabbar_id = "account_signin"

{
:ok,
socket
|> assign(
email: Map.get(params, "email"),
user_type: user_type,
initial_tab: initial_tab,
tabbar_id: tabbar_id,
show_errors: true
)
|> update_view_model()
|> update_menus()
}
end

defp update_view_model(socket) do
vm = SigninPageBuilder.view_model(nil, socket.assigns)
assign(socket, vm: vm)
end

@impl true
def render(assigns) do
~H"""
<.stripped menus={@menus}>
<div id="signup_content" phx-hook="LiveContent" data-show-errors={true}>
<Area.form>
<Margin.y id={:page_top} />
<Margin.y id={:page_top} />
<Text.title2><%= dgettext("eyra-account", "signin.title") %></Text.title2>
<Tabbar.container id={@tabbar_id} tabs={@vm.tabs} initial_tab={@initial_tab} type={:segmented} size={:full} />
<.spacing value="M" />
<.line />
<.spacing value="M" />
<div id="tabbar_content" phx-hook="LiveContent" data-show-errors={@show_errors}>
<Tabbar.content include_top_margin={false} tabs={@vm.tabs} />
</div>
</Area.form>
</div>
</.stripped>
"""
end
end
Loading

0 comments on commit 162928d

Please sign in to comment.