Skip to content

Commit

Permalink
Rename journey -> journeys, update copy
Browse files Browse the repository at this point in the history
  • Loading branch information
hulloitskai committed Dec 13, 2023
1 parent 808d7db commit 59a1778
Show file tree
Hide file tree
Showing 43 changed files with 461 additions and 344 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down
2 changes: 2 additions & 0 deletions Profile.ci-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vite-ssr: bin/vite ssr
rails: sleep 1 && bin/rails db:prepare && bin/rails test:all || exit -1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { AppShellProps, ContainerProps, MantineSize } from "@mantine/core";
import type { Maybe } from "~/helpers/graphql";
import type { AppViewerFragment } from "~/helpers/graphql";

import JourneyAppMeta from "./JourneyAppMeta";
import type { JourneyAppMetaProps } from "./JourneyAppMeta";
import JourneysAppMeta from "./JourneysAppMeta";
import type { JourneysAppMetaProps } from "./JourneysAppMeta";

// import AppMenu from "./AppMenu";
import AppFlash from "./AppFlash";
Expand All @@ -17,23 +17,23 @@ import PageLayout from "./PageLayout";
import "./AppLayout.css";
import classes from "./AppLayout.module.css";

export type JourneyAppLayoutProps = JourneyAppMetaProps &
export type JourneysAppLayoutProps = JourneysAppMetaProps &
AppShellProps & {
readonly viewer: Maybe<AppViewerFragment>;
readonly breadcrumbs?: ReadonlyArray<JourneyAppBreadcrumb | null | false>;
readonly breadcrumbs?: ReadonlyArray<JourneysAppBreadcrumb | null | false>;
readonly withContainer?: boolean;
readonly containerSize?: MantineSize | (string & {}) | number;
readonly containerProps?: ContainerProps;
readonly withGutter?: boolean;
readonly gutterSize?: MantineSize | (string & {}) | number;
};

export type JourneyAppBreadcrumb = {
export type JourneysAppBreadcrumb = {
readonly title: string;
readonly href: string;
};

const JourneyAppLayout: FC<JourneyAppLayoutProps> = ({
const JourneysAppLayout: FC<JourneysAppLayoutProps> = ({
// viewer,
title,
description,
Expand All @@ -51,7 +51,7 @@ const JourneyAppLayout: FC<JourneyAppLayoutProps> = ({
}) => {
// == Breadcrumbs
const filteredBreadcrumbs = useMemo(
() => (breadcrumbs?.filter(x => !!x) || []) as JourneyAppBreadcrumb[],
() => (breadcrumbs?.filter(x => !!x) || []) as JourneysAppBreadcrumb[],
[breadcrumbs],
);

Expand All @@ -74,7 +74,7 @@ const JourneyAppLayout: FC<JourneyAppLayoutProps> = ({

return (
<PageLayout>
<JourneyAppMeta {...{ title, description, imageUrl, noIndex }} />
<JourneysAppMeta {...{ title, description, imageUrl, noIndex }} />
<AppShell
header={{ height: 44 }}
footer={{ height: 44 }}
Expand Down Expand Up @@ -110,7 +110,7 @@ const JourneyAppLayout: FC<JourneyAppLayoutProps> = ({
fz="md"
className={classes.logo}
>
Journey
Journeys
</Button>
{/* <AppMenu style={{ flexShrink: 0 }} {...{ viewer }} /> */}
</AppShell.Header>
Expand Down Expand Up @@ -155,4 +155,4 @@ const JourneyAppLayout: FC<JourneyAppLayoutProps> = ({
);
};

export default JourneyAppLayout;
export default JourneysAppLayout;
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { FC } from "react";

const JourneyAppMetaSiteType = "website";
const JourneyAppMetaSiteName = "Journey";
const JourneyAppMetaSiteName = "Journeys";
const JourneyAppMetaSiteDescription = undefined; // "Welcome to my little corner of the internet :)";
const JourneyAppMetaSiteImage = undefined; // "/banner.png";
const JourneyAppMetaTitleSeparator = "|";

export type JourneyAppMetaProps = {
export type JourneysAppMetaProps = {
readonly title?: string | string[];
readonly description?: string | null;
readonly imageUrl?: string | null;
readonly noIndex?: boolean;
};

const JourneyAppMeta: FC<JourneyAppMetaProps> = ({
const JourneysAppMeta: FC<JourneysAppMetaProps> = ({
title: titleProp,
description = JourneyAppMetaSiteDescription,
imageUrl = JourneyAppMetaSiteImage,
Expand Down Expand Up @@ -60,4 +60,4 @@ const JourneyAppMeta: FC<JourneyAppMetaProps> = ({
);
};

export default JourneyAppMeta;
export default JourneysAppMeta;
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# typed: strict
# frozen_string_literal: true

class JourneySubdomainConstraint
class JourneysSubdomainConstraint
extend T::Sig

sig { params(request: ActionDispatch::Request).returns(T::Boolean) }
def matches?(request)
subdomain = T.let(request.subdomain.dup, String)
subdomain.delete_suffix!(".127.0.0.1") if Rails.env.development?
subdomain == "journey"
subdomain == "journeys"
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# typed: strict
# frozen_string_literal: true

module Journey
module Journeys
class ApplicationController < ::ApplicationController
# == Filters
before_action :set_participant_id

# == Authorization
authorize :participant_id

private

# == Helpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# typed: true
# frozen_string_literal: true

module Journey
module Journeys
class HomeController < ApplicationController
# == Filters
before_action :set_active_session

# == Actions
def show
if (session = @active_session)
redirect_to(journey_session_path(session))
redirect_to(journeys_session_path(session))
else
render(inertia: "JourneyHomePage")
render(inertia: "JourneysHomePage")
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# typed: true
# frozen_string_literal: true

module Journey
module Journeys
class SessionsController < ApplicationController
# == Filters
before_action :set_session_and_participation, only: :show
before_action :set_session, only: :show

# == Actions
def show
session = @session or raise "Missing session"
if @participation
data = query!("JourneySessionPageQuery", {
if allowed_to?(:show?, session)
data = query!("JourneysSessionPageQuery", {
session_id: session.to_gid.to_s,
})
render(inertia: "JourneySessionPage", props: {
render(inertia: "JourneysSessionPage", props: {
homepage_url: journeys_root_url,
data:,
})
else
redirect_to(
journey_root_path,
journeys_root_path,
alert: "You are not a participant in this session.",
)
end
Expand All @@ -33,10 +34,10 @@ def create
**participation_params,
)
session.save!
redirect_to(journey_session_path(session))
redirect_to(journeys_session_path(session))
rescue => error
redirect_to(
journey_root_path,
journeys_root_path,
alert: "Failed to start session: #{error.message}",
)
end
Expand Down Expand Up @@ -80,15 +81,11 @@ def transcribe_goal_recording

# == Filter Handlers
sig { void }
def set_session_and_participation
def set_session
@session = T.let(
Session.friendly.find(params.fetch(:id)),
T.nilable(Session),
)
@participation = T.let(
SessionParticipation.find_by(session: @session, participant_id:),
T.nilable(SessionParticipation),
)
end
end
end
3 changes: 2 additions & 1 deletion app/graphql/concerns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Resolver
extend T::Sig
extend T::Helpers
extend ActiveSupport::Concern
include Routing

# == Annotations
Expand Down Expand Up @@ -77,7 +78,7 @@ def actor_id
end

sig { returns(String) }
def journey_participant_id
def journeys_participant_id
cookies.signed[:journey_participant_id] or
raise "Missing journey participant ID"
end
Expand Down
9 changes: 9 additions & 0 deletions app/graphql/queries/journeys_base_query.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# typed: strict
# frozen_string_literal: true

module Queries
class JourneysBaseQuery < BaseQuery
# == Authorization
authorize :participant_id, through: :journeys_participant_id
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# frozen_string_literal: true

module Queries
class JourneySession < BaseQuery
class JourneysSession < JourneysBaseQuery
include AllowsFailedLoads

# == Type
type Types::JourneySessionType, null: true
type Types::JourneysSessionType, null: true

# == Arguments
argument :id, ID, loads: Types::JourneySessionType, as: :session
argument :id, ID, loads: Types::JourneysSessionType, as: :session

# == Resolver
sig do
params(session: T.nilable(::Journey::Session))
.returns(T.nilable(::Journey::Session))
params(session: T.nilable(::Journeys::Session))
.returns(T.nilable(::Journeys::Session))
end
def resolve(session:)
return unless session
Expand Down
22 changes: 0 additions & 22 deletions app/graphql/subscriptions/journey_session_participation.rb

This file was deleted.

22 changes: 22 additions & 0 deletions app/graphql/subscriptions/journeys_session_participation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# typed: strict
# frozen_string_literal: true

module Subscriptions
class JourneysSessionParticipation < BaseSubscription
# == Configuration
broadcastable false

# == Type
type Types::JourneysSessionParticipationType, null: true

# == Arguments
argument :session_id, ID, loads: Types::JourneysSessionType

# == Callback Handlers
sig do
params(session: ::Journeys::Session)
.returns(T.nilable(::Journeys::SessionParticipation))
end
def subscribe(session:) = nil
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
# frozen_string_literal: true

module Types
class JourneySessionParticipationType < BaseObject
class JourneysSessionParticipationType < BaseObject
# == Interfaces
implements NodeType

# == Fields
field :goal, String, null: false
field :participant_is_viewer, Boolean, null: false
field :participant_name, String, null: false
field :session, [JourneySessionType], null: false
field :session, [JourneysSessionType], null: false

# == Resolvers
sig { returns(T::Boolean) }
def participant_is_viewer
journey_participant_id == object.participant_id
journeys_participant_id == object.participant_id
end

# == Helpers
sig { override.returns(::Journey::SessionParticipation) }
sig { override.returns(::Journeys::SessionParticipation) }
def object = super
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# frozen_string_literal: true

module Types
class JourneySessionType < BaseObject
class JourneysSessionType < BaseObject
# == Interfaces
implements NodeType

# == Fields
field :participations, [JourneySessionParticipationType], null: false
field :participations, [JourneysSessionParticipationType], null: false
field :started_at, DateTimeType, null: false, method: :created_at
field :url, String, null: false

# == Resolvers
sig { returns(String) }
def url
journey_session_url(object)
journeys_session_url(object)
end

# == Helpers
sig { override.returns(::Journey::Session) }
sig { override.returns(::Journeys::Session) }
def object = super
end
end
2 changes: 1 addition & 1 deletion app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QueryType < BaseObject
field :journal_entry, resolver: Queries::JournalEntry
field :journal_entry_comments, resolver: Queries::JournalEntryComments

field :journey_session, resolver: Queries::JourneySession
field :journeys_session, resolver: Queries::JourneysSession
field :location_access_grants, resolver: Queries::LocationAccessGrants
field :pensieve_messages, resolver: Queries::PensieveMessages
end
Expand Down
Loading

0 comments on commit 59a1778

Please sign in to comment.