Skip to content

Commit

Permalink
Remove locally hosted demo data
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Apr 9, 2024
1 parent 58dcefb commit 58138d9
Show file tree
Hide file tree
Showing 5 changed files with 1,926 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
ResponseType,
IntrospectionResult,
} from './types';
import { getAuthenticationHeaders, getDefaultUrl, parseBaseUrl } from './shared';
import { getAuthenticationHeaders, parseBaseUrl } from './shared';
import BindableEditor, {
RenderControlParams,
} from '../../toolpad/AppEditor/PageEditor/BindableEditor';
Expand Down Expand Up @@ -278,17 +278,15 @@ function QueryEditor({
connectionParams: rawConnectionParams,
value: input,
settingsTab,
runtimeConfig,
}: QueryEditorProps<RestConnectionParams, FetchQuery>) {
const appStateApi = useAppStateApi();
const { currentView } = useAppState();
const isBrowserSide = input.attributes.query.browser;

const connectionParams = isBrowserSide ? null : rawConnectionParams;
const baseUrl = isBrowserSide ? null : connectionParams?.baseUrl ?? null;
// input.attributes.query.url will be reset when it's empty
const urlValue: BindableAttrValue<string> =
input.attributes.query.url ?? getDefaultUrl(runtimeConfig, connectionParams);

const urlValue: BindableAttrValue<string> = input.attributes.query.url ?? '';

const introspection = usePrivateQuery<FetchPrivateQuery, IntrospectionResult>(
{
Expand Down Expand Up @@ -714,6 +712,7 @@ function QueryEditor({
function getInitialQueryValue(): FetchQuery {
return {
method: 'GET',
url: 'https://raw.githubusercontent.com/mui/mui-toolpad/master/public/movies.json',
headers: [],
browser: false,
};
Expand Down
13 changes: 6 additions & 7 deletions packages/toolpad-studio/src/toolpadDataSources/rest/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ import {
UrlEncodedBody,
} from './types';
import applyTransform from '../applyTransform';
import { HTTP_NO_BODY, getAuthenticationHeaders, getDefaultUrl, parseBaseUrl } from './shared';
import { HTTP_NO_BODY, getAuthenticationHeaders, parseBaseUrl } from './shared';
import type { IToolpadProject } from '../server';

async function loadEnvFile(project: IToolpadProject) {
return project.envManager.getDeclaredValues();
}

function resolveBindable(
function resolveBindable<T>(
jsRuntime: JsRuntime,
bindable: BindableAttrValue<string>,
bindable: BindableAttrValue<T>,
scope: Record<string, unknown>,
): any {
): T {
const { value, error } = evaluateBindable(jsRuntime, bindable, scope);
if (error) {
throw error;
}
return value;
return value as T;
}

function resolveBindableEntries(
Expand Down Expand Up @@ -149,8 +149,7 @@ async function execBase(
parameters: Object.fromEntries(resolvedParams),
};

const runtimeConfig = await project.getRuntimeConfig();
const urlvalue = fetchQuery.url || getDefaultUrl(runtimeConfig, connection);
const urlvalue = fetchQuery.url ?? '';
const resolvedUrl = resolveBindable(jsRuntime, urlvalue, queryScope);
const resolvedSearchParams = resolveBindableEntries(
jsRuntime,
Expand Down
15 changes: 1 addition & 14 deletions packages/toolpad-studio/src/toolpadDataSources/rest/shared.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { BindableAttrValue } from '@toolpad/studio-runtime';
import { ensureSuffix } from '@toolpad/utils/strings';
import { Maybe } from '@toolpad/utils/types';
import { Authentication, RestConnectionParams } from './types';
import type { RuntimeConfig } from '../../types';
import { Authentication } from './types';

export const HTTP_NO_BODY = new Set(['GET', 'HEAD']);

Expand Down Expand Up @@ -35,14 +33,3 @@ export function parseBaseUrl(baseUrl: string): URL {
parsedBase.hash = '';
return parsedBase;
}

export function getDefaultUrl(
config: RuntimeConfig,
connection?: RestConnectionParams | null,
): BindableAttrValue<string> {
const baseUrl = connection?.baseUrl;

return baseUrl
? ''
: new URL('/static/movies.json', config.externalUrl || window.location.href).href;
}
282 changes: 282 additions & 0 deletions public/employees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
[
{
"Name": "Todd Breitenberg",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/793.jpg",
"Designation": "International",
"Profile": "http://spotless-octopus.name",
"ID": "1"
},
{
"Name": "Cheryl Feest",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/668.jpg",
"Designation": "Product",
"Profile": "http://zealous-psychoanalyst.info",
"ID": "2"
},
{
"Name": "Rudy Bradtke",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1049.jpg",
"Designation": "Investor",
"Profile": "http://thankful-revelation.com",
"ID": "3"
},
{
"Name": "Desiree Osinski",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/606.jpg",
"Designation": "Future",
"Profile": "https://valuable-newspaper.org",
"ID": "4"
},
{
"Name": "Dominic Spinka",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/303.jpg",
"Designation": "Dynamic",
"Profile": "http://qualified-cd.biz",
"ID": "5"
},
{
"Name": "Leticia Morar",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1001.jpg",
"Designation": "Internal",
"Profile": "http://obvious-soundness.info",
"ID": "6"
},
{
"Name": "Julian Crist",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/827.jpg",
"Designation": "Forward",
"Profile": "http://forked-flan.org",
"ID": "7"
},
{
"Name": "Deborah Smitham",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/136.jpg",
"Designation": "Regional",
"Profile": "https://mealy-helmet.net",
"ID": "8"
},
{
"Name": "Robin Hintz",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/835.jpg",
"Designation": "Central",
"Profile": "https://humongous-council.org",
"ID": "9"
},
{
"Name": "Della Rowe",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/919.jpg",
"Designation": "Corporate",
"Profile": "http://adored-sofa.name",
"ID": "10"
},
{
"Name": "Brandy Collier",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/808.jpg",
"Designation": "Internal",
"Profile": "http://wonderful-shoulder.com",
"ID": "11"
},
{
"Name": "Roy Gottlieb",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/293.jpg",
"Designation": "Internal",
"Profile": "http://possible-secretion.com",
"ID": "12"
},
{
"Name": "Kristie Mraz",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/119.jpg",
"Designation": "Dynamic",
"Profile": "http://studious-cruise.org",
"ID": "13"
},
{
"Name": "Delia Effertz",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/119.jpg",
"Designation": "Senior",
"Profile": "http://good-natured-twister.net",
"ID": "14"
},
{
"Name": "Bryant Leuschke",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/915.jpg",
"Designation": "Senior",
"Profile": "http://charming-sister-in-law.name",
"ID": "15"
},
{
"Name": "Dwayne Jaskolski",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/60.jpg",
"Designation": "Dynamic",
"Profile": "https://brave-shortage.net",
"ID": "16"
},
{
"Name": "Kayla Deckow",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/687.jpg",
"Designation": "Global",
"Profile": "http://quick-witted-curse.com",
"ID": "17"
},
{
"Name": "Kathy Reichel",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/871.jpg",
"Designation": "Human",
"Profile": "https://familiar-circumference.name",
"ID": "18"
},
{
"Name": "Ms. Violet Rogahn",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1076.jpg",
"Designation": "Legacy",
"Profile": "http://handmade-realization.name",
"ID": "19"
},
{
"Name": "Erin Tillman",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1047.jpg",
"Designation": "Internal",
"Profile": "https://elegant-bacterium.org",
"ID": "20"
},
{
"Name": "Harvey Langworth",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/724.jpg",
"Designation": "Legacy",
"Profile": "https://another-ultimatum.org",
"ID": "21"
},
{
"Name": "Sammy Swift",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/894.jpg",
"Designation": "Forward",
"Profile": "http://vicious-veto.org",
"ID": "22"
},
{
"Name": "Lorena Klocko",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/613.jpg",
"Designation": "Human",
"Profile": "https://overlooked-flume.net",
"ID": "23"
},
{
"Name": "Aaron Little",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1078.jpg",
"Designation": "International",
"Profile": "https://punctual-consequence.biz",
"ID": "24"
},
{
"Name": "Nathaniel Balistreri",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/245.jpg",
"Designation": "Legacy",
"Profile": "http://defiant-entirety.biz",
"ID": "25"
},
{
"Name": "Alex Olson",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/752.jpg",
"Designation": "Principal",
"Profile": "https://massive-restroom.net",
"ID": "26"
},
{
"Name": "Mrs. Ida Lockman",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1084.jpg",
"Designation": "Corporate",
"Profile": "https://sweet-cloakroom.name",
"ID": "27"
},
{
"Name": "Faith Smith",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/29.jpg",
"Designation": "International",
"Profile": "http://illegal-valance.org",
"ID": "28"
},
{
"Name": "Esther Ruecker",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/536.jpg",
"Designation": "Forward",
"Profile": "http://sunny-close.biz",
"ID": "29"
},
{
"Name": "Ms. Ramiro Hessel",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1023.jpg",
"Designation": "District",
"Profile": "http://complicated-waistband.com",
"ID": "30"
},
{
"Name": "Lloyd Kshlerin",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1206.jpg",
"Designation": "Global",
"Profile": "http://right-lamb.info",
"ID": "31"
},
{
"Name": "Mrs. Meghan Beahan",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/436.jpg",
"Designation": "Senior",
"Profile": "http://flashy-poverty.com",
"ID": "32"
},
{
"Name": "Ron Jakubowski",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1027.jpg",
"Designation": "International",
"Profile": "http://nimble-fun.biz",
"ID": "33"
},
{
"Name": "Brenda Morissette",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1151.jpg",
"Designation": "International",
"Profile": "https://unfolded-usage.com",
"ID": "34"
},
{
"Name": "Dana Ledner",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/177.jpg",
"Designation": "District",
"Profile": "http://worn-pod.info",
"ID": "35"
},
{
"Name": "Lorraine Cummerata",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/420.jpg",
"Designation": "Internal",
"Profile": "https://misguided-isolation.net",
"ID": "36"
},
{
"Name": "Dewey Bahringer",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/293.jpg",
"Designation": "Legacy",
"Profile": "https://busy-jellyfish.biz",
"ID": "37"
},
{
"Name": "Lila Dare",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/696.jpg",
"Designation": "Product",
"Profile": "https://dishonest-necklace.name",
"ID": "38"
},
{
"Name": "Marshall Hodkiewicz",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/289.jpg",
"Designation": "Legacy",
"Profile": "http://good-natured-cactus.com",
"ID": "39"
},
{
"Name": "Max Dickens",
"Avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/623.jpg",
"Designation": "Global",
"Profile": "http://real-villa.biz",
"ID": "40"
}
]
Loading

0 comments on commit 58138d9

Please sign in to comment.