Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): update story custom domain extension #1361

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { AssetField, InputField, SwitchField } from "@reearth/beta/ui/fields";
import TextAreaField from "@reearth/beta/ui/fields/TextareaField";
import { Story } from "@reearth/services/api/storytellingApi/utils";
import { useAuth } from "@reearth/services/auth";
import {
ProjectPublicationExtensionProps,
StoryPublicationExtensionProps
} from "@reearth/services/config/extensions";
import { useLang, useT } from "@reearth/services/i18n";
import {
NotificationType,
Expand Down Expand Up @@ -104,6 +108,18 @@ const PublicSettingsDetail: React.FC<Props> = ({
[setNotification]
);

const ExtensionComponent = (
props: ProjectPublicationExtensionProps | StoryPublicationExtensionProps
) => {
const type = props.typename.toLocaleLowerCase();
const extensionId = `custom-${type}-domain`;
const Component = extensions?.find((e) => e.id === extensionId)?.component;
if (!Component) {
return null;
}
return <Component {...props} />;
};

return (
<>
<Collapse title={t("Public Info")} size="large">
Expand Down Expand Up @@ -233,22 +249,31 @@ const PublicSettingsDetail: React.FC<Props> = ({
</ButtonWrapper>
</SettingsFields>
</Collapse>
{extensions && extensions.length > 0 && accessToken && (
<Collapse title={t("Custom Domain")} size="large">
{extensions.map((ext) => (
<ext.component
key={ext.id}
projectId={settingsItem.id}
projectAlias={settingsItem.alias}
{extensions &&
extensions.length > 0 &&
settingsItem.__typename &&
accessToken && (
<Collapse title={t("Custom Domain")} size="large">
<ExtensionComponent
typename={settingsItem.__typename}
key={settingsItem.id}
{...(settingsItem.__typename === "Project"
? {
projectId: settingsItem.id,
projectAlias: settingsItem.alias
}
: {
storyId: settingsItem.id,
storyAlias: settingsItem.alias
})}
lang={currentLang}
theme={currentTheme}
accessToken={accessToken}
onNotificationChange={onNotificationChange}
version={"visualizer"}
version="visualizer"
/>
))}
</Collapse>
)}
</Collapse>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type SettingsProject = {
isArchived: boolean;
enableGa: boolean;
trackingId: string;
__typename: string;
};

type Props = {
Expand Down
1 change: 1 addition & 0 deletions web/src/services/api/storytellingApi/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export type Story = {
pages?: Page[];
trackingId?: string; // Not supported yet
enableGa?: boolean; // Not supported yet
__typename: string;
};

export const getStories = (rawScene?: GetSceneQuery) => {
Expand Down
12 changes: 11 additions & 1 deletion web/src/services/config/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export type ProjectPublicationExtensionProps = {
projectId: string;
projectAlias?: string;
publishDisabled?: boolean;
typename: string;
} & SharedExtensionProps;

export type StoryPublicationExtensionProps = {
storyId: string;
storyAlias?: string;
publishDisabled?: boolean;
typename: string;
} & SharedExtensionProps;

export type PluginExtensionProps = {
Expand All @@ -50,7 +58,9 @@ export type GlobalModalProps = {

export type ExtensionProps = {
"dataset-import": DatasetImportExtensionProps;
publication: ProjectPublicationExtensionProps;
publication:
| ProjectPublicationExtensionProps
| StoryPublicationExtensionProps;
"plugin-library": PluginExtensionProps;
"plugin-installed": PluginExtensionProps;
"global-modal": GlobalModalProps;
Expand Down
Loading