Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
/**
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
import { useForm } from "react-hook-form";
|
|
import { Button } from "@makeplane/propel/components/button";
|
|
import type { IFormattedInstanceConfiguration, TInstanceImageConfigurationKeys } from "@plane/types";
|
|
// components
|
|
import { ControllerInput } from "@/components/common/controller-input";
|
|
import { TOAST_TYPE, setToast } from "@/providers/toast";
|
|
// hooks
|
|
import { useInstance } from "@/hooks/store";
|
|
|
|
type IInstanceImageConfigForm = {
|
|
config: IFormattedInstanceConfiguration;
|
|
};
|
|
|
|
type ImageConfigFormValues = Record<TInstanceImageConfigurationKeys, string>;
|
|
|
|
export function InstanceImageConfigForm(props: IInstanceImageConfigForm) {
|
|
const { config } = props;
|
|
// store hooks
|
|
const { updateInstanceConfigurations } = useInstance();
|
|
// form data
|
|
const {
|
|
handleSubmit,
|
|
control,
|
|
formState: { errors, isSubmitting },
|
|
} = useForm<ImageConfigFormValues>({
|
|
defaultValues: {
|
|
UNSPLASH_ACCESS_KEY: config["UNSPLASH_ACCESS_KEY"],
|
|
},
|
|
});
|
|
|
|
const onSubmit = async (formData: ImageConfigFormValues) => {
|
|
const payload: Partial<ImageConfigFormValues> = { ...formData };
|
|
|
|
await updateInstanceConfigurations(payload)
|
|
.then(() =>
|
|
setToast({
|
|
type: TOAST_TYPE.SUCCESS,
|
|
title: "Success",
|
|
message: "Image Configuration Settings updated successfully",
|
|
})
|
|
)
|
|
.catch((err) => console.error(err));
|
|
};
|
|
|
|
return (
|
|
<div className="space-y-8">
|
|
<div className="grid-col grid w-full grid-cols-1 items-center justify-between gap-x-16 gap-y-8 lg:grid-cols-2">
|
|
<ControllerInput
|
|
control={control}
|
|
type="password"
|
|
name="UNSPLASH_ACCESS_KEY"
|
|
label="Access key from your Unsplash account"
|
|
description={
|
|
<>
|
|
You will find your access key in your Unsplash developer console.
|
|
<a
|
|
href="https://unsplash.com/documentation#creating-a-developer-account"
|
|
target="_blank"
|
|
className="text-accent-primary hover:underline"
|
|
rel="noreferrer"
|
|
aria-label="Unsplash developer account documentation"
|
|
>
|
|
Learn more.
|
|
</a>
|
|
</>
|
|
}
|
|
placeholder="oXgq-sdfadsaeweqasdfasdf3234234rassd"
|
|
error={Boolean(errors.UNSPLASH_ACCESS_KEY)}
|
|
required
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<Button
|
|
variant="primary"
|
|
size="md"
|
|
stretch="auto"
|
|
onClick={handleSubmit(onSubmit)}
|
|
loading={isSubmitting}
|
|
label={isSubmitting ? "Saving" : "Save changes"}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|