Skip to content

Commit

Permalink
Merge branch 'master' into latex
Browse files Browse the repository at this point in the history
  • Loading branch information
deepansh96 committed May 11, 2024
2 parents 98733f6 + 997d40c commit bbd2060
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 64 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy_to_ecs_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
VUE_APP_MIXPANEL_PROJECT_TOKEN: ${{ secrets.VUE_APP_MIXPANEL_PROJECT_TOKEN }}
VUE_APP_SENTRY_DSN: ${{ secrets.VUE_APP_SENTRY_DSN }}
VUE_APP_GOOGLE_API_KEY: ${{ secrets.VUE_APP_GOOGLE_API_KEY }}
NODE_OPTIONS: --openssl-legacy-provider
run: |
# Build a docker container and push it to ECR
docker build \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# base stage
FROM node:lts-alpine as base-stage
# FROM node:lts-alpine as base-stage
FROM node:16-alpine as base-stage
WORKDIR /app
COPY package.json ./
# install dependencies for npm run test:unit
Expand Down
86 changes: 72 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,17 @@
<!-- first-time language picker -->
<div
class="fixed w-full top-1/4 my-5 flex justify-center"
v-if="showLanguagePickerDialog"
v-if="(
// if user is not SSO user, everything works as defined in this file
// if user is SSO user, we take up the setting provided by the org,
// and if the setting is not to show language picker, it won't be shown
(
checkIfIsSSOUser &&
isFirstTimeLanguagePickerShownBySetting !== null &&
isFirstTimeLanguagePickerShownBySetting == true
) ||
(!checkIfIsSSOUser && showLanguagePickerDialog)
)"
>
<div
class="bg-white w-11/12 sm:w-9/12 lg:w-7/12 p-4 sm:p-10 rounded-lg border border-black"
Expand Down Expand Up @@ -266,6 +276,7 @@ import UserAPIService from "@/services/API/User.js";
import OrganizationAPIService from "@/services/API/Organization.js";
import { mapActions, mapState, mapGetters } from "vuex";
import { useToast } from "vue-toastification";
import globalDefaultSettings from "@/services/Config/GlobalDefaultSettings.js";
let clonedeep = require("lodash.clonedeep");
Expand Down Expand Up @@ -477,6 +488,7 @@ export default {
"setWindowInnerHeight",
"showSpinner",
"hideSpinner",
"unsetFirstTimeLanguagePickerShownBySetting"
]),
...mapActions("sync", ["stopLoading"]),
...mapActions("dialog", [
Expand Down Expand Up @@ -511,18 +523,50 @@ export default {
let setting = updatedSettings[key];
if (setting.isWorkspaceSetting) {
if (newWorkspaceSettings == null)
newWorkspaceSettings = clonedeep(this.activeWorkspaceSettings);
newWorkspaceSettings
.get(setting.headerName)
.children.get(setting.tabName)
.children.get(setting.leafName).value = setting.newValue;
if (newWorkspaceSettings == null) newWorkspaceSettings = clonedeep(this.activeWorkspaceSettings);
if (newWorkspaceSettings.has(setting.headerName) == false) {
newWorkspaceSettings.set(setting.headerName, clonedeep(globalDefaultSettings.get(setting.headerName)));
}
const header = newWorkspaceSettings.get(setting.headerName);
if (header.children.has(setting.tabName) == false) {
header.children.set(
setting.tabName,
clonedeep(globalDefaultSettings.get(setting.headerName).children.get(setting.tabName))
);
}
const tab = header.children.get(setting.tabName);
if (tab.children.has(setting.leafName) == false) {
tab.children.set(
setting.leafName,
clonedeep(globalDefaultSettings.get(setting.headerName).children.get(setting.tabName).children.get(setting.leafName))
);
}
tab.children.get(setting.leafName).value = setting.newValue;
} else {
if (newUserSettings == null) newUserSettings = clonedeep(this.userSettings);
newUserSettings
.get(setting.headerName)
.children.get(setting.tabName)
.children.get(setting.leafName).value = setting.newValue;
// newUserSettings
// .get(setting.headerName)
// .children.get(setting.tabName)
// .children.get(setting.leafName).value = setting.newValue;
if (newUserSettings.has(setting.headerName) == false) {
newUserSettings.set(setting.headerName, clonedeep(globalDefaultSettings.get(setting.headerName)));
}
const header = newUserSettings.get(setting.headerName);
if (header.children.has(setting.tabName) == false) {
header.children.set(
setting.tabName,
clonedeep(globalDefaultSettings.get(setting.headerName).children.get(setting.tabName))
);
}
const tab = header.children.get(setting.tabName);
if (tab.children.has(setting.leafName) == false) {
tab.children.set(
setting.leafName,
clonedeep(globalDefaultSettings.get(setting.headerName).children.get(setting.tabName).children.get(setting.leafName))
);
}
tab.children.get(setting.leafName).value = setting.newValue;
}
});
Expand Down Expand Up @@ -772,6 +816,7 @@ export default {
this.$i18n.locale = locale;
UserConfigService.updateLocale();
this.showLanguagePickerDialog = false;
this.unsetFirstTimeLanguagePickerShownBySetting();
},
/**
* triggered when any keyboard button is pressed
Expand Down Expand Up @@ -810,7 +855,7 @@ export default {
"userRoleInActiveWorkspace",
"activeWorkspaceId",
]),
...mapGetters("generic", ["isMobileScreen"]),
...mapGetters("generic", ["isMobileScreen", "isFirstTimeLanguagePickerShownBySetting"]),
...mapState("auth", ["config", "user", "activeWorkspace", "userId", "userSettings"]),
...mapState("generic", [
"isSharePlioDialogShown",
Expand Down Expand Up @@ -1137,19 +1182,32 @@ export default {
onLoginPage() {
return this.$route.name == "Login";
},
checkIfIsSSOUser() {
const output = (
"api_key" in this.$route.query &&
"unique_id" in this.$route.query
)
return output
},
/**
* whether the background should be disabled
*/
isBackgroundDisabled() {
return (
this.showLanguagePickerDialog ||
const output = (
(
this.checkIfIsSSOUser &&
this.isFirstTimeLanguagePickerShownBySetting !== null &&
this.isFirstTimeLanguagePickerShownBySetting == true
) ||
(!this.checkIfIsSSOUser && this.showLanguagePickerDialog) ||
this.isSharePlioDialogShown ||
this.isEmbedPlioDialogShown ||
this.isDialogBoxShown ||
this.isSpinnerShown ||
this.isSettingsMenuShown ||
this.isSingleSelectorShown
);
return output
},
/**
* list of shortcodes of all workspaces that the user is a part of
Expand Down
5 changes: 5 additions & 0 deletions src/assets/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,13 @@ export default {
menu: {
title: {
skipEnabled: "Viewers can skip questions while attempting plios",
firstTimeLanguagePickerPopup:
"Viewers will see the language picker on first login",
},
description: {
skipEnabled: "Provide viewers the option to skip a question",
firstTimeLanguagePickerPopup:
"Your users will see the language picker on their first login. This sets what language they will see the platform in. Currently only two values, English and Hindi, are supported.",
},
info:
"The new settings will only apply to plios created in the future and not the existing plios",
Expand All @@ -591,6 +595,7 @@ export default {
},
tab: {
configuration: "Configuration",
ui: "UI",
},
},
badge: {
Expand Down
6 changes: 6 additions & 0 deletions src/assets/locales/hi.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,14 @@ export default {
title: {
skipEnabled:
"प्लायो का प्रयास करते समय दर्शक प्रश्नों को छोड़ सकते हैं",
// firstTimeLanguagePickerPopup: "Viewers will see the language picker on first login",
firstTimeLanguagePickerPopup:
"दर्शकों को पहली बार लॉगिन करते समय भाषा चुनने का विकल्प प्रदान करें",
},
description: {
skipEnabled: "दर्शकों को प्रश्न छोड़ने का विकल्प प्रदान करें",
firstTimeLanguagePickerPopup:
"आपके दर्शक अपनी पहली लॉगिन पर भाषा चुनने का विकल्प देखेंगे। यह निर्धारित करता है कि वे प्लेटफ़ॉर्म को किस भाषा में देखेंगे। वर्तमान में केवल दो, अंग्रेजी और हिंदी, का समर्थन किया जाता है।",
},
info:
"नई सेटिंग्स केवल भविष्य में बनाए जाने वाले प्लायो पर लागू होंगी, न कि पहले से बनाए गए प्लायो पर",
Expand All @@ -593,6 +598,7 @@ export default {
},
tab: {
configuration: "विन्यास",
ui: "यूआई",
},
},
badge: {
Expand Down
40 changes: 39 additions & 1 deletion src/pages/Embeds/Plio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export default {
// if for some reason the API call didn't go through and there's no response
// object, then redirect the user to a 404 page
console.log("error", error)
if (error.response != undefined && error.response.status === 400) {
this.$router.replace({
name: "Player",
Expand Down Expand Up @@ -348,7 +349,7 @@ export default {
},
},
computed: {
...mapGetters("auth", ["isAuthenticated"]),
...mapGetters("auth", ["isAuthenticated", "locale"]),
...mapState("generic", ["windowInnerWidth", "windowInnerHeight"]),
firstUnansweredItem() {
if (this.isSkipEnabled || this.lastAnsweredItemIndex == this.numItems - 1)
Expand All @@ -362,6 +363,9 @@ export default {
numItems() {
return this.items.length;
},
shouldFirstTimeLanguagePickerBeShown() {
return this.uiSettings.get("firstTimeLanguagePickerPopup").value;
},
isSkipEnabled() {
// if a custom configuration is provided, then use that otherwise
// use the global settings
Expand All @@ -373,8 +377,28 @@ export default {
return globalDefaultSettings.get("player").children.get("configuration").children;
},
configuration() {
if (
this.plioSettings == null ||
!(this.plioSettings instanceof Map) ||
!this.plioSettings.has("player") ||
!this.plioSettings.get("player").children.has("configuration")
) return this.defaultConfiguration
return this.plioSettings.get("player").children.get("configuration").children;
},
defaultUISettings() {
return globalDefaultSettings.get("player").children.get("ui").children;
},
uiSettings() {
if (
this.plioSettings == null ||
!(this.plioSettings instanceof Map) ||
!this.plioSettings.has("player") ||
!this.plioSettings.get("player").children.has("ui")
) return this.defaultUISettings
return this.plioSettings.get("player").children.get("ui").children;
},
/**
* whether player has the correct aspect ratio as desired
*/
Expand Down Expand Up @@ -554,6 +578,12 @@ export default {
},
},
methods: {
...mapActions(
"generic", [
"unsetFirstTimeLanguagePickerShownBySetting",
"setFirstTimeLanguagePickerShownBySetting"
]
),
...mapActions("auth", ["setAccessToken", "setActiveWorkspace"]),
/**
* @param {Number} itemIndex - the index of the item whose response is to be checked
Expand Down Expand Up @@ -847,6 +877,14 @@ export default {
this.videoId = this.getVideoIDfromURL(plioDetails.videoURL);
this.plioTitle = plioDetails.plioTitle;
this.plioSettings = SettingsUtilities.setPlioSettings(plioDetails.config);
// apply the setting of showing the first time language picker or not
if (
!this.shouldFirstTimeLanguagePickerBeShown
) this.unsetFirstTimeLanguagePickerShownBySetting();
else {
if (this.locale == null) this.setFirstTimeLanguagePickerShownBySetting()
}
})
.then(() => this.createSession())
.then(() => this.logData());
Expand Down
16 changes: 16 additions & 0 deletions src/services/Config/GlobalDefaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export let settingsMetadata = {
description: "settings.menu.description.skipEnabled",
type: "checkbox",
},
firstTimeLanguagePickerPopup: {
title: "settings.menu.title.firstTimeLanguagePickerPopup",
description: "settings.menu.description.firstTimeLanguagePickerPopup",
type: "checkbox",
},
};

/**
Expand Down Expand Up @@ -51,6 +56,17 @@ let globalDefaultSetings = new Map(
})
),
},
ui: {
scope: ["org-admin", "super-admin"],
children: new Map(
Object.entries({
firstTimeLanguagePickerPopup: {
scope: ["org-admin", "super-admin"],
value: true,
},
})
),
},
})
),
},
Expand Down
2 changes: 1 addition & 1 deletion src/services/Config/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
userConfig["locale"] || process.env.VUE_APP_I18N_LOCALE;
clearInterval(redirectId);
}
}, 10);
}, 50);
},

updateLocale() {
Expand Down
Loading

0 comments on commit bbd2060

Please sign in to comment.