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

Release: 2023-09-29 #4869

Merged
merged 5 commits into from
Sep 29, 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
11 changes: 8 additions & 3 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename "$0")"
readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
Expand All @@ -19,13 +19,18 @@ if [ -z "$husky_skip_init" ]; then
. ~/.huskyrc
fi

export readonly husky_skip_init=1
readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

if [ $exitCode = 127 ]; then
echo "husky - command not found in PATH=$PATH"
fi

exit $exitCode
fi
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx pretty-quick --staged --pattern 'src/**/*.js' --pattern 'gatsby-*.js'
npx lint-staged
3 changes: 2 additions & 1 deletion gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ exports.onRenderBody = ({ setPreBodyComponents }) => {
__html: `
const storedDark = window.localStorage.getItem('dark');
const inferredDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (storedDark === 'true' || (storedDark === null && inferredDark)) {
if (storedDark === 'true' || (storedDark !== false && inferredDark)) {
document.documentElement.classList.add('dark');
document.documentElement.dataset['bsTheme'] = 'dark';
}
`,
},
Expand Down
1,718 changes: 1,132 additions & 586 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"update-icons": "node scripts/createIconNames.js && prettier --write src/components/icon/iconNames.js"
},
"dependencies": {
"@enterprisedb/icons": "^1.25.1",
"@enterprisedb/icons": "^1.26.1",
"@mdx-js/mdx": "^1.6.22",
"@mdx-js/react": "^1.6.22",
"algoliasearch": "^4.17.2",
"algoliasearch": "^4.20.0",
"balance-text": "^3.3.1",
"bl": "5.0.0",
"bootstrap": "^4.6.2",
"bootstrap": "^5.3.2",
"gatsby": "^4.25.7",
"gatsby-cli": "^4.25.0",
"gatsby-plugin-algolia": "^0.26.0",
Expand Down Expand Up @@ -69,27 +69,28 @@
"graceful-fs": "^4.2.11",
"hast-util-to-string": "^1.0.4",
"is-absolute-url": "^4.0.1",
"markdown-to-jsx": "^7.2.1",
"markdown-to-jsx": "^7.3.2",
"masonry-layout": "^4.2.2",
"mdast-util-to-string": "^2.0.0",
"prismjs": "^1.29.0",
"react": "^18.2.0",
"react-bootstrap": "^1.6.7",
"react-bootstrap": "^2.8.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-instantsearch-dom": "^6.40.0",
"react-instantsearch": "^7.1.0",
"rehype-parse": "^7.0.1",
"remark-admonitions": "github:josh-heyer/remark-admonitions",
"sass": "^1.63.4",
"sass": "^1.68.0",
"truncate-utf8-bytes": "^1.0.2",
"unist-util-visit-parents": "^3.1.1"
},
"devDependencies": {
"fast-glob": "^3.2.12",
"fast-glob": "^3.3.1",
"hast-util-is-element": "^2.1.3",
"hast-util-to-text": "^3.1.2",
"husky": "^7.0.4",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"react-refresh": "^0.14.0",
"rehype-format": "^3.1.0",
"rehype-remark": "^8.1.1",
Expand All @@ -108,6 +109,9 @@
"loader-utils": ">=1.4.1",
"nth-check": ">=2.0.1"
},
"lint-staged": {
"*.js": "prettier --write"
},
"repository": {
"type": "git",
"url": "https://github.com/EnterpriseDB/docs"
Expand Down
3 changes: 2 additions & 1 deletion product_docs/docs/pgd/3.7/bdr/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ Check also release notes for pglogical 3.7.20 for resolved issues
that affect BDR as well.

!!! Note
This version is required for EDB Postgres Advanced Server versions 12.14.18, 13.10.14, and later.
This version is required for EDB Postgres Advanced Server versions 12.14.18, 13.10.14, and later.
!!!

### Resolved issues

Expand Down
182 changes: 80 additions & 102 deletions src/components/advanced-search/filtering.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React, { useEffect } from "react";
import React from "react";
import { Badge } from "react-bootstrap";
import {
connectMenu,
connectCurrentRefinements,
connectRefinementList,
} from "react-instantsearch-dom";
useClearRefinements,
useCurrentRefinements,
useRefinementList,
useInstantSearch,
} from "react-instantsearch";
import { products } from "../../constants/products";
import { capitalize } from "../../constants/utils";

const typeToContentType = {
doc: { name: "Documentation" },
guide: { name: "Guides" },
};
import useSiteMetadata from "../../hooks/use-sitemetadata";

const labelForItem = (item, translation) => {
return translation[item.label]
Expand All @@ -20,7 +17,7 @@ const labelForItem = (item, translation) => {
};

const versionSort = (a, b) => {
return b.label.localeCompare(a.label, undefined, { numeric: true });
return b.name.localeCompare(a.name, undefined, { numeric: true });
};

const RadioInput = ({
Expand All @@ -46,7 +43,7 @@ const RadioInput = ({
{labelText}
<Badge
variant="secondary"
className="ml-2 align-middle search-filter-badge"
className="ms-2 align-middle search-filter-badge"
>
{showBadge && badgeNumber}
</Badge>
Expand All @@ -58,8 +55,8 @@ const RadioRefinement = ({
attribute,
heading,
items,
queryActive,
refine,
showBadge,
show,
sortFunction,
translation = {},
Expand All @@ -79,18 +76,26 @@ const RadioRefinement = ({
}),
);

const radioRefine = (refinement) => {
// toggle all current refinements, add new one
for (let item of items) {
if (item !== refinement && item.isRefined) refine(item.label);
}
if (refinement) refine(refinement.label);
};

return (
<div className={`mb-4 pl-1 ${!show && "d-none"}`}>
<div className="mb-2 font-weight-bold text-muted text-uppercase small">
<div className={`mb-4 ps-1 ${!show && "d-none"}`}>
<div className="mb-2 fw-bold text-muted text-uppercase small">
{heading || capitalize(attribute)}
</div>
<RadioInput
id={`radio-refinement-${attribute}-all`}
name={radioName}
labelText="All"
badgeNumber={items.reduce((total, item) => total + item.count, 0)}
showBadge={queryActive}
onChange={() => refine("")}
showBadge={showBadge}
onChange={() => radioRefine()}
checked={!refinedItem}
/>
{sortedItems.map((item) => (
Expand All @@ -100,115 +105,88 @@ const RadioRefinement = ({
name={radioName}
labelText={labelForItem(item, translation)}
badgeNumber={item.count}
showBadge={queryActive}
onChange={() => refine(item.label)}
showBadge={showBadge}
onChange={() => radioRefine(item)}
checked={refinedItem === item}
/>
))}
</div>
);
};

/* eslint-disable no-unused-vars */
const ContentTypeRefinement = connectMenu(
/* eslint-enable */
({ items, currentRefinement, refine, queryActive }) => (
const SingleFacetRefinement = ({
attribute,
limit,
show,
hideIfEmpty = false,
sortBy,
}) => {
const { items, refine } = useRefinementList({ attribute, limit, sortBy });
const empty = !items || items.length === 0;
const { algoliaIndex } = useSiteMetadata();

const { uiState } = useInstantSearch();
const query = uiState[algoliaIndex].query;

return (
<RadioRefinement
attribute="type"
attribute={attribute}
items={items}
queryActive={queryActive}
refine={refine}
show={true}
translation={typeToContentType}
showBadge={query && query.length}
show={show && !(hideIfEmpty && empty)}
translation={products}
sortFunction={null}
/>
),
);

const SingleFacetRefinement = connectRefinementList(
({
items,
refine,
queryActive,
show,
attribute,
sortFunction,
hideIfEmpty = false,
}) => {
const empty = !items || items.length === 0;

return (
<RadioRefinement
attribute={attribute}
items={items}
queryActive={queryActive}
refine={refine}
show={show && !(hideIfEmpty && empty)}
translation={products}
sortFunction={sortFunction}
/>
);
},
);
);
};

const ClearRefinements = connectCurrentRefinements(({ items, refine }) => {
const ClearRefinements = () => {
const { canRefine, refine } = useClearRefinements();
const clear = (e) => {
refine(items);
refine();
e.preventDefault();
};

if (items.length > 0) {
if (canRefine) {
return (
<a href="/" onClick={clear}>
Clear Filters
</a>
);
}
return null;
});
};

export const AdvancedSearchFiltering = connectCurrentRefinements(
({ items, queryActive, refine }) => {
const showProductVersionFilters = !items.find((item) => {
return item.attribute === "type" && item.currentRefinement === "guide";
});
export const AdvancedSearchFiltering = () => {
const { items } = useCurrentRefinements();

const productFilterApplied = items.some(
(item) => item.attribute === "product",
);
const versionFilterApplied = items.some(
(item) => item.attribute === "version",
);
const productFilterApplied = items.some(
(item) => item.attribute === "product",
);
const versionFilterApplied = items.some(
(item) => item.attribute === "version",
);

// if we don't have a product filter applied, wipe any version filters
useEffect(() => {
if (versionFilterApplied && !productFilterApplied) {
const versionFilter = items.find(
(item) => item.attribute === "version",
);
if (versionFilter.items[0]) {
refine(versionFilter.items[0].value);
}
}
});
// if we don't have a product filter applied, wipe any version filters
if (versionFilterApplied && !productFilterApplied) {
const versionFilter = items.find((item) => item.attribute === "version");
for (let refinement of versionFilter.refinements) {
versionFilter.refine(refinement);
}
}

return (
<>
<SingleFacetRefinement
attribute="product"
limit={30}
show={showProductVersionFilters}
queryActive={queryActive}
/>
<SingleFacetRefinement
attribute="version"
limit={30}
show={showProductVersionFilters && productFilterApplied}
queryActive={queryActive}
hideIfEmpty={!versionFilterApplied}
sortFunction={versionSort}
/>
<ClearRefinements />
</>
);
},
);
return (
<>
<SingleFacetRefinement attribute="product" limit={30} show={true} />
<SingleFacetRefinement
attribute="version"
limit={30}
show={productFilterApplied}
hideIfEmpty={!versionFilterApplied}
sortBy={versionSort}
/>
<ClearRefinements />
</>
);
};
Loading