Skip to content

Commit 25bea6c

Browse files
authored
Merge pull request #67 from contentstack/staging
Staging
2 parents 2e03e82 + 35d88fd commit 25bea6c

File tree

8 files changed

+10719
-30289
lines changed

8 files changed

+10719
-30289
lines changed

ui/package-lock.json

Lines changed: 10705 additions & 30263 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "marketplace-json-editor-app-ui",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"private": true,
55
"dependencies": {
6-
"@contentstack/app-sdk": "^1.5.0",
6+
"@contentstack/app-sdk": "^2.0.1",
77
"@datadog/browser-rum": "^4.25.0",
88
"@playwright/test": "1.25.0",
99
"@types/react": "^18.2.14",

ui/src/common/utils/function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Extension from "@contentstack/app-sdk/dist/src/extension";
1+
import Extension from "@contentstack/app-sdk/dist/src/uiLocation";
22
import { get, isEmpty, keys } from "lodash";
33

44
function getAppLocation(sdk: Extension): string {

ui/src/components/jsoneditor/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useEffect } from "react";
1+
import React, { useRef } from "react";
22
import { JsonEditor } from "jsoneditor-react";
33
import ace from "brace";
44
import "brace/mode/json";
@@ -13,10 +13,6 @@ const JSONEditor: React.FC<TypeJsonProps> = function ({
1313
}) {
1414
const jsonEditorRef = useRef<JsonEditor | null>(null);
1515

16-
useEffect(() => {
17-
jsonEditorRef?.current?.set(value);
18-
}, [value]);
19-
2016
const setRef = (instance: any) => {
2117
jsonEditorRef.current = instance?.jsonEditor;
2218
};

ui/src/containers/App/index.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
import React from "react";
2-
import { HashRouter, Route, Routes, Navigate } from "react-router-dom";
2+
import { HashRouter, Route, Routes } from "react-router-dom";
33
import ErrorBoundary from "../../components/ErrorBoundary";
44
import ConfigScreen from "../ConfigScreen";
55
import CustomField from "../CustomField";
66
import "./venus.css";
77
import "./styles.scss";
88

9-
/** HomeRedirectHandler - component to nandle redirect based on the window location pathname,
10-
as react Router does not identifies pathname if the app is rendered in an iframe.
11-
*/
12-
const HomeRedirectHandler = function () {
13-
if (window?.location?.pathname !== "/") {
14-
return <Navigate to={{ pathname: window?.location?.pathname }} />;
15-
}
16-
return null;
17-
};
18-
199

2010
/* App - The main app component that should be rendered */
2111
const App: React.FC = function () {
@@ -24,7 +14,6 @@ const App: React.FC = function () {
2414
<ErrorBoundary>
2515
<HashRouter>
2616
<Routes>
27-
<Route path="/" element={<HomeRedirectHandler />} />
2817
<Route path="/config" element={<ConfigScreen />} />
2918
<Route path="/custom-field" element={<CustomField />} />
3019
</Routes>

ui/src/containers/CustomField/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable spaced-comment */
12
import React, { useEffect, useState } from "react";
23
import { get } from "lodash";
34
import ContentstackAppSdk from "@contentstack/app-sdk";
@@ -53,6 +54,7 @@ const CustomField: React.FC = function () {
5354

5455
if (initialData && !isEmpty(initialData)) {
5556
try {
57+
//@ts-ignore
5658
jsonVal = typeof initialData[0] === "string" ? [JSON.parse(initialData[0]?.trim()?.length ? initialData[0] : "{}")] : initialData;
5759
} catch (e) {
5860
jsonVal = [{}];

ui/src/hooks/useAppSdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This hook is to utilize for appSdk pulse method and its an exception for dev tools app.
55
*/
66
import { atom, useAtom } from 'jotai';
7-
import Extension from '@contentstack/app-sdk/dist/src/extension';
7+
import Extension from '@contentstack/app-sdk/dist/src/uiLocation';
88

99
export const appSdkRefAtom = atom<Extension | null>(null);
1010

ui/src/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Import React modules */
22
import React from "react";
3-
import ReactDOM from "react-dom";
3+
import { createRoot } from "react-dom/client";
44
/* Import other node modules */
55
import reportWebVitals from "./reportWebVitals";
66
/* Import our modules */
@@ -9,14 +9,15 @@ import App from "./containers/App";
99
/* Import our CSS */
1010
import "./index.css";
1111

12-
ReactDOM.render(
12+
const container = document.getElementById("root") as HTMLElement;
13+
const root = createRoot(container); // createRoot(container!) if you use TypeScript
14+
root.render(
1315
<React.StrictMode>
1416
<App />
15-
</React.StrictMode>,
16-
document.getElementById("root")
17+
</React.StrictMode>
1718
);
1819

1920
// If you want to start measuring performance in your app, pass a function
2021
// to log results (for example: reportWebVitals(console.log))
2122
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
22-
reportWebVitals();
23+
reportWebVitals();

0 commit comments

Comments
 (0)