Skip to content

Commit

Permalink
fix: 73 - add 2.0.0 to the recognized FE versions (#74)
Browse files Browse the repository at this point in the history
* fix: add 2.0.0 to the recognized FE versions

* Modify to include the right schema_version node

* Refactor
  • Loading branch information
ebezzi authored Sep 21, 2021
1 parent 47b206a commit a16acc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
7 changes: 2 additions & 5 deletions client/src/components/infoDrawer/infoFormat.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { H3, H1, UL, HTMLTable, Classes } from "@blueprintjs/core";
import React from "react";
import { checkValidVersion } from "../util/version";

// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const renderContributors = (contributors: any, affiliations: any) => {
Expand Down Expand Up @@ -184,11 +185,7 @@ const renderLinks = (projectLinks: any, aboutURL: any) => {
const InfoFormat = React.memo(
// @ts-expect-error ts-migrate(2339) FIXME: Property 'datasetTitle' does not exist on type '{ ... Remove this comment to see the full error message
({ datasetTitle, singleValueCategories, aboutURL, dataPortalProps = {} }) => {
if (
["1.0.0", "1.1.0"].indexOf(
dataPortalProps.version?.corpora_schema_version
) === -1
) {
if (checkValidVersion(dataPortalProps)) {
dataPortalProps = {};
}
const {
Expand Down
7 changes: 3 additions & 4 deletions client/src/components/leftSidebar/topLeftLogoAndTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import Logo from "../framework/logo";
import Truncate from "../util/truncate";
import InfoDrawer from "../infoDrawer/infoDrawer";
import InformationMenu from "./infoMenu";
import { checkValidVersion } from "../util/version";

const DATASET_TITLE_FONT_SIZE = 14;

// @ts-expect-error ts-migrate(1238) FIXME: Unable to resolve signature of class decorator whe... Remove this comment to see the full error message
@connect((state) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
const { corpora_props: corporaProps } = (state as any).config;
const correctVersion =
["1.0.0", "1.1.0"].indexOf(corporaProps?.version?.corpora_schema_version) >
-1;
const isValidVersion = checkValidVersion(corporaProps);
return {
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
datasetTitle: (state as any).config?.displayNames?.dataset ?? "",
Expand All @@ -28,7 +27,7 @@ const DATASET_TITLE_FONT_SIZE = 14;
tosURL: (state as any).config?.parameters?.about_legal_tos,
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
privacyURL: (state as any).config?.parameters?.about_legal_privacy,
title: correctVersion ? corporaProps?.title : undefined,
title: isValidVersion ? corporaProps?.title : undefined,
};
})
class LeftSideBar extends React.Component {
Expand Down
16 changes: 16 additions & 0 deletions client/src/components/util/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const VERSION_ONES = ["1.0.0", "1.1.0"];
const VERSION_TWOS = ["2.0.0"];

export function checkValidVersion(corporaProps: any) {
if (!corporaProps) return false;

// eslint-disable-next-line @typescript-eslint/naming-convention -- prop from BE
const { version, schema_version } = corporaProps;

const isValidVersionOne = VERSION_ONES.includes(
version?.corpora_schema_version
);
const isValidVersionTwo = VERSION_TWOS.includes(schema_version);

return isValidVersionOne || isValidVersionTwo;
}

0 comments on commit a16acc9

Please sign in to comment.