Skip to content

Commit 5cb31eb

Browse files
DOP-6265 remove realm references (#1560)
1 parent b857580 commit 5cb31eb

File tree

16 files changed

+24
-1011
lines changed

16 files changed

+24
-1011
lines changed

src/components/ComponentFactoryLazy.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import { isOfflineDocsBuild } from '../utils/is-offline-docs-build';
33
import { SuspenseHelper } from './SuspenseHelper';
44
import OfflineNotAvailable from './OfflineNotAvailable';
55

6-
type LazyComponentType = 'openapi' | 'video' | 'instruqt' | 'quiz' | 'quizchoice';
6+
type LazyComponentType = 'openapi' | 'video' | 'instruqt';
77
type LazyComponentMap = Record<LazyComponentType, React.LazyExoticComponent<any>>;
88

99
const ComponentMap: LazyComponentMap = {
1010
openapi: lazy(() => import('./OpenAPI')),
1111
video: lazy(() => import('./Video')),
1212
instruqt: lazy(() => import('./Instruqt')),
13-
quiz: lazy(() => import('./Widgets/QuizWidget/QuizWidget')),
14-
quizchoice: lazy(() => import('./Widgets/QuizWidget/QuizChoice')),
1513
};
1614

1715
const isOfflineNotAvailableKey = (key: LazyComponentType): key is 'video' | 'instruqt' => {

src/components/OpenAPI/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,24 @@ const MenuTitleContainer = ({ pageTitle }) => {
137137

138138
const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, page, ...rest }) => {
139139
const usesRST = options?.['uses-rst'];
140-
const usesRealm = options?.['uses-realm'];
140+
const usesNextAPI = options?.['uses-realm'];
141141
const { database } = useSiteMetadata();
142-
const [realmSpec, setRealmSpec] = useState(null);
142+
const [nextAPISpec, setNextAPISpec] = useState(null);
143143
const topValues = useStickyTopValues();
144144
const [isLoading, setIsLoading] = useState(true);
145145
const [hasValidSpecUrl, setHasValidSpecUrl] = useState(true);
146146
const [src, setSrc] = useState(null);
147147
let specUrl, spec;
148148

149-
// Attempt to fetch a spec from Realm
149+
// Attempt to fetch a spec from Next API route
150150
useEffect(() => {
151-
if (usesRealm) {
151+
if (usesNextAPI) {
152152
const apiName = getPlaintext(argument);
153153
fetchOASFile(apiName, database)
154-
.then((response) => setRealmSpec(response))
154+
.then((response) => setNextAPISpec(response))
155155
.catch((e) => console.error(e));
156156
}
157-
}, [argument, database, usesRealm]);
157+
}, [argument, database, usesNextAPI]);
158158

159159
useEffect(() => {
160160
if (isBrowser) {
@@ -175,7 +175,7 @@ const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, pag
175175
);
176176
}
177177

178-
spec = usesRealm ? realmSpec : JSON.parse(children[0]?.value || '{}');
178+
spec = usesNextAPI ? nextAPISpec : JSON.parse(children[0]?.value || '{}');
179179
spec = !src ? spec : null;
180180

181181
// Create our loading widget

src/components/Widgets/FeedbackWidget/context.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ export type FeedbackPayload = {
3838
docs_property: string;
3939
};
4040
user: FeedbackUser;
41-
attachment: {
42-
dataUri?: string;
43-
viewport?: Viewport;
41+
attachment?: {
42+
type: 'screenshot';
43+
dataUri: string;
44+
viewport: Viewport;
4445
};
4546
viewport: Viewport;
4647
category: FeedbackSentiment;
@@ -130,7 +131,6 @@ export function FeedbackProvider({ page, test, ...props }: FeedbackContextProps)
130131
docs_property: page.docs_property,
131132
},
132133
user: { id: user?.id || '' },
133-
attachment: {},
134134
viewport: getViewport(),
135135
comment,
136136
category: createSentiment(rating),
@@ -144,11 +144,12 @@ export function FeedbackProvider({ page, test, ...props }: FeedbackContextProps)
144144
if (email) {
145145
res.user.email = email;
146146
}
147-
if (dataUri) {
148-
res.attachment.dataUri = dataUri;
149-
}
150-
if (viewport) {
151-
res.attachment.viewport = viewport;
147+
if (dataUri && viewport) {
148+
res.attachment = {
149+
type: 'screenshot',
150+
dataUri,
151+
viewport,
152+
};
152153
}
153154
if (feedbackId) {
154155
res.feedback_id = feedbackId;
@@ -220,7 +221,7 @@ export function FeedbackProvider({ page, test, ...props }: FeedbackContextProps)
220221
try {
221222
await upsertFeedback(newFeedback);
222223
} catch (err) {
223-
// This catch block will most likely only be hit after Realm attempts internal retry logic
224+
// This catch block will most likely only be hit after Next API route attempts internal retry logic
224225
// after access token is refreshed
225226
console.error('There was an error submitting feedback', err);
226227
if (err instanceof Error && 'statusCode' in err && err.statusCode === 401) {

src/components/Widgets/QuizWidget/QuizChoice.js

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/components/Widgets/QuizWidget/QuizWidget.js

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)