Skip to content

Commit

Permalink
modal onboarding clarity (#2780)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodanswer authored Oct 21, 2024
1 parent cee6810 commit 45d852a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export function CustomLLMProviderUpdateForm({
existingLlmProvider,
shouldMarkAsDefault,
setPopup,
hideSuccess,
}: {
onClose: () => void;
existingLlmProvider?: FullLLMProvider;
shouldMarkAsDefault?: boolean;
setPopup?: (popup: PopupSpec) => void;
hideSuccess?: boolean;
}) {
const { mutate } = useSWRConfig();

Expand Down Expand Up @@ -108,9 +110,6 @@ export function CustomLLMProviderUpdateForm({
return;
}

// don't set groups if marked as public
const groups = values.is_public ? [] : values.groups;

// test the configuration
if (!isEqual(values, initialValues)) {
setIsTesting(true);
Expand Down Expand Up @@ -190,7 +189,7 @@ export function CustomLLMProviderUpdateForm({
const successMsg = existingLlmProvider
? "Provider updated successfully!"
: "Provider enabled successfully!";
if (setPopup) {
if (!hideSuccess && setPopup) {
setPopup({
type: "success",
message: successMsg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ export function LLMProviderUpdateForm({
shouldMarkAsDefault,
setPopup,
hideAdvanced,
hideSuccess,
}: {
llmProviderDescriptor: WellKnownLLMProviderDescriptor;
onClose: () => void;
existingLlmProvider?: FullLLMProvider;
shouldMarkAsDefault?: boolean;
hideAdvanced?: boolean;
setPopup?: (popup: PopupSpec) => void;
hideSuccess?: boolean;
}) {
const { mutate } = useSWRConfig();

Expand Down Expand Up @@ -202,7 +204,7 @@ export function LLMProviderUpdateForm({
const successMsg = existingLlmProvider
? "Provider updated successfully!"
: "Provider enabled successfully!";
if (setPopup) {
if (!hideSuccess && setPopup) {
setPopup({
type: "success",
message: successMsg,
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/initialSetup/search/NoSourcesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SettingsContext } from "@/components/settings/SettingsProvider";
export function NoSourcesModal() {
const settings = useContext(SettingsContext);
const [isHidden, setIsHidden] = useState(
!settings?.settings.search_page_enabled ?? false
!settings?.settings.search_page_enabled
);

if (isHidden) {
Expand All @@ -19,7 +19,7 @@ export function NoSourcesModal() {

return (
<Modal
className="max-w-4xl"
width="max-w-3xl w-full"
title="🧐 No sources connected"
onOutsideClick={() => setIsHidden(true)}
>
Expand Down
13 changes: 3 additions & 10 deletions web/src/components/initialSetup/welcome/WelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function _CompletedWelcomeFlowDummyComponent() {
export function _WelcomeModal({ user }: { user: User | null }) {
const router = useRouter();

const [canBegin, setCanBegin] = useState(false);
const [providerOptions, setProviderOptions] = useState<
WellKnownLLMProviderDescriptor[]
>([]);
Expand Down Expand Up @@ -75,19 +74,13 @@ export function _WelcomeModal({ user }: { user: User | null }) {

<div className="max-h-[900px] overflow-y-scroll">
<ApiKeyForm
// Don't show success message on initial setup
hideSuccess
setPopup={setPopup}
onSuccess={() => {
router.refresh();
refreshProviderInfo();
setCanBegin(true);
}}
onSuccess={clientSetWelcomeFlowComplete}
providerOptions={providerOptions}
/>
</div>
<Divider />
<Button disabled={!canBegin} onClick={clientSetWelcomeFlowComplete}>
Get Started
</Button>
</div>
</Modal>
</>
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/llm/ApiKeyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export const ApiKeyForm = ({
onSuccess,
providerOptions,
setPopup,
hideSuccess,
}: {
onSuccess: () => void;
providerOptions: WellKnownLLMProviderDescriptor[];
setPopup: (popup: PopupSpec) => void;
hideSuccess?: boolean;
}) => {
const defaultProvider = providerOptions[0]?.name;
const providerNameToIndexMap = new Map<string, number>();
Expand Down Expand Up @@ -56,6 +58,7 @@ export const ApiKeyForm = ({
onClose={() => onSuccess()}
shouldMarkAsDefault
setPopup={setPopup}
hideSuccess={hideSuccess}
/>
</TabPanel>
);
Expand All @@ -65,6 +68,7 @@ export const ApiKeyForm = ({
onClose={() => onSuccess()}
shouldMarkAsDefault
setPopup={setPopup}
hideSuccess={hideSuccess}
/>
</TabPanel>
</TabPanels>
Expand Down
47 changes: 22 additions & 25 deletions web/src/components/llm/ApiKeyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,35 @@ export const ApiKeyModal = ({
if (!shouldShowConfigurationNeeded) {
return null;
}

return (
<Modal
title="Set an API Key!"
width="max-w-3xl w-full"
onOutsideClick={() => hide()}
>
<div className="max-h-[75vh] overflow-y-auto flex flex-col">
<div>
<div className="mb-5 text-sm">
Please provide an API Key below in order to start using
Danswer – you can always change this later.
<br />
If you&apos;d rather look around first, you can
<strong onClick={() => hide()} className="text-link cursor-pointer">
{" "}
skip this step
</strong>
.
</div>

<ApiKeyForm
setPopup={setPopup}
onSuccess={() => {
router.refresh();
refreshProviderInfo();
hide();
}}
providerOptions={providerOptions}
/>
<>
<div className="mb-5 text-sm text-gray-700">
Please provide an API Key below in order to start using Danswer – you
can always change this later.
<br />
If you&apos;d rather look around first, you can
<strong onClick={() => hide()} className="text-link cursor-pointer">
{" "}
skip this step
</strong>
.
</div>
</div>

<ApiKeyForm
setPopup={setPopup}
onSuccess={() => {
router.refresh();
refreshProviderInfo();
hide();
}}
providerOptions={providerOptions}
/>
</>
</Modal>
);
};

0 comments on commit 45d852a

Please sign in to comment.