Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-4938 - Add school specific Terms of Use (Nutzungsordnung) for new school admin page #2799

Merged
merged 24 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports = {
"!<rootDir>/src/pages/NewsCreate.page.vue",
"!<rootDir>/src/pages/NewsEdit.page.vue",
"!<rootDir>/src/pages/ProxyError.page.vue",
"!<rootDir>/src/pages/TermsOfUse.vue",
],

// maxWorkers: 2, // limited for not taking all workers within of a single github action
Expand Down
8 changes: 6 additions & 2 deletions src/components/administration/AdminMigrationSection.unit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import AdminMigrationSection from "@/components/administration/AdminMigrationSection.vue";
import EnvConfigModule from "@/store/env-config";
import SchoolsModule from "@/store/schools";
import { ENV_CONFIG_MODULE_KEY, I18N_KEY } from "@/utils/inject";
import {
ENV_CONFIG_MODULE_KEY,
I18N_KEY,
SCHOOLS_MODULE_KEY,
} from "@/utils/inject";
import { createModuleMocks } from "@/utils/mock-store-module";
import createComponentMocks from "@@/tests/test-utils/componentMocks";
import { Wrapper, mount, shallowMount } from "@vue/test-utils";
Expand Down Expand Up @@ -39,7 +43,7 @@ describe("AdminMigrationSection", () => {
}),
provide: {
[I18N_KEY.valueOf()]: i18nMock,
schoolsModule,
[SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule,
[ENV_CONFIG_MODULE_KEY.valueOf()]: envConfigModule,
},
});
Expand Down
22 changes: 8 additions & 14 deletions src/components/administration/AdminMigrationSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,25 @@

<script lang="ts">
import { MigrationBody } from "@/serverApi/v3";
import SchoolsModule from "@/store/schools";
import { OauthMigration, School } from "@/store/types/schools";
import { ENV_CONFIG_MODULE_KEY, I18N_KEY, injectStrict } from "@/utils/inject";
import {
ENV_CONFIG_MODULE_KEY,
injectStrict,
SCHOOLS_MODULE_KEY,
} from "@/utils/inject";
import dayjs from "dayjs";
import {
computed,
ComputedRef,
defineComponent,
inject,
onMounted,
ref,
Ref,
watch,
} from "vue";
import VueI18n from "vue-i18n";
import MigrationWarningCard from "./MigrationWarningCard.vue";
import { RenderHTML } from "@feature-render-html";
import { useI18n } from "@/composables/i18n.composable";

export default defineComponent({
name: "AdminMigrationSection",
Expand All @@ -194,22 +196,14 @@ export default defineComponent({
RenderHTML,
},
setup() {
const i18n = injectStrict(I18N_KEY);
const { t } = useI18n();
const envConfigModule = injectStrict(ENV_CONFIG_MODULE_KEY);
const schoolsModule: SchoolsModule | undefined =
inject<SchoolsModule>("schoolsModule");
if (!schoolsModule || !i18n) {
throw new Error("Injection of dependencies failed");
}
const schoolsModule = injectStrict(SCHOOLS_MODULE_KEY);

onMounted(async () => {
await schoolsModule.fetchSchoolOAuthMigration();
});

// TODO: https://ticketsystem.dbildungscloud.de/browse/BC-443
const t = (key: string, values?: VueI18n.Values): string =>
i18n.tc(key, 0, values);

const oauthMigration: ComputedRef<OauthMigration> = computed(
() => schoolsModule.getOauthMigration
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/icons/material/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import {
mdiTune,
mdiUndo,
mdiViewGridOutline,
mdiTrayArrowDown,
mdiFileReplaceOutline,
} from "@mdi/js";

const materialIcons = {
Expand Down Expand Up @@ -126,6 +128,8 @@ const materialIcons = {
mdiTune,
mdiUndo,
mdiViewGridOutline,
mdiTrayArrowDown,
mdiFileReplaceOutline,
};

export default materialIcons;
17 changes: 1 addition & 16 deletions src/components/legacy/TheFooter.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { envConfigModule, filePathsModule } from "@/store";
import { envConfigModule } from "@/store";
import EnvConfigModule from "@/store/env-config";
import FilePathsModule from "@/store/filePaths";
import setupStores from "@@/tests/test-utils/setupStores";
Expand All @@ -16,21 +16,6 @@ describe("@/components/legacy/TheFooter.vue", () => {
name: "test",
};

it("Terms of use link is set correctly", () => {
filePathsModule.setSpecificFiles("https://dummy-url.org/");
const wrapper = shallowMount(TheFooter, {
...createComponentMocks({
mocks: {
$theme,
},
i18n: true,
}),
});
expect(wrapper.vm.links[1].href).toStrictEqual(
"https://dummy-url.org/Willkommensordner/Datenschutz/Nutzungsordnung_Schueler-innen.pdf"
);
});

it.skip("Link to accessibility statement is set correctly", () => {
// accessibility statement is now part of the theme-specific TheFooter.vue implementation
});
Expand Down
12 changes: 6 additions & 6 deletions src/components/legacy/TheFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<template v-for="(link, index) in links">
<span v-if="index !== 0" :key="index"> - </span>
<template v-if="!link.innerlinks">
<base-link :key="link.text" class="footer-link" v-bind="link">
{{ link.text }}
</base-link>
<base-link :key="link.text" class="footer-link" v-bind="link">{{
link.text
}}</base-link>
</template>
<template v-else>
<span :key="link.text">{{ link.text }}: </span>
Expand Down Expand Up @@ -41,7 +41,7 @@
</template>

<script>
import { authModule, envConfigModule, filePathsModule } from "@/store";
import { authModule, envConfigModule } from "@/store";

export default {
computed: {
Expand All @@ -58,13 +58,13 @@ export default {
text: this.$t("components.legacy.footer.imprint"),
},
{
href: filePathsModule.getSpecificFiles.termsOfUseSchool,
href: "/termsofuse",
text: this.$t("components.legacy.footer.terms"),
target: "_blank",
rel: "noopener",
},
{
to: "/datenschutz",
to: "/privacypolicy",
text: this.$t("components.legacy.footer.privacy_policy"),
target: "_blank",
rel: "noopener",
Expand Down

This file was deleted.

16 changes: 11 additions & 5 deletions src/components/organisms/administration/SchoolPolicy.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import { shallowMount, Wrapper } from "@vue/test-utils";
import createComponentMocks from "@@/tests/test-utils/componentMocks";
import { mockSchool } from "@@/tests/test-utils/mockObjects";
import { ConsentVersion } from "@/store/types/consent-version";
import { I18N_KEY } from "@/utils/inject";
import {
AUTH_MODULE_KEY,
I18N_KEY,
PRIVACY_POLICY_MODULE_KEY,
SCHOOLS_MODULE_KEY,
} from "@/utils/inject";
import Vue from "vue";
import { i18nMock } from "@@/tests/test-utils";

describe("SchoolPolicy", () => {
let authModule: jest.Mocked<AuthModule>;
Expand Down Expand Up @@ -67,10 +73,10 @@ describe("SchoolPolicy", () => {
i18n: true,
}),
provide: {
[I18N_KEY as symbol]: { t: (key: string) => key },
authModule,
schoolsModule,
privacyPolicyModule,
[I18N_KEY.valueOf()]: i18nMock,
[PRIVACY_POLICY_MODULE_KEY.valueOf()]: privacyPolicyModule,
[AUTH_MODULE_KEY.valueOf()]: authModule,
[SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule,
},
});

Expand Down
61 changes: 16 additions & 45 deletions src/components/organisms/administration/SchoolPolicy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/>
<v-list-item v-else two-line dense class="mb-6" data-testid="policy-item">
<v-list-item-icon>
<v-icon>{{ pdfIcon }}</v-icon>
<v-icon>$file_pdf_outline</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title class="text-body-1 black--text mb-2">
Expand All @@ -34,7 +34,7 @@
{{
t("pages.administration.school.index.schoolPolicy.uploadedOn", {
date: dayjs(privacyPolicy.publishedAt).format(
"DD.MM.YYYY HH:mm"
t("format.dateTime")
),
})
}}
Expand All @@ -60,9 +60,7 @@
t('pages.administration.school.index.schoolPolicy.edit')
"
>
<v-icon>
{{ mdiPencilOutline }}
</v-icon>
<v-icon>$mdiPencilOutline</v-icon>
</v-btn>
</v-list-item-action>
<v-list-item-action
Expand All @@ -77,9 +75,7 @@
t('pages.administration.school.index.schoolPolicy.download')
"
>
<v-icon>
{{ mdiTrayArrowDown }}
</v-icon>
<v-icon>$mdiTrayArrowDown</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
Expand All @@ -96,49 +92,28 @@
<script lang="ts">
import SchoolPolicyFormDialog from "@/components/organisms/administration/SchoolPolicyFormDialog.vue";
import dayjs from "dayjs";
import { mdiPencilOutline, mdiTrayArrowDown } from "@mdi/js";
import {
computed,
ComputedRef,
defineComponent,
inject,
ref,
Ref,
watch,
} from "vue";
import AuthModule from "@/store/auth";
import SchoolsModule from "@/store/schools";
import PrivacyPolicyModule from "@/store/privacy-policy";
import { I18N_KEY, injectStrict } from "@/utils/inject";
import VueI18n from "vue-i18n";
import { computed, ComputedRef, defineComponent, ref, Ref, watch } from "vue";
import { School } from "@/store/types/schools";
import { ConsentVersion } from "@/store/types/consent-version";
import { BusinessError } from "@/store/types/commons";
import { useI18n } from "@/composables/i18n.composable";
import {
AUTH_MODULE_KEY,
PRIVACY_POLICY_MODULE_KEY,
injectStrict,
SCHOOLS_MODULE_KEY,
} from "@/utils/inject";

export default defineComponent({
name: "SchoolPolicy",
components: {
SchoolPolicyFormDialog,
},
setup() {
const authModule: AuthModule | undefined = inject<AuthModule>("authModule");
const schoolsModule: SchoolsModule | undefined =
inject<SchoolsModule>("schoolsModule");
const privacyPolicyModule: PrivacyPolicyModule | undefined =
inject<PrivacyPolicyModule>("privacyPolicyModule");
const i18n = injectStrict(I18N_KEY);

if (!authModule || !schoolsModule || !privacyPolicyModule || !i18n) {
throw new Error("Injection of dependencies failed");
}

const t = (key: string, values?: VueI18n.Values | undefined): string => {
const translateResult = i18n.t(key, values);
if (typeof translateResult === "string") {
return translateResult;
}
return "unknown translation-key:" + key;
};
const { t } = useI18n();
const authModule = injectStrict(AUTH_MODULE_KEY);
const privacyPolicyModule = injectStrict(PRIVACY_POLICY_MODULE_KEY);
const schoolsModule = injectStrict(SCHOOLS_MODULE_KEY);

const isSchoolPolicyFormDialogOpen: Ref<boolean> = ref(false);

Expand All @@ -163,7 +138,6 @@ export default defineComponent({
const error: ComputedRef<BusinessError> = computed(
() => privacyPolicyModule.getBusinessError
);
const pdfIcon = "$file_pdf_outline";

const downloadFile = () => {
const link = document.createElement("a");
Expand All @@ -185,9 +159,6 @@ export default defineComponent({
privacyPolicy,
status,
error,
mdiPencilOutline,
mdiTrayArrowDown,
pdfIcon,
downloadFile,
dayjs,
closeDialog,
Expand Down
Loading