Skip to content

Commit

Permalink
N21-1311 Remove old User login migration (#2912)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap authored Nov 14, 2023
1 parent 74e7e6c commit bb8805a
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 1,198 deletions.
260 changes: 14 additions & 246 deletions src/components/administration/AdminMigrationSection.unit.ts

Large diffs are not rendered by default.

73 changes: 27 additions & 46 deletions src/components/administration/AdminMigrationSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
class="my-4 button-end"
color="primary"
depressed
:disabled="!oauthMigration.startedAt"
:disabled="!isMigrationActive"
data-testid="migration-end-button"
@click="onToggleShowEndWarning"
>
Expand All @@ -75,15 +75,15 @@
'components.administration.adminMigrationSection.mandatorySwitch.label'
)
"
:disabled="!oauthMigration.startedAt"
:disabled="!isMigrationActive"
:true-value="true"
:false-value="false"
:value="oauthMigration.mandatorySince"
:value="isMigrationMandatory"
inset
dense
class="ml-1"
data-testid="migration-mandatory-switch"
@change="setMigrationMandatory(!oauthMigration.mandatorySince)"
@change="setMigrationMandatory(!isMigrationMandatory)"
/>
</div>

Expand All @@ -104,15 +104,19 @@
/>

<RenderHTML
v-if="oauthMigration && oauthMigration.finishedAt"
v-if="
userLoginMigration &&
userLoginMigration.closedAt &&
userLoginMigration.finishedAt
"
class="migration-completion-date"
data-testid="migration-finished-timestamp"
:html="
t(latestMigration, {
date: dayjs(oauthMigration.closedAt).format('DD.MM.YYYY'),
time: dayjs(oauthMigration.closedAt).format('HH:mm'),
finishDate: dayjs(oauthMigration.finishedAt).format('DD.MM.YYYY'),
finishTime: dayjs(oauthMigration.finishedAt).format('HH:mm'),
date: dayjs(userLoginMigration.closedAt).format('DD.MM.YYYY'),
time: dayjs(userLoginMigration.closedAt).format('HH:mm'),
finishDate: dayjs(userLoginMigration.finishedAt).format('DD.MM.YYYY'),
finishTime: dayjs(userLoginMigration.finishedAt).format('HH:mm'),
})
"
component="p"
Expand Down Expand Up @@ -161,14 +165,16 @@
</template>

<script lang="ts">
import { MigrationBody } from "@/serverApi/v3";
import { useI18n } from "@/composables/i18n.composable";
import { School } from "@/store/types/schools";
import { UserLoginMigration } from "@/store/user-login-migration";
import {
ENV_CONFIG_MODULE_KEY,
injectStrict,
SCHOOLS_MODULE_KEY,
USER_LOGIN_MIGRATION_MODULE_KEY,
} from "@/utils/inject";
import { RenderHTML } from "@feature-render-html";
import dayjs from "dayjs";
import {
computed,
Expand All @@ -177,13 +183,8 @@ import {
onMounted,
ref,
Ref,
watch,
} from "vue";
import MigrationWarningCard from "./MigrationWarningCard.vue";
import { RenderHTML } from "@feature-render-html";
import { useI18n } from "@/composables/i18n.composable";
import { UserLoginMigration } from "@/store/user-login-migration";
import { UserLoginMigrationFlags } from "@/store/user-login-migration/user-login-migration-flags";
export default defineComponent({
name: "AdminMigrationSection",
Expand All @@ -200,31 +201,24 @@ export default defineComponent({
);
onMounted(async () => {
// TODO remove in https://ticketsystem.dbildungscloud.de/browse/N21-820
await schoolsModule.fetchSchoolOAuthMigration();
await userLoginMigrationModule.fetchLatestUserLoginMigrationForSchool();
});
const userLoginMigration: ComputedRef<UserLoginMigration | undefined> =
computed(() => userLoginMigrationModule.getUserLoginMigration);
const oauthMigration: ComputedRef<UserLoginMigrationFlags> = computed(
() => {
return {
startedAt: !!userLoginMigration.value?.startedAt,
mandatorySince: !!userLoginMigration.value?.mandatorySince,
closedAt: userLoginMigration.value?.closedAt,
finishedAt: userLoginMigration.value?.finishedAt,
};
}
const isMigrationActive: ComputedRef<boolean> = computed(
() =>
!!userLoginMigration.value?.startedAt &&
!userLoginMigration.value.closedAt
);
const isMigrationActive: ComputedRef<boolean> = computed(
() => oauthMigration.value.startedAt && !oauthMigration.value.closedAt
const isMigrationMandatory: ComputedRef<boolean> = computed(
() => !!userLoginMigration.value?.mandatorySince
);
const onStartMigration = () => {
if (oauthMigration.value.startedAt) {
if (userLoginMigration.value) {
userLoginMigrationModule.restartUserLoginMigration();
} else {
userLoginMigrationModule.startUserLoginMigration();
Expand All @@ -239,21 +233,7 @@ export default defineComponent({
userLoginMigrationModule.closeUserLoginMigration();
};
// TODO remove in https://ticketsystem.dbildungscloud.de/browse/N21-820
const setMigration = async (available: boolean, mandatory: boolean) => {
const migrationFlags: MigrationBody = {
oauthMigrationPossible: available,
oauthMigrationMandatory: mandatory,
oauthMigrationFinished: !available,
};
await schoolsModule.setSchoolOauthMigration(migrationFlags);
await schoolsModule.fetchSchool();
};
const school: ComputedRef<School> = computed(() => schoolsModule.getSchool);
watch(school, async () => {
await schoolsModule.fetchSchoolOAuthMigration();
});
const isEndWarningVisible: Ref<boolean> = ref(false);
Expand Down Expand Up @@ -290,9 +270,9 @@ export default defineComponent({
return (
Date.now() >= new Date(userLoginMigration.value.finishedAt).getTime()
);
} else {
return false;
}
return false;
});
const latestMigration: ComputedRef<string> = computed(() => {
Expand Down Expand Up @@ -339,7 +319,7 @@ export default defineComponent({
};
return {
oauthMigration,
userLoginMigration,
onStartMigration,
setMigrationMandatory,
onCloseMigration,
Expand All @@ -361,6 +341,7 @@ export default defineComponent({
globalFeatureEnableLdapSyncDuringMigration,
officialSchoolNumber,
isMigrationActive,
isMigrationMandatory,
};
},
});
Expand Down
Loading

0 comments on commit bb8805a

Please sign in to comment.