Skip to content

Commit

Permalink
Working About page
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Jan 15, 2025
1 parent 2c889a8 commit 120f715
Show file tree
Hide file tree
Showing 21 changed files with 606 additions and 128 deletions.
98 changes: 98 additions & 0 deletions packages/api/generated-schema-clean.gql
Original file line number Diff line number Diff line change
Expand Up @@ -9143,6 +9143,18 @@ type Mutation {
"""
input: ToggleResponsesPracticeInput!
): ToggleResponsesPracticePayload
updateAboutPageContent(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: UpdateAboutPageContentInput!
): UpdateAboutPageContentPayload
updateAboutPageEnabled(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: UpdateAboutPageEnabledInput!
): UpdateAboutPageEnabledPayload

"""Updates a single `Acl` using a unique key and a patch."""
updateAcl(
Expand Down Expand Up @@ -10353,6 +10365,16 @@ needed to drive the application.
"""
type Project implements Node {
aboutPageContents: JSON!
aboutPageEnabled: Boolean!

"""
Metadata will be returned as directly stored in the SeaSketch
database or computed by fetching from a 3rd party service,
depending on the data source type.
"""
aboutPageRenderedContent: [RenderedAboutPageContent]

"""
Admins can control whether a project is public, invite-only, or admins-only.
"""
Expand Down Expand Up @@ -12822,6 +12844,11 @@ type RemoveValidChildSketchClassPayload {
query: Query
}

type RenderedAboutPageContent {
html: String
lang: String
}

enum RenderUnderType {
LABELS
LAND
Expand Down Expand Up @@ -15253,6 +15280,77 @@ type UnsplashUser {
username: String!
}

"""All input for the `updateAboutPageContent` mutation."""
input UpdateAboutPageContentInput {
"""
An arbitrary string value with no semantic meaning. Will be included in the
payload verbatim. May be used to track mutations by the client.
"""
clientMutationId: String
content: JSON
lang: String
slug: String
}

"""The output of our `updateAboutPageContent` mutation."""
type UpdateAboutPageContentPayload {
"""
The exact same `clientMutationId` that was provided in the mutation input,
unchanged and unused. May be used by a client to track mutations.
"""
clientMutationId: String

"""Reads a single `DataSourcesBucket` that is related to this `Project`."""
dataSourcesBucket: DataSourcesBucket
project: Project

"""An edge for our `Project`. May be used by Relay 1."""
projectEdge(
"""The method to use when ordering `Project`."""
orderBy: [ProjectsOrderBy!] = [PRIMARY_KEY_ASC]
): ProjectsEdge

"""
Our root query field type. Allows us to run any query from our mutation payload.
"""
query: Query
}

"""All input for the `updateAboutPageEnabled` mutation."""
input UpdateAboutPageEnabledInput {
"""
An arbitrary string value with no semantic meaning. Will be included in the
payload verbatim. May be used to track mutations by the client.
"""
clientMutationId: String
enabled: Boolean
slug: String
}

"""The output of our `updateAboutPageEnabled` mutation."""
type UpdateAboutPageEnabledPayload {
"""
The exact same `clientMutationId` that was provided in the mutation input,
unchanged and unused. May be used by a client to track mutations.
"""
clientMutationId: String

"""Reads a single `DataSourcesBucket` that is related to this `Project`."""
dataSourcesBucket: DataSourcesBucket
project: Project

"""An edge for our `Project`. May be used by Relay 1."""
projectEdge(
"""The method to use when ordering `Project`."""
orderBy: [ProjectsOrderBy!] = [PRIMARY_KEY_ASC]
): ProjectsEdge

"""
Our root query field type. Allows us to run any query from our mutation payload.
"""
query: Query
}

"""All input for the `updateAclByBasemapId` mutation."""
input UpdateAclByBasemapIdInput {
basemapId: Int!
Expand Down
12 changes: 12 additions & 0 deletions packages/api/generated-schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -10368,6 +10368,13 @@ type Project implements Node {
aboutPageContents: JSON!
aboutPageEnabled: Boolean!

"""
Metadata will be returned as directly stored in the SeaSketch
database or computed by fetching from a 3rd party service,
depending on the data source type.
"""
aboutPageRenderedContent: [RenderedAboutPageContent]

"""
Admins can control whether a project is public, invite-only, or admins-only.
"""
Expand Down Expand Up @@ -12837,6 +12844,11 @@ type RemoveValidChildSketchClassPayload {
query: Query
}

type RenderedAboutPageContent {
html: String
lang: String
}

enum RenderUnderType {
LABELS
LAND
Expand Down
35 changes: 35 additions & 0 deletions packages/api/migrations/committed/000347.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--! Previous: sha1:e697656842a7b30ad925e95f11e70f0620739495
--! Hash: sha1:90ea7a3aac6c1bbbe0a2e80c9e975cf5b1a96421

-- Enter migration here
alter table projects add column if not exists about_page_contents jsonb not null default '{}'::jsonb;

alter table projects add column if not exists about_page_enabled boolean not null default false;

create or replace function update_about_page_content(slug text, content jsonb, lang text)
returns projects
language sql
security definer
as $$
update projects
set about_page_contents = jsonb_set(about_page_contents, array[lang], content)
where projects.slug = update_about_page_content.slug
and session_is_admin(projects.id)
returning *;
$$;

grant execute on function update_about_page_content(text, jsonb, text) to seasketch_user;

create or replace function update_about_page_enabled(slug text, enabled boolean)
returns projects
security definer
language sql
as $$
update projects
set about_page_enabled = enabled
where projects.slug = update_about_page_enabled.slug
and session_is_admin(projects.id)
returning *;
$$;

grant execute on function update_about_page_enabled(text, boolean) to seasketch_user;
31 changes: 0 additions & 31 deletions packages/api/migrations/current.sql
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
-- Enter migration here
alter table projects add column if not exists about_page_contents jsonb not null default '{}'::jsonb;

alter table projects add column if not exists about_page_enabled boolean not null default false;

create or replace function update_about_page_content(slug text, content jsonb, lang text)
returns projects
language sql
security definer
as $$
update projects
set about_page_contents = jsonb_set(about_page_contents, array[lang], content)
where projects.slug = update_about_page_content.slug
and session_is_admin(projects.id)
returning *;
$$;

grant execute on function update_about_page_content(text, jsonb, text) to seasketch_user;

create or replace function update_about_page_enabled(slug text, enabled boolean)
returns projects
security definer
language sql
as $$
update projects
set about_page_enabled = enabled
where projects.slug = update_about_page_enabled.slug
and session_is_admin(projects.id)
returning *;
$$;

grant execute on function update_about_page_enabled(text, boolean) to seasketch_user;
71 changes: 48 additions & 23 deletions packages/api/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,8 @@ CREATE TABLE public.projects (
hide_overlays boolean DEFAULT false NOT NULL,
enable_download_by_default boolean DEFAULT false NOT NULL,
data_hosting_retention_period interval,
about_page_contents jsonb DEFAULT '{}'::jsonb NOT NULL,
about_page_enabled boolean DEFAULT false NOT NULL,
CONSTRAINT disallow_unlisted_public_projects CHECK (((access_control <> 'public'::public.project_access_control_setting) OR (is_listed = true))),
CONSTRAINT is_public_key CHECK (((mapbox_public_key IS NULL) OR (mapbox_public_key ~* '^pk\..+'::text))),
CONSTRAINT is_secret CHECK (((mapbox_secret_key IS NULL) OR (mapbox_secret_key ~* '^sk\..+'::text))),
Expand Down Expand Up @@ -6136,22 +6138,6 @@ CREATE FUNCTION public.copy_table_of_contents_item(item_id integer, copy_data_so
$$;


--
-- Name: copy_table_of_contents_item_recursive(integer, boolean, boolean, integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.copy_table_of_contents_item_recursive(item_id integer, copy_data_source boolean, append_copy_to_name boolean, project_id integer) RETURNS integer
LANGUAGE plpgsql SECURITY DEFINER
AS $$
declare
copy_id int;
child record;
begin
copy_id := copy_table_of_contents_item(item_id, copy_data_source, append_copy_to_name, project_id);
end;
$$;


--
-- Name: copy_table_of_contents_item_recursive(integer, boolean, boolean, integer, public.ltree, text); Type: FUNCTION; Schema: public; Owner: -
--
Expand Down Expand Up @@ -17554,6 +17540,36 @@ $$;
COMMENT ON FUNCTION public.unsubscribed("userId" integer) IS '@omit';


--
-- Name: update_about_page_content(text, jsonb, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_about_page_content(slug text, content jsonb, lang text) RETURNS public.projects
LANGUAGE sql SECURITY DEFINER
AS $$
update projects
set about_page_contents = jsonb_set(about_page_contents, array[lang], content)
where projects.slug = update_about_page_content.slug
and session_is_admin(projects.id)
returning *;
$$;


--
-- Name: update_about_page_enabled(text, boolean); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_about_page_enabled(slug text, enabled boolean) RETURNS public.projects
LANGUAGE sql SECURITY DEFINER
AS $$
update projects
set about_page_enabled = enabled
where projects.slug = update_about_page_enabled.slug
and session_is_admin(projects.id)
returning *;
$$;


--
-- Name: update_basemap_offline_tile_settings(integer, integer, boolean, integer, integer); Type: FUNCTION; Schema: public; Owner: -
--
Expand Down Expand Up @@ -26453,13 +26469,6 @@ GRANT ALL ON FUNCTION public.copy_sketch_toc_item_recursive_for_forum(parent_id
REVOKE ALL ON FUNCTION public.copy_table_of_contents_item(item_id integer, copy_data_source boolean, append_copy_to_name boolean, "projectId" integer, lpath public.ltree, "parentStableId" text) FROM PUBLIC;


--
-- Name: FUNCTION copy_table_of_contents_item_recursive(item_id integer, copy_data_source boolean, append_copy_to_name boolean, project_id integer); Type: ACL; Schema: public; Owner: -
--

REVOKE ALL ON FUNCTION public.copy_table_of_contents_item_recursive(item_id integer, copy_data_source boolean, append_copy_to_name boolean, project_id integer) FROM PUBLIC;


--
-- Name: FUNCTION copy_table_of_contents_item_recursive(item_id integer, copy_data_source boolean, append_copy_to_name boolean, project_id integer, lpath public.ltree, parent_stable_id text); Type: ACL; Schema: public; Owner: -
--
Expand Down Expand Up @@ -34419,6 +34428,22 @@ REVOKE ALL ON FUNCTION public.unsubscribed("userId" integer) FROM PUBLIC;
GRANT ALL ON FUNCTION public.unsubscribed("userId" integer) TO graphile;


--
-- Name: FUNCTION update_about_page_content(slug text, content jsonb, lang text); Type: ACL; Schema: public; Owner: -
--

REVOKE ALL ON FUNCTION public.update_about_page_content(slug text, content jsonb, lang text) FROM PUBLIC;
GRANT ALL ON FUNCTION public.update_about_page_content(slug text, content jsonb, lang text) TO seasketch_user;


--
-- Name: FUNCTION update_about_page_enabled(slug text, enabled boolean); Type: ACL; Schema: public; Owner: -
--

REVOKE ALL ON FUNCTION public.update_about_page_enabled(slug text, enabled boolean) FROM PUBLIC;
GRANT ALL ON FUNCTION public.update_about_page_enabled(slug text, enabled boolean) TO seasketch_user;


--
-- Name: FUNCTION update_basemap_offline_tile_settings("projectId" integer, "basemapId" integer, use_default boolean, "maxZ" integer, "maxShorelineZ" integer); Type: ACL; Schema: public; Owner: -
--
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/graphileOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import SearchOverlaysRateLimiterPlugin from "./plugins/searchOverlaysRateLimiter
import ProjectBackgroundJobSubscriptionPlugin from "./plugins/projectBackgroundJobSubscriptionPlugin";
import MetadataParserPlugin from "./plugins/metadataParserPlugin";
import ApiKeyPlugin from "./plugins/apiKeyPlugin";
import AboutPagePlugin from "./plugins/aboutPagePlugin";

const pluginHook = makePluginHook([{ ...PgPubsub, ...SentryPlugin }]);

Expand Down Expand Up @@ -98,6 +99,7 @@ export default function graphileOptions(): PostGraphileOptions {
ProjectBackgroundJobSubscriptionPlugin,
MetadataParserPlugin,
ApiKeyPlugin,
AboutPagePlugin,
// reorderSchemaFields(graphqlSchemaModifiers.fieldOrder),
// extraDocumentationPlugin(graphqlSchemaModifiers.documentation),
],
Expand Down
Loading

0 comments on commit 120f715

Please sign in to comment.