Skip to content

Commit

Permalink
Merge branch 'yoav/unmut_lifted_objects_take2' of https://github.com/…
Browse files Browse the repository at this point in the history
…winglang/wing into yoav/unmut_lifted_objects_take2
  • Loading branch information
yoav-steinberg committed Apr 23, 2024
2 parents 6ac3663 + cc62ef0 commit 7212529
Show file tree
Hide file tree
Showing 144 changed files with 2,690 additions and 1,024 deletions.
2 changes: 1 addition & 1 deletion apps/wing-console/console/app/demo/main.w
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class ApiUsersService {
"parameters": [
{
"in": "header",
"name": "cookie",
"name": "accept",
},
],
"requestBody": {
Expand Down
1 change: 0 additions & 1 deletion apps/wing-console/console/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@wingconsole/ui": "workspace:^",
"autoprefixer": "^10.4.15",
"bump-pack": "workspace:^",
"conf": "^11.0.2",
"dotenv": "^16.3.1",
"eslint": "^8.48.0",
"nanoid": "^4.0.2",
Expand Down
3 changes: 3 additions & 0 deletions apps/wing-console/console/app/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "https://turborepo.org/schema.json",
"extends": ["//"],
"pipeline": {
"dev": {
"dependsOn": ["^compile"]
},
"compile": {
"outputs": ["dist/**"],
"env": ["SEGMENT_WRITE_KEY", "VITE_WING_CLOUD_SIGN_IN_URL"]
Expand Down
4 changes: 2 additions & 2 deletions apps/wing-console/console/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"@wingconsole/tsconfig": "workspace:^",
"bump-pack": "workspace:^",
"chokidar": "^3.5.3",
"conf": "^11.0.2",
"constructs": "^10.3",
"cors": "^2.8.5",
"emittery": "^1.0.1",
"env-paths": "^3.0.0",
"esbuild-plugin-raw": "^0.1.7",
"eslint": "^8.48.0",
"express": "^4.19.2",
Expand All @@ -58,4 +58,4 @@
"volta": {
"extends": "../../../../package.json"
}
}
}
47 changes: 37 additions & 10 deletions apps/wing-console/console/server/src/utils/terms-and-conditions.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
// @ts-ignore-next-line
import Conf from "conf";
import * as fs from "node:fs";

import envPaths from "env-paths";

// @ts-ignore-next-line
import License from "../../LICENSE.md?raw";

const PROJECT_NAME = "@wingconsole/server";
const CONFIG_KEY = "termsAndConditions";

const paths = envPaths(PROJECT_NAME);

const configFilename = `${paths.config}/config.json`;

const getConfig = () => {
if (!fs.existsSync(configFilename)) {
return;
}

try {
return JSON.stringify(
fs.readFileSync(configFilename, "utf8"),
) as unknown as Record<string, any>;
} catch (error) {
console.error(error);
}
};

const saveConfig = (config: Record<string, any>) => {
try {
fs.mkdirSync(paths.config, { recursive: true });
fs.writeFileSync(configFilename, JSON.stringify(config, undefined, 2));
} catch (error) {
console.error(error);
}
};

export const isTermsAccepted = (): boolean => {
const config = new Conf({
projectName: PROJECT_NAME,
});
const config = getConfig();

const accepted = config.get(CONFIG_KEY) as boolean;
const accepted = config?.[CONFIG_KEY];
return accepted === true;
};

export const acceptTerms = (value: boolean) => {
const config = new Conf({
projectName: PROJECT_NAME,
});
const config = getConfig();

config.set(CONFIG_KEY, value);
saveConfig({
...config,
[CONFIG_KEY]: value,
});
};

export const getLicense = (): string => {
Expand Down
16 changes: 13 additions & 3 deletions apps/wing-console/console/ui/src/features/api-interaction-view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { OpenApiSpec } from "@wingconsole/server/src/wingsdk";
import { createPersistentState } from "@wingconsole/use-persistent-state";
import { memo, useCallback, useContext, useState } from "react";

import { AppContext } from "../AppContext.js";
Expand All @@ -13,11 +14,19 @@ export interface ApiViewProps {

export const ApiInteractionView = memo(({ resourcePath }: ApiViewProps) => {
const { appMode } = useContext(AppContext);
const { usePersistentState } = createPersistentState(resourcePath);

const [apiResponse, setApiResponse] = useState<ApiResponse>();
const [apiResponse, setApiResponse] = usePersistentState<
ApiResponse | undefined
>();
const onFetchDataUpdate = useCallback(
(data: ApiResponse) => setApiResponse(data),
[],
(data: ApiResponse) => {
if (!data) {
return;
}
setApiResponse(data);
},
[setApiResponse],
);

const schema = trpc["api.schema"].useQuery({ resourcePath });
Expand All @@ -35,6 +44,7 @@ export const ApiInteractionView = memo(({ resourcePath }: ApiViewProps) => {
callFetch={callFetch}
isLoading={isLoading}
apiResponse={apiResponse}
resetApiResponse={() => setApiResponse(undefined)}
/>
);
});
Loading

0 comments on commit 7212529

Please sign in to comment.