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

🐛 Refactor questionnaire template downloading #1574

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions client/config/webpack.common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import { Configuration, WatchIgnorePlugin } from "webpack";
import { Configuration } from "webpack";
// import CaseSensitivePathsWebpackPlugin from "case-sensitive-paths-webpack-plugin";
import CopyPlugin from "copy-webpack-plugin";
import Dotenv from "dotenv-webpack";
Expand Down Expand Up @@ -181,8 +181,8 @@ const config: Configuration = {
to: pathTo("../dist/manifest.json"),
},
{
from: pathTo("../public/template_application_import.csv"),
to: pathTo("../dist/template_application_import.csv"),
from: pathTo("../public/templates"),
to: pathTo("../dist/templates"),
},
],
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const ManageImports: React.FC = () => {
<a
{...props}
download
href="/template_application_import.csv"
href="/templates/template_application_import.csv"
/>
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ import { ExportQuestionnaireDropdownItem } from "./components/export-questionnai
import dayjs from "dayjs";
import { QuestionnaireQuestionsColumn } from "./components/questionnaire-questions-column";
import { QuestionnaireThresholdsColumn } from "./components/questionnaire-thresholds-column";
import saveAs from "file-saver";
import { load } from "js-yaml";
import questionnaireTemplateFile from "./questionnaire-template.yaml";

const AssessmentSettings: React.FC = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -157,14 +154,6 @@ const AssessmentSettings: React.FC = () => {
// TODO: Check RBAC access
const rbacWriteAccess = true; // checkAccess(userScopes, questionnaireWriteScopes);

const downloadTemplate = () => {
const parsedContent = load(questionnaireTemplateFile);
const blob = new Blob([JSON.stringify(parsedContent, null, 2)], {
type: "application/x-yaml",
});
saveAs(blob, "questionnaire-template.yaml");
};

return (
<>
<PageSection variant={PageSectionVariants.light}>
Expand Down Expand Up @@ -211,7 +200,9 @@ const AssessmentSettings: React.FC = () => {
id="download-yaml-template"
aria-label="Download questionnaire"
variant={ButtonVariant.link}
onClick={downloadTemplate}
component="a"
download
href="/templates/questionnaire-template.yaml"
>
{t("dialog.title.download", {
what: t("terms.YAMLTemplate"),
Expand Down
Loading