Skip to content

The open alternative to Salesforce, designed for AI.

Add known sources dropdown to api docs (#5204)

brendanlaschkeadf64f0a4cc2
diff --git a/packages/twenty-docs/src/components/token-form.css b/packages/twenty-docs/src/components/token-form.css
index 2530a5c9c94..48016ae3e07 100644
--- a/packages/twenty-docs/src/components/token-form.css
+++ b/packages/twenty-docs/src/components/token-form.css
@@ -7,6 +7,7 @@
padding: 0px 8px;
background: var(--ifm-color-secondary-contrast-background);
z-index: 2;
+ display: flex;
}
.form {
@@ -15,6 +16,7 @@
gap: 10px;
width: 50%;
margin-left: auto;
+ flex: 0.7;
}
.link {
@@ -42,6 +44,10 @@
height: 32px;
}
+.input[disabled] {
+ color: rgb(153, 153, 153)
+}
+
[data-theme='dark'] .input {
background-color: #16233f;
}
diff --git a/packages/twenty-docs/src/components/token-form.tsx b/packages/twenty-docs/src/components/token-form.tsx
index 3c59ba0969f..4acf4e8236d 100644
--- a/packages/twenty-docs/src/components/token-form.tsx
+++ b/packages/twenty-docs/src/components/token-form.tsx
@@ -28,6 +28,10 @@ const TokenForm = ({
const history = useHistory();
const location = useLocation();
const [isLoading, setIsLoading] = useState(false);
+ const [locationSetting, setLocationSetting] = useState(
+ parseJson(localStorage.getItem('baseUrl'))?.locationSetting ??
+ 'production',
+ );
const [baseUrl, setBaseUrl] = useState(
parseJson(localStorage.getItem('baseUrl'))?.baseUrl ??
'https://api.twenty.com',
@@ -49,13 +53,24 @@ const TokenForm = ({
await submitToken(event.target.value);
};
- const updateBaseUrl = (baseUrl: string) => {
- const url = baseUrl?.endsWith('/')
+ const updateBaseUrl = (baseUrl: string, locationSetting: string) => {
+ let url: string;
+ if (locationSetting === 'production') {
+ url = 'https://api.twenty.com';
+ } else if (locationSetting === 'demo') {
+ url = 'https://api-demo.twenty.com';
+ } else if (locationSetting === 'localhost') {
+ url = 'http://localhost:3000';
+ } else {
+ url = baseUrl?.endsWith('/')
? baseUrl.substring(0, baseUrl.length - 1)
- : baseUrl;
+ : baseUrl
+ }
+
setBaseUrl(url);
+ setLocationSetting(locationSetting);
submitBaseUrl?.(url);
- localStorage.setItem('baseUrl', JSON.stringify({ baseUrl: url }));
+ localStorage.setItem('baseUrl', JSON.stringify({ baseUrl: url, locationSetting }));
};
const validateToken = (openApiJson) => {
@@ -93,7 +108,7 @@ const TokenForm = ({
useEffect(() => {
(async () => {
- updateBaseUrl(baseUrl);
+ updateBaseUrl(baseUrl, locationSetting);
await submitToken(token);
})();
}, []);
@@ -114,19 +129,19 @@ const TokenForm = ({
<TbChevronLeft size={18} />
<span>Back</span>
</div>
-
<div className="inputWrapper">
- <div className="inputIcon" title="Api Key">
- <TbApi size={20} />
- </div>
- <input
- className={!isTokenValid && !isLoading ? 'input invalid' : 'input'}
- type="text"
- readOnly={isLoading}
- placeholder="API Key"
- defaultValue={token}
- onChange={updateToken}
- />
+ <select
+ className="select"
+ onChange={(event) => {
+ updateBaseUrl(baseUrl, event.target.value)
+ }}
+ value={locationSetting}
+ >
+ <option value="production">Production API</option>
+ <option value="demo">Demo API</option>
+ <option value="localhost">Localhost</option>
+ <option value="other">Other</option>
+ </select>
</div>
<div className="inputWrapper">
<div className="inputIcon" title="Base URL">
@@ -136,12 +151,26 @@ const TokenForm = ({
className={'input'}
type="text"
readOnly={isLoading}
+ disabled={locationSetting !== 'other'}
placeholder="Base URL"
- defaultValue={baseUrl}
- onChange={(event) => updateBaseUrl(event.target.value)}
+ value={baseUrl}
+ onChange={(event) => updateBaseUrl(event.target.value, locationSetting)}
onBlur={() => submitToken(token)}
/>
</div>
+ <div className="inputWrapper">
+ <div className="inputIcon" title="Api Key">
+ <TbApi size={20} />
+ </div>
+ <input
+ className={!isTokenValid && !isLoading ? 'input invalid' : 'input'}
+ type="text"
+ readOnly={isLoading}
+ placeholder="API Key"
+ defaultValue={token}
+ onChange={updateToken}
+ />
+ </div>
<div className="inputWrapper" style={{ maxWidth: '100px' }}>
<select
className="select"