Skip to content

Commit

Permalink
🐛 Fikset oppdateringer av prop-docs på Aksel.nav.no
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Aug 3, 2023
1 parent 09ba52e commit 5b42ff0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions @navikt/core/react/src/dropdown/Menu/GroupedList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import cl from "clsx";
import React, { forwardRef } from "react";
import { OverridableComponent } from "../../../util/OverridableComponent";
import GroupedHeading, { GroupedHeadingProps } from "./Heading";
import GroupedItem, { GroupedItemProps } from "./Item";
import GroupedHeading, { GroupedHeadingProps } from "./GroupedHeading";
import GroupedItem, { GroupedItemProps } from "./GroupedItem";

export interface GroupedListProps
extends React.HTMLAttributes<HTMLDListElement> {
Expand Down
24 changes: 18 additions & 6 deletions aksel.nav.no/website/scripts/update-props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ const propList = (
name: string
) =>
src.map((prop) => {
let dupe = false;
if (ids.includes(`${prop?.displayName?.toLowerCase()}_${name}_ds_props`)) {
console.error(
`Found duplicate id: ${`${prop.displayName.toLowerCase()}_${name}_ds_props`}`
);
dupe = true;
}
ids.push(`${prop.displayName.toLowerCase()}_${name}_ds_props`);
const id = `${prop.displayName.toLowerCase()}_${name}_ds_props`;
ids.push(id);

return {
_id: `${prop.displayName.toLowerCase()}_${name}_ds_props`,
_id: dupe ? `${id}_2` : id,
_type: "ds_props",
title: prop.displayName,
displayname: prop.displayName,
Expand All @@ -60,13 +63,22 @@ const updateProps = async () => {
// this is our transactional client, it won't push anything until we say .commit() later
const transactionClient = noCdnClient(token).transaction();

propList(CoreDocs as any, "core").forEach((x) =>
transactionClient.createOrReplace(x)
);
const props = propList(CoreDocs as any, "core");

// Preserve existing props that are not in the new list to allow documenting deprecated props
/* const remoteProps = await noCdnClient(token).fetch(`*[_type == "ds_props"]`);
for (const prop of remoteProps) {
if (!props.find((x) => prop._id === x._id)) {
transactionClient.delete(prop._id);
}
} */

props.forEach((x) => transactionClient.createOrReplace(x));

await transactionClient
.commit()
.then(() => console.log(`Updated props`))
.then((e) => console.log(e))
.catch((e) => console.error(e.message));
};

Expand Down

0 comments on commit 5b42ff0

Please sign in to comment.