Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Dec 5, 2024
1 parent c84f147 commit 84aeb2a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
6 changes: 2 additions & 4 deletions app/server/src/static-site-builder/wodinBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ if (fs.existsSync(appsPathFull)) {
}
fs.mkdirSync(appsPathFull);

Check warning on line 31 in app/server/src/static-site-builder/wodinBuilder.ts

View check run for this annotation

Codecov / codecov/patch

app/server/src/static-site-builder/wodinBuilder.ts#L31

Added line #L31 was not covered by tests

const sessionId = null;
const shareNotFound = null;
const baseUrl = wodinConfig.baseUrl.replace(/\/$/, "");

Check warning on line 33 in app/server/src/static-site-builder/wodinBuilder.ts

View check run for this annotation

Codecov / codecov/patch

app/server/src/static-site-builder/wodinBuilder.ts#L33

Added line #L33 was not covered by tests

const appNames = fs.readdirSync(path.resolve(configPath, wodinConfig.appsPath)).map(fileName => {
Expand Down Expand Up @@ -83,8 +81,8 @@ appNames.forEach(async appName => {
appTitle: config.title,
courseTitle: wodinConfig.courseTitle,
wodinVersion,
loadSessionId: sessionId || "",
shareNotFound: shareNotFound || "",
loadSessionId: "",
shareNotFound: "",
mathjaxSrc: "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js",
enableI18n: wodinConfig.enableI18n ?? false, // if option not set then false by default
defaultLanguage: wodinConfig?.defaultLanguage || "en",

Check warning on line 88 in app/server/src/static-site-builder/wodinBuilder.ts

View check run for this annotation

Codecov / codecov/patch

app/server/src/static-site-builder/wodinBuilder.ts#L87-L88

Added lines #L87 - L88 were not covered by tests
Expand Down
6 changes: 2 additions & 4 deletions app/static/src/components/code/CodeEditor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<button
v-if="defaultCodeExists && !STATIC_BUILD"
v-if="defaultCodeExists && !readOnly"
class="btn btn-primary btn-sm mb-2"
id="reset-btn"
v-help="'resetCode'"
Expand All @@ -24,7 +24,6 @@ import Timeout = NodeJS.Timeout;
import { AppConfig, OdinModelResponse } from "../../types/responseTypes";
import { CodeAction } from "../../store/code/actions";
import { CodeMutation } from "../../store/code/mutations";
import { STATIC_BUILD } from "@/parseEnv";
interface DecorationOptions {
range: {
Expand Down Expand Up @@ -190,8 +189,7 @@ export default defineComponent({
editor,
readOnly,
resetCode,
defaultCodeExists,
STATIC_BUILD
defaultCodeExists
};
}
});
Expand Down
7 changes: 4 additions & 3 deletions app/static/src/components/code/CodeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div v-if="appIsConfigured" class="code-tab">
<generic-help title="Write odin code" :markdown="codeHelp"></generic-help>
<code-editor />
<div v-if="!STATIC_BUILD">
<div v-if="!readOnly">
<button class="btn btn-primary mt-2" id="compile-btn" :disabled="!codeIsValid" @click="compile">Compile</button>
<div class="mt-2" id="code-status" :class="codeValidating ? 'code-validating-text' : ''">
<vue-feather
Expand Down Expand Up @@ -33,7 +33,7 @@ import userMessages from "../../userMessages";
import ErrorInfo from "../ErrorInfo.vue";
import GenericHelp from "../help/GenericHelp.vue";
import GraphConfigsCollapsible from "../graphConfig/GraphConfigsCollapsible.vue";
import { STATIC_BUILD } from "@/parseEnv";
import { AppConfig } from "@/types/responseTypes";
export default defineComponent({
name: "CodeTab",
Expand All @@ -47,6 +47,7 @@ export default defineComponent({
},
setup() {
const store = useStore();
const readOnly = computed(() => (store.state.config as AppConfig).readOnlyCode);
const codeIsValid = computed(() => store.state.model.odinModelResponse?.valid);
const codeValidating = computed(() => store.state.code.loading);
const error = computed(() => store.state.model.odinModelCodeError);
Expand All @@ -70,7 +71,7 @@ export default defineComponent({
codeHelp,
codeValidating,
loadingMessage,
STATIC_BUILD
readOnly
};
}
});
Expand Down
6 changes: 5 additions & 1 deletion app/static/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import type StochasticApp from "./components/stochastic/StochasticApp.vue";
type UnionAppComponent = typeof BasicApp | typeof FitApp | typeof StochasticApp
type IntersectionAppComponent = typeof BasicApp & typeof FitApp & typeof StochasticApp

// this type just extracts the intersection of props that all of the app components accept
// by getting the type of the first argument in setup function (which are props)
type IntersectedTabProp = Parameters<NonNullable<IntersectionAppComponent["setup"]>>["0"];

export function initialiseRouter(
appComponent: UnionAppComponent,
appName: string,
Expand All @@ -34,7 +38,7 @@ export function initialiseRouter(
component: appComponent,
props: {
initSelectedTab: STATIC_BUILD ? "Options" : undefined
} as Parameters<NonNullable<IntersectionAppComponent["setup"]>>["0"]
} as IntersectedTabProp
};

const sessionsRoute: RouteRecordRaw = {
Expand Down
5 changes: 3 additions & 2 deletions app/static/src/store/appState/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SessionsAction } from "../sessions/actions";
import { localStorageManager } from "../../localStorageManager";
import { AppStateGetter } from "./getters";
import { InitialiseAppPayload, InitialiseSessionPayload } from "../../types/payloadTypes";
import { STATIC_BUILD } from "@/parseEnv";

export enum AppStateAction {
InitialiseApp = "InitialiseApp",
Expand Down Expand Up @@ -97,7 +98,7 @@ export const appStateActions: ActionTree<AppState, AppState> = {
};

// Do not queue uploads while fitting is true, or while running sensitivity - we'll upload when finished
if (!isBusy()) {
if (!isBusy() && !STATIC_BUILD) {
// remove any existing queued upload, as this request should supersede it
commit(AppStateMutation.ClearQueuedStateUpload);

Expand All @@ -110,7 +111,7 @@ export const appStateActions: ActionTree<AppState, AppState> = {
immediateUploadState(context);
}
},
state.config?.stateUploadIntervalMillis
state.config?.stateUploadIntervalMillis || 2000
);

// record the newly queued upload
Expand Down
4 changes: 4 additions & 0 deletions app/static/src/store/appState/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppConfig } from "../../types/responseTypes";
import { InitialiseAppPayload } from "../../types/payloadTypes";
import registerTranslations from "../../../translationPackage/registerTranslations";
import { collectedTranslations } from "../translations/collectedTranslations";
import { STATIC_BUILD } from "@/parseEnv";

export enum AppStateMutation {
SetApp = "SetApp",
Expand Down Expand Up @@ -38,6 +39,9 @@ export const appStateMutations: MutationTree<AppState> = {
},

[AppStateMutation.SetConfig](state: AppState, payload: AppConfig) {
if (STATIC_BUILD) {
payload.readOnlyCode = true;

Check warning on line 43 in app/static/src/store/appState/mutations.ts

View check run for this annotation

Codecov / codecov/patch

app/static/src/store/appState/mutations.ts#L43

Added line #L43 was not covered by tests
}
state.config = payload;
},

Expand Down

0 comments on commit 84aeb2a

Please sign in to comment.