Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
srietkerk committed Mar 4, 2025
1 parent fc7c5f7 commit b38fd62
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
5 changes: 5 additions & 0 deletions pxtlib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,11 @@ namespace ts.pxtc.Util {
const isSupported = supportedExps?.includes(cleanedExpId) ?? false;
return isSupported;
}

export function ocvEnabled() {
return pxt.webConfig.ocv?.appId && pxt.webConfig.ocv?.iframeEndpoint;
}

}

namespace ts.pxtc.BrowserImpl {
Expand Down
52 changes: 23 additions & 29 deletions react-common/components/controls/Feedback/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import { Modal } from "../Modal";
// this would not happen if the EventListener did not have a callback to close the modal
interface IFeedbackProps {
kind: ocv.FeedbackKind;
frameId: string;
onClose?: () => void;
}

// right now, there are two kinds of feedback that I think could be valuable for our targets
// generic and rating feedback, but we will likely want to expand this
// keeping separate props for the iframe and modal for now because we might want to expand either
// without dependencies on the other
interface IFeedbackModalProps {
kind: ocv.FeedbackKind;
onClose: () => void;
Expand All @@ -22,38 +21,27 @@ interface IFeedbackModalProps {
// Wrapper component of the feedback modal so kind can determine what feedback actually shows in the modal
export const FeedbackModal = (props: IFeedbackModalProps) => {
const { kind, onClose } = props;
const title = kind === "generic" ? lf("Leave Feedback") : lf("Rate this activity");
const title = kind === "rating" ? lf("Rate this activity") : lf("Leave Feedback for Microsoft");

return (
<Modal className="feedback-modal" title={title} onClose={onClose}>
<>
{ kind === "generic" &&
<Feedback
kind={kind}
frameId="menu-feedback-frame"
onClose={onClose}
/>
}
{ kind === "rating" &&
<Feedback
kind={kind}
frameId="activity-feedback-frame"
onClose={onClose}
/>
}
</>
<Feedback
kind={kind}
onClose={onClose}
/>
</Modal>
)
}

export const Feedback = (props: IFeedbackProps) => {
const { kind, frameId } = props;
const { kind, onClose } = props;

const feedbackConfig = kind === "generic" ? baseConfig : ratingFeedbackConfig;
const feedbackConfig = kind === "rating" ? ratingFeedbackConfig : baseConfig ;
const frameId = kind === "rating" ? "activity-feedback-frame" : "menu-feedback-frame";

const onDismiss = () => {
if (props.onClose) {
props.onClose();
if (onClose) {
onClose();
}
}

Expand All @@ -65,11 +53,17 @@ export const Feedback = (props: IFeedbackProps) => {
removeFeedbackEventListener();
}
}, [])

return (
<iframe
title="feedback"
id={frameId}
src={`${pxt.webConfig.ocv?.iframeEndpoint}/centrohost?appname=ocvfeedback&feature=host-ocv-inapp-feedback&platform=web&appId=${pxt.webConfig.ocv?.appId}#/hostedpage`}
sandbox="allow-scripts allow-same-origin allow-forms allow-popups" />
<>
{ pxt.U.ocvEnabled() &&
<iframe
title="feedback"
id={frameId}
src={`${pxt.webConfig.ocv?.iframeEndpoint}/centrohost?appname=ocvfeedback&feature=host-ocv-inapp-feedback&platform=web&appId=${pxt.webConfig.ocv?.appId}#/hostedpage`}
sandbox="allow-scripts allow-same-origin allow-forms allow-popups" />
}
</>

)
}
2 changes: 1 addition & 1 deletion webapp/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5334,7 +5334,7 @@ export class ProjectView
const hideMenuBar = targetTheme.hideMenuBar || hideTutorialIteration || (isTabTutorial && pxt.appTarget.appTheme.embeddedTutorial) || pxt.shell.isTimeMachineEmbed();
const isHeadless = simOpts && simOpts.headless;
const selectLanguage = targetTheme.selectLanguage;
const feedbackEnabled = pxt.webConfig.ocv?.appId && pxt.webConfig.ocv?.iframeEndpoint;
const feedbackEnabled = pxt.U.ocvEnabled();
const showEditorToolbar = inEditor && !hideEditorToolbar && this.editor.hasEditorToolbar();
const useSerialEditor = pxt.appTarget.serial && !!pxt.appTarget.serial.useEditor;
const showSideDoc = sideDocs && this.state.sideDocsLoadUrl && !this.state.sideDocsCollapsed;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class SettingsMenu extends data.Component<SettingsMenuProps, SettingsMenu
const showPairDevice = pxt.usb.isEnabled;

const showCenterDivider = targetTheme.selectLanguage || targetTheme.highContrast || showGreenScreen || githubUser;
const showFeedbackOption = pxt.webConfig.ocv?.appId && pxt.webConfig.ocv?.iframeEndpoint;
const showFeedbackOption = pxt.U.ocvEnabled();

const simCollapseText = headless ? lf("Toggle the File Explorer") : lf("Toggle the simulator");

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class ProjectSettingsMenu extends data.Component<ProjectSettingsMenuProps
const githubUser = !hasIdentity && this.getData("github:user") as UserInfo;
const reportAbuse = pxt.appTarget.cloud && pxt.appTarget.cloud.sharing && pxt.appTarget.cloud.importing;
const showDivider = targetTheme.selectLanguage || targetTheme.highContrast || githubUser;
const showFeedbackOption = pxt.webConfig.ocv?.appId && pxt.webConfig.ocv?.iframeEndpoint;
const showFeedbackOption = pxt.U.ocvEnabled();
sendUpdateFeedbackTheme(highContrast);

return <sui.DropdownMenu role="menuitem" icon={'setting large'} title={lf("Settings")} className="item icon more-dropdown-menuitem" ref={ref => this.dropdown = ref}>
Expand Down

0 comments on commit b38fd62

Please sign in to comment.