Skip to content

Commit

Permalink
Merge pull request #9809 from akolson/remove-corebase-from-user-profi…
Browse files Browse the repository at this point in the history
…le-and-auth

Refactors UserAuth and ProfileEdit pages  not to use Corebase
  • Loading branch information
akolson authored Nov 22, 2022
2 parents f02ed81 + 4b5556c commit ecf08f1
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 55 deletions.
2 changes: 0 additions & 2 deletions kolibri/core/assets/src/core-app/apiSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ import UserTable from '../views/UserTable';
import CoachContentLabel from '../views/CoachContentLabel';
import PrivacyInfoModal from '../views/PrivacyInfoModal';
import UserTypeDisplay from '../views/UserTypeDisplay';
import TechnicalTextBlock from '../views/AppError/TechnicalTextBlock';
import Draggable from '../views/sortable/Draggable';
import DragHandle from '../views/sortable/DragHandle';
import DragContainer from '../views/sortable/DragContainer';
Expand Down Expand Up @@ -194,7 +193,6 @@ export default {
UiToolbar,
PrivacyInfoModal,
UserTypeDisplay,
TechnicalTextBlock,
Draggable,
DragHandle,
DragContainer,
Expand Down
4 changes: 2 additions & 2 deletions kolibri/core/assets/src/views/CoreBase/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@
import { currentLanguage, defaultLanguage } from 'kolibri.utils.i18n';
import coreBannerContent from 'kolibri.utils.coreBannerContent';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import AppError from 'kolibri-common/components/AppError';
import GlobalSnackbar from 'kolibri-common/components/GlobalSnackbar';
import navComponentsMixin from '../../mixins/nav-components';
import AppError from '../AppError';
import GlobalSnackbar from '../GlobalSnackbar';
import ImmersiveToolbar from '../ImmersiveToolbar';
import UpdateNotification from '../UpdateNotification';
import LanguageSwitcherModal from '../language-switcher/LanguageSwitcherModal';
Expand Down
4 changes: 2 additions & 2 deletions kolibri/core/assets/src/views/NotificationsRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import { currentLanguage, defaultLanguage } from 'kolibri.utils.i18n';
import AuthMessage from 'kolibri.coreVue.components.AuthMessage';
import AppBarPage from 'kolibri.coreVue.components.AppBarPage';
import GlobalSnackbar from './GlobalSnackbar.vue';
import AppError from 'kolibri-common/components/AppError';
import GlobalSnackbar from 'kolibri-common/components/GlobalSnackbar';
import UpdateNotification from './UpdateNotification.vue';
import AppError from './AppError';
export default {
name: 'NotificationsRoot',
Expand Down
2 changes: 1 addition & 1 deletion kolibri/plugins/device/assets/src/views/DeviceInfoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<script>
import { mapState } from 'vuex';
import TechnicalTextBlock from 'kolibri.coreVue.components.TechnicalTextBlock';
import TechnicalTextBlock from 'kolibri-common/components/AppError/TechnicalTextBlock';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import responsiveWindowMixin from 'kolibri.coreVue.mixins.responsiveWindowMixin';
import AppBarPage from 'kolibri.coreVue.components.AppBarPage';
Expand Down
4 changes: 2 additions & 2 deletions kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import client from 'kolibri.client';
import urls from 'kolibri.urls';
import GlobalSnackbar from '../../../../../../kolibri/core/assets/src/views/GlobalSnackbar';
import AppError from 'kolibri-common/components/AppError';
import GlobalSnackbar from 'kolibri-common/components/GlobalSnackbar';
import SkipNavigationLink from '../../../../../../kolibri/core/assets/src/views/SkipNavigationLink';
import AppError from '../../../../../../kolibri/core/assets/src/views/AppError';
import useCoreLearn from '../composables/useCoreLearn';
import useContentNodeProgress from '../composables/useContentNodeProgress';
import useLearnerResources from '../composables/useLearnerResources';
Expand Down
53 changes: 18 additions & 35 deletions kolibri/plugins/user_auth/assets/src/views/UserAuthIndex.vue
Original file line number Diff line number Diff line change
@@ -1,50 +1,25 @@
<template>

<div>
<CoreBase
:showDemoBanner="demoBannerRoute"
:immersivePage="false"
:immersivePagePrimary="false"
:fullScreen="true"
>
<UserAuthLayout>
<router-view />
</CoreBase>
</UserAuthLayout>
</div>

</template>


<script>
import CoreBase from 'kolibri.coreVue.components.CoreBase';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import { createTranslator } from 'kolibri.utils.i18n';
import { ComponentMap } from '../constants';
const tempTranslator = createTranslator('UserIndex', {
signUpStep1Title: {
message: 'Step 1 of 2',
context: 'Indicates at which stage of the sign up process the user is at.',
},
signUpStep2Title: {
message: 'Step 2 of 2',
context: 'Indicates at which stage of the sign up process the user is at.',
},
});
import UserAuthLayout from './UserAuthLayout';
export default {
name: 'UserAuthIndex',
components: { CoreBase },
components: { UserAuthLayout },
mixins: [commonCoreStrings],
computed: {
demoBannerRoute() {
return [
ComponentMap.SIGN_IN,
ComponentMap.FACILITY_SELECT,
ComponentMap.AUTH_SELECT,
ComponentMap.NEW_PASSWORD,
].includes(this.$route.name);
},
redirect: {
get() {
return this.$store.state.signIn.redirect;
Expand All @@ -66,8 +41,10 @@
},
},
created() {
// Check for redirect param and store it in vuex
// otherwise it'll be lost when the route changes.
/*
* Check for redirect param and store it in vuex
* otherwise it'll be lost when the route changes.
*/
if (this.$route.query.redirect) {
this.redirect = this.$route.query.redirect;
}
Expand All @@ -78,17 +55,23 @@
// remove 'disable' after switching back to `this.$tr`
if (route.name === ComponentMap.SIGN_UP) {
if (route.query.step) {
return tempTranslator.$tr('signUpStep1Title');
return this.$tr('signUpStep1Title');
}
return tempTranslator.$tr('signUpStep2Title');
return this.$tr('signUpStep2Title');
}
/* eslint-enable kolibri/vue-no-undefined-string-uses */
return this.coreString('signInLabel');
},
},
$trs: {
// TODO: move strings from tempTranslator back to this.$tr
signUpStep1Title: {
message: 'Step 1 of 2',
context: 'Indicates at which stage of the sign up process the user is at.',
},
signUpStep2Title: {
message: 'Step 2 of 2',
context: 'Indicates at which stage of the sign up process the user is at.',
},
},
};
Expand Down
187 changes: 187 additions & 0 deletions kolibri/plugins/user_auth/assets/src/views/UserAuthLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<template>

<div
ref="mainWrapper"
class="main-wrapper"
:style="mainWrapperStyles"
>

<div v-if="blockDoubleClicks" class="click-mask"></div>

<div
v-if="!loading"
class="scrolling-pane"
>
<CoreBanner v-if="coreBannerComponent && showDemoBanner">
<template #default="props">
<component
:is="coreBannerComponent"
:bannerClosed="props.bannerClosed"
/>
</template>
</CoreBanner>

<KPageContainer v-if="!isAuthorized">
<AuthMessage />
</KPageContainer>
<KPageContainer v-else-if="error">
<AppError />
</KPageContainer>

<div
v-else
id="main"
role="main"
tabindex="-1"
class="main"
>
<slot></slot>
</div>
</div>

<!-- Monitor snackbar changes so they can be announced by assistive technologies -->
<div aria-live="polite">
<GlobalSnackbar />
</div>

</div>

</template>


<script>
import { mapState } from 'vuex';
import AuthMessage from 'kolibri.coreVue.components.AuthMessage';
import coreBannerContent from 'kolibri.utils.coreBannerContent';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import AppError from 'kolibri-common/components/AppError';
import GlobalSnackbar from 'kolibri-common/components/GlobalSnackbar';
import CoreBanner from '../../../../../core/assets/src/views/CoreBanner';
import { ComponentMap } from '../constants';
export default {
name: 'UserAuthLayout',
metaInfo() {
return {
// Use arrow function to bind $tr to this component
titleTemplate: title => {
if (this.error) {
return this.$tr('kolibriTitleMessage', { title: this.$tr('errorPageTitle') });
}
// If no child component sets title, it reads 'Kolibri'
if (!title) {
return this.coreString('kolibriLabel');
}
// If child component sets title, it reads 'Child Title - Kolibri'
return this.$tr('kolibriTitleMessage', { title });
},
};
},
components: {
AppError,
CoreBanner,
AuthMessage,
GlobalSnackbar,
},
mixins: [commonCoreStrings],
computed: {
...mapState({
error: state => state.core.error,
loading: state => state.core.loading,
blockDoubleClicks: state => state.core.blockDoubleClicks,
}),
isAuthorized() {
return !(
this.error &&
this.error.response &&
this.error.response.status &&
this.error.response.status == 403
);
},
mainWrapperStyles() {
return {
width: '100vw',
backgroundColor: this.$themePalette.grey.v_100,
paddingTop: '0px',
paddingBottom: '0px',
};
},
coreBannerComponent() {
return coreBannerContent[0];
},
showDemoBanner() {
return [
ComponentMap.SIGN_IN,
ComponentMap.FACILITY_SELECT,
ComponentMap.AUTH_SELECT,
ComponentMap.NEW_PASSWORD,
].includes(this.$route.name);
},
},
$trs: {
kolibriTitleMessage: {
message: '{ title } - Kolibri',
context: 'DO NOT TRANSLATE\nCopy the source string.',
},
errorPageTitle: {
message: 'Error',
context:
"When Kolibri throws an error, this is the text that's used as the title of the error page. The description of the error follows below.",
},
},
};
</script>


<style lang="scss" scoped>
.main-wrapper {
display: inline-block;
width: 100vw;
@media print {
/* Without this, things won't print correctly
* - Firefox: Tables will get cutoff
* - Chrome: Table header won't repeat correctly on each page
*/
display: block;
}
}
.main {
height: 100%;
margin-right: auto;
margin-left: auto;
}
.scrolling-pane {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 0;
margin-top: 0;
margin-bottom: 0;
overflow-x: auto;
}
.click-mask {
position: fixed;
top: 0;
left: 0;
z-index: 24;
width: 100%;
height: 100%;
}
.debug {
font-family: monospace;
font-size: large;
font-weight: bold;
line-height: 2em;
}
</style>
18 changes: 8 additions & 10 deletions kolibri/plugins/user_profile/assets/src/views/ProfileEditPage.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<template>

<!-- The v-if ensures the page isn't visible briefly before redirection -->
<CoreBase
<ImmersivePage
v-if="!isSubsetOfUsersDevice"
:immersivePage="true"
immersivePageIcon="close"
icon="close"
:appBarTitle="$tr('editProfileHeader')"
:pageTitle="$tr('editProfileHeader')"
:showSubNav="false"
:immersivePageRoute="profileRoute"
:route="profileRoute"
>
<KPageContainer class="narrow-container">
<KPageContainer class="narrow-container" :topMargin="100">
<form class="form" @submit.prevent="handleSubmit">
<h1>{{ $tr('editProfileHeader') }}</h1>

Expand Down Expand Up @@ -62,7 +59,8 @@
</KButtonGroup>
</form>
</KPageContainer>
</CoreBase>

</Immersivepage>

</template>

Expand All @@ -78,10 +76,10 @@
import GenderSelect from 'kolibri.coreVue.components.GenderSelect';
import BirthYearSelect from 'kolibri.coreVue.components.BirthYearSelect';
import FullNameTextbox from 'kolibri.coreVue.components.FullNameTextbox';
import ImmersivePage from 'kolibri.coreVue.components.ImmersivePage';
import UsernameTextbox from 'kolibri.coreVue.components.UsernameTextbox';
import { FacilityUserResource } from 'kolibri.resources';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import CoreBase from 'kolibri.coreVue.components.CoreBase';
import { RoutesMap } from '../constants';
import plugin_data from 'plugin_data';
Expand All @@ -97,7 +95,7 @@
BirthYearSelect,
FullNameTextbox,
UsernameTextbox,
CoreBase,
ImmersivePage,
},
mixins: [commonCoreStrings],
data() {
Expand Down
Loading

0 comments on commit ecf08f1

Please sign in to comment.