Skip to content

Commit a3736c4

Browse files
committed
get persona dropdown to not error, but still nonfunctional
1 parent 8b64baa commit a3736c4

File tree

4 files changed

+60
-8
lines changed

4 files changed

+60
-8
lines changed

example-apps/internal-knowledge-search/app-ui/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
# secrets
26+
.env

example-apps/internal-knowledge-search/app-ui/src/components/SearchApplicationSettings.tsx

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1-
import React from 'react';
1+
import React, {useState} from 'react';
22
import {useDispatch, useSelector} from "react-redux";
33
import {updateSettings} from "../store/slices/searchApplicationSettingsSlice";
44
import {useToast} from "../contexts/ToastContext";
55
import {MessageType} from "./Toast";
66
import {RootState} from "../store/store";
7+
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
8+
import {faAngleDown, faAngleUp} from "@fortawesome/free-solid-svg-icons";
9+
710

811
const SearchApplicationSettings: React.FC = () => {
912
const dispatch = useDispatch();
10-
const {appName, apiKey, searchEndpoint} = useSelector((state: RootState) => state.searchApplicationSettings);
13+
const {appName, apiKey, searchEndpoint, searchPersona} = useSelector((state: RootState) => state.searchApplicationSettings);
1114
const {showToast} = useToast();
15+
const searchPersonaOptions = [
16+
"admin",
17+
"user"
18+
]
19+
const [isOpen, setIsOpen] = useState(false);
20+
21+
const toggleDropdown = () => {
22+
setIsOpen(!isOpen);
23+
};
24+
25+
const handlePersonaChange = (value: string) => {
26+
updateSearchPersona(value);
27+
};
1228

1329
const handleSave = () => {
14-
dispatch(updateSettings({appName, apiKey, searchEndpoint}));
30+
dispatch(updateSettings({appName, apiKey, searchEndpoint, searchPersona}));
1531
showToast("Settings saved!", MessageType.Info);
1632
};
1733

18-
const updateAppName = (e) => dispatch(updateSettings({appName: e.target.value, apiKey, searchEndpoint}))
19-
const updateApiKey = (e) => dispatch(updateSettings({appName, apiKey: e.target.value, searchEndpoint}))
20-
const updateSearchEndpoint = (e) => dispatch(updateSettings({appName, apiKey, searchEndpoint: e.target.value}))
34+
const updateAppName = (e) => dispatch(updateSettings({appName: e.target.value, apiKey, searchEndpoint, searchPersona}))
35+
const updateApiKey = (e) => dispatch(updateSettings({appName, apiKey: e.target.value, searchEndpoint, searchPersona}))
36+
const updateSearchEndpoint = (e) => dispatch(updateSettings({appName, apiKey, searchEndpoint: e.target.value, searchPersona}))
37+
38+
const updateSearchPersona = (e) => dispatch(updateSettings({appName, apiKey, searchEndpoint, searchPersona: e}))
2139

2240
return (
2341
<div className="container mx-auto p-4 bg-white rounded shadow-md">
@@ -54,9 +72,9 @@ const SearchApplicationSettings: React.FC = () => {
5472
htmlFor="apiKey"
5573
className="block text-sm font-medium mb-1 text-gray-700"
5674
>
57-
API Key:
75+
Application API Key:
5876
</label>
59-
<p className="text-xs mb-2 text-gray-500">Your unique API key used for authentication.</p>
77+
<p className="text-xs mb-2 text-gray-500">Your application's unique API key used for looking up identities.</p>
6078
<input
6179
id="apiKey"
6280
type="password"
@@ -83,6 +101,29 @@ const SearchApplicationSettings: React.FC = () => {
83101
/>
84102
</div>
85103

104+
<div className="text-left mb-6 p-4 border rounded bg-gray-50">
105+
<label
106+
htmlFor="searchPersona"
107+
className="block text-sm font-medium mb-1 text-gray-700"
108+
>
109+
Search Persona:
110+
</label>
111+
<p className="text-xs mb-2 text-gray-500">The persona on whose behalf searches will be executed</p>
112+
<div className="relative">
113+
<select
114+
onChange={(event) => handlePersonaChange(event.target.value)}
115+
className="flex items-center space-x-2 p-2 bg-white rounded border border-gray-300 focus:outline-none focus:border-blue-500"
116+
>
117+
{searchPersonaOptions.map((option, index) => (
118+
<option value={option} className="block text-left p-2 hover:bg-gray-100 cursor-pointer">
119+
{option}
120+
</option>
121+
))}
122+
</select>
123+
</div>
124+
</div>
125+
126+
86127
<button
87128
onClick={handleSave}
88129
className="mt-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import {FilterModel} from "./FilterModel";
2+
13
export interface SearchApplicationSettingsModel {
24
appName: string;
35
apiKey: string;
46
searchEndpoint: string;
7+
8+
searchPersona: string;
59
}

example-apps/internal-knowledge-search/app-ui/src/store/slices/searchApplicationSettingsSlice.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import {createSlice, PayloadAction} from '@reduxjs/toolkit';
22
import {SearchApplicationSettingsModel} from "../../models/SearchApplicationSettingsModel";
3+
4+
5+
36
const initialState: SearchApplicationSettingsModel = {
47
appName: process.env.REACT_APP_SEARCH_APP_NAME || "some-search-application",
58
apiKey: process.env.REACT_APP_SEARCH_APP_API_KEY || "xxxxxxxxxxxxxxxxxxx",
69
searchEndpoint: process.env.REACT_APP_SEARCH_APP_ENDPOINT || "https://some-search-end-point.co",
10+
searchPersona: "admin"
711
};
812

913
const searchApplicationSettingsSlice = createSlice({

0 commit comments

Comments
 (0)