From 1c0d8e524e1ce5de2c9ea184bc85fbf5e6d56da2 Mon Sep 17 00:00:00 2001 From: J Date: Fri, 26 Feb 2021 00:38:01 +0000 Subject: [PATCH] interface: thread gcp through props Basically just a grep for 's3', and I added gcp wherever it looked like I ought to. --- pkg/interface/src/logic/lib/s3.js | 41 ------------------- .../src/views/apps/links/LinkResource.tsx | 2 +- .../apps/profile/components/EditProfile.tsx | 6 +-- .../views/apps/profile/components/Profile.tsx | 1 + .../src/views/apps/profile/profile.tsx | 1 + .../views/apps/publish/PublishResource.tsx | 1 + .../apps/publish/components/EditPost.tsx | 6 ++- .../apps/publish/components/MarkdownField.tsx | 2 + .../apps/publish/components/NoteForm.tsx | 7 ++-- .../apps/publish/components/NoteRoutes.tsx | 11 ++++- .../publish/components/NotebookRoutes.tsx | 4 ++ .../apps/publish/components/new-post.tsx | 4 +- .../components/lib/BackgroundPicker.tsx | 5 ++- .../settings/components/lib/DisplayForm.tsx | 6 ++- .../apps/settings/components/settings.tsx | 2 + .../components/GroupSettings/Admin.tsx | 6 ++- .../GroupSettings/GroupSettings.tsx | 3 +- .../views/landscape/components/GroupsPane.tsx | 1 + .../landscape/components/PopoverRoutes.tsx | 9 +++- 19 files changed, 59 insertions(+), 59 deletions(-) delete mode 100644 pkg/interface/src/logic/lib/s3.js diff --git a/pkg/interface/src/logic/lib/s3.js b/pkg/interface/src/logic/lib/s3.js deleted file mode 100644 index 64bda11be7..0000000000 --- a/pkg/interface/src/logic/lib/s3.js +++ /dev/null @@ -1,41 +0,0 @@ -import S3 from 'aws-sdk/clients/s3'; - -export default class S3Client { - constructor() { - this.s3 = null; - - this.endpoint = ''; - this.accessKeyId = ''; - this.secretAccesskey = ''; - } - - setCredentials(endpoint, accessKeyId, secretAccessKey) { - this.endpoint = endpoint; - this.accessKeyId = accessKeyId; - this.secretAccessKey = secretAccessKey; - - this.s3 = new S3({ - endpoint: endpoint, - credentials: { - accessKeyId: this.accessKeyId, - secretAccessKey: this.secretAccessKey - } - }); - } - - async upload(bucket, filename, buffer) { - const params = { - Bucket: bucket, - Key: filename, - Body: buffer, - ACL: 'public-read', - ContentType: buffer.type - }; - - if(!this.s3) { - throw new Error('S3 not initialized'); - } - return this.s3.upload(params).promise(); - } -} - diff --git a/pkg/interface/src/views/apps/links/LinkResource.tsx b/pkg/interface/src/views/apps/links/LinkResource.tsx index bb1dec2781..5b4aeff556 100644 --- a/pkg/interface/src/views/apps/links/LinkResource.tsx +++ b/pkg/interface/src/views/apps/links/LinkResource.tsx @@ -34,8 +34,8 @@ export function LinkResource(props: LinkResourceProps) { associations, graphKeys, unreads, - s3, gcp, + s3, history } = props; diff --git a/pkg/interface/src/views/apps/profile/components/EditProfile.tsx b/pkg/interface/src/views/apps/profile/components/EditProfile.tsx index d43cfbaad2..1aca97d866 100644 --- a/pkg/interface/src/views/apps/profile/components/EditProfile.tsx +++ b/pkg/interface/src/views/apps/profile/components/EditProfile.tsx @@ -114,15 +114,15 @@ export function EditProfile(props: any) { Description - + - + - + diff --git a/pkg/interface/src/views/apps/profile/components/Profile.tsx b/pkg/interface/src/views/apps/profile/components/Profile.tsx index 0072b591bc..7252eec3c3 100644 --- a/pkg/interface/src/views/apps/profile/components/Profile.tsx +++ b/pkg/interface/src/views/apps/profile/components/Profile.tsx @@ -107,6 +107,7 @@ export function Profile(props: any) { diff --git a/pkg/interface/src/views/apps/publish/components/EditPost.tsx b/pkg/interface/src/views/apps/publish/components/EditPost.tsx index 0f6ed4dcc0..84ca37acf3 100644 --- a/pkg/interface/src/views/apps/publish/components/EditPost.tsx +++ b/pkg/interface/src/views/apps/publish/components/EditPost.tsx @@ -4,7 +4,7 @@ import { PostFormSchema, PostForm } from "./NoteForm"; import { FormikHelpers } from "formik"; import GlobalApi from "~/logic/api/global"; import { RouteComponentProps, useLocation } from "react-router-dom"; -import { GraphNode, TextContent, Association, S3State } from "~/types"; +import { GraphNode, TextContent, Association, GcpState, S3State } from "~/types"; import { getLatestRevision, editPost } from "~/logic/lib/publish"; import {useWaitForProps} from "~/logic/lib/useWaitForProps"; interface EditPostProps { @@ -13,11 +13,12 @@ interface EditPostProps { note: GraphNode; api: GlobalApi; book: string; + gcp: GcpState; s3: S3State; } export function EditPost(props: EditPostProps & RouteComponentProps) { - const { note, book, noteId, api, ship, history, s3 } = props; + const { note, book, noteId, api, ship, history, gcp, s3 } = props; const [revNum, title, body] = getLatestRevision(note); const location = useLocation(); @@ -54,6 +55,7 @@ export function EditPost(props: EditPostProps & RouteComponentProps) { cancel history={history} onSubmit={onSubmit} + gcp={gcp} s3={s3} submitLabel="Update" loadingText="Updating..." diff --git a/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx b/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx index 750a649784..c6adb0b6b8 100644 --- a/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx +++ b/pkg/interface/src/views/apps/publish/components/MarkdownField.tsx @@ -6,6 +6,7 @@ import { MarkdownEditor } from "./MarkdownEditor"; export const MarkdownField = ({ id, + gcp, s3, ...rest }: { id: string } & Parameters[0]) => { @@ -35,6 +36,7 @@ export const MarkdownField = ({ onBlur={handleBlur} value={value} onChange={setValue} + gcp={gcp} s3={s3} /> diff --git a/pkg/interface/src/views/apps/publish/components/NoteForm.tsx b/pkg/interface/src/views/apps/publish/components/NoteForm.tsx index 6fbaaee20a..ff2001ff68 100644 --- a/pkg/interface/src/views/apps/publish/components/NoteForm.tsx +++ b/pkg/interface/src/views/apps/publish/components/NoteForm.tsx @@ -9,7 +9,7 @@ import { import { AsyncButton } from "../../../components/AsyncButton"; import { Formik, Form, FormikHelpers } from "formik"; import { MarkdownField } from "./MarkdownField"; -import { S3State } from "~/types"; +import { GcpState, S3State } from "~/types"; interface PostFormProps { initial: PostFormSchema; @@ -21,6 +21,7 @@ interface PostFormProps { ) => Promise; submitLabel: string; loadingText: string; + gcp: GcpState; s3: S3State; } @@ -35,7 +36,7 @@ export interface PostFormSchema { } export function PostForm(props: PostFormProps) { - const { initial, onSubmit, submitLabel, loadingText, s3, cancel, history } = props; + const { initial, onSubmit, submitLabel, loadingText, gcp, s3, cancel, history } = props; return ( @@ -66,7 +67,7 @@ export function PostForm(props: PostFormProps) { type="button">Cancel} - + diff --git a/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx b/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx index 916347038a..234ef941c6 100644 --- a/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx +++ b/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx @@ -6,7 +6,15 @@ import { RouteComponentProps } from "react-router-dom"; import Note from "./Note"; import { EditPost } from "./EditPost"; -import { GraphNode, Graph, Contacts, Association, S3State, Group } from "~/types"; +import { + GraphNode, + Graph, + Contacts, + Association, + GcpState, + S3State, + Group +} from "~/types"; interface NoteRoutesProps { ship: string; @@ -20,6 +28,7 @@ interface NoteRoutesProps { baseUrl?: string; rootUrl?: string; group: Group; + gcp: GcpState; s3: S3State; } diff --git a/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx b/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx index a3d1f5474f..a134613fe5 100644 --- a/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx @@ -9,6 +9,7 @@ import { Contacts, Rolodex, Unreads, + GcpState, S3State } from "~/types"; import { Center, LoadingSpinner } from "@tlon/indigo-react"; @@ -33,6 +34,7 @@ interface NotebookRoutesProps { rootUrl: string; association: Association; associations: Associations; + gcp: GcpState; s3: S3State; } @@ -80,6 +82,7 @@ export function NotebookRoutes( association={props.association} graph={graph} baseUrl={baseUrl} + gcp={props.gcp} s3={props.s3} /> )} @@ -112,6 +115,7 @@ export function NotebookRoutes( contacts={notebookContacts} association={props.association} group={group} + gcp={props.gcp} s3={props.s3} {...routeProps} /> diff --git a/pkg/interface/src/views/apps/publish/components/new-post.tsx b/pkg/interface/src/views/apps/publish/components/new-post.tsx index 2b0dd366a2..c56410e2fd 100644 --- a/pkg/interface/src/views/apps/publish/components/new-post.tsx +++ b/pkg/interface/src/views/apps/publish/components/new-post.tsx @@ -6,7 +6,7 @@ import { RouteComponentProps } from "react-router-dom"; import { PostForm, PostFormSchema } from "./NoteForm"; import {createPost} from "~/logic/api/graph"; import {Graph} from "~/types/graph-update"; -import {Association, S3State} from "~/types"; +import {Association, GcpState, S3State} from "~/types"; import {newPost} from "~/logic/lib/publish"; interface NewPostProps { @@ -16,6 +16,7 @@ interface NewPostProps { graph: Graph; association: Association; baseUrl: string; + gcp: GcpState; s3: S3State; } @@ -53,6 +54,7 @@ export default function NewPost(props: NewPostProps & RouteComponentProps) { onSubmit={onSubmit} submitLabel="Publish" loadingText="Posting..." + gcp={props.gcp} s3={props.s3} /> ); diff --git a/pkg/interface/src/views/apps/settings/components/lib/BackgroundPicker.tsx b/pkg/interface/src/views/apps/settings/components/lib/BackgroundPicker.tsx index 53aed1b3e9..e90c757490 100644 --- a/pkg/interface/src/views/apps/settings/components/lib/BackgroundPicker.tsx +++ b/pkg/interface/src/views/apps/settings/components/lib/BackgroundPicker.tsx @@ -9,7 +9,7 @@ import { } from "@tlon/indigo-react"; import GlobalApi from "~/logic/api/global"; -import { S3State } from "~/types"; +import { GcpState, S3State } from "~/types"; import { ImageInput } from "~/views/components/ImageInput"; import {ColorInput} from "~/views/components/ColorInput"; @@ -19,11 +19,13 @@ export function BackgroundPicker({ bgType, bgUrl, api, + gcp, s3, }: { bgType: BgType; bgUrl?: string; api: GlobalApi; + gcp: GcpState; s3: S3State; }) { @@ -38,6 +40,7 @@ export function BackgroundPicker({ diff --git a/pkg/interface/src/views/landscape/components/GroupSettings/Admin.tsx b/pkg/interface/src/views/landscape/components/GroupSettings/Admin.tsx index 34fc6f9abf..a9ac19856b 100644 --- a/pkg/interface/src/views/landscape/components/GroupSettings/Admin.tsx +++ b/pkg/interface/src/views/landscape/components/GroupSettings/Admin.tsx @@ -22,7 +22,7 @@ import { ColorInput } from "~/views/components/ColorInput"; import { useHistory } from "react-router-dom"; import { uxToHex } from "~/logic/lib/util"; -import {S3State} from "~/types"; +import {GcpState, S3State} from "~/types"; import {ImageInput} from "~/views/components/ImageInput"; interface FormSchema { @@ -46,11 +46,12 @@ interface GroupAdminSettingsProps { group: Group; association: Association; api: GlobalApi; + gcp: GcpState; s3: S3State; } export function GroupAdminSettings(props: GroupAdminSettingsProps) { - const { group, association, s3 } = props; + const { group, association, gcp, s3 } = props; const { metadata } = association; const history = useHistory(); const currentPrivate = "invite" in props.group.policy; @@ -132,6 +133,7 @@ export function GroupAdminSettings(props: GroupAdminSettingsProps) { caption="A picture for your group" placeholder="Enter URL" disabled={disabled} + gcp={gcp} s3={s3} /> )}