Skip to content

Commit

Permalink
Merge branch 'main' into DOP-4952-last-breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs committed Oct 30, 2024
2 parents 832411e + 68ab6bc commit ab7495b
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 64 deletions.
6 changes: 3 additions & 3 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ console.log('PATH PREFIX', pathPrefix);
// Keep our main plugin at top to include file saving before image plugins
const plugins = [
'gatsby-source-snooty-prod',
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`, // Needed for dynamic images
'gatsby-plugin-image',
'gatsby-plugin-sharp',
'gatsby-transformer-sharp', // Needed for dynamic images
{
resolve: 'gatsby-source-filesystem',
options: {
Expand Down
20 changes: 10 additions & 10 deletions plugins/gatsby-source-snooty-prod/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,16 @@ exports.sourceNodes = async ({ actions, createContentDigest, createNodeId, getNo

await createBreadcrumbNodes({ db, createNode, createNodeId, createContentDigest });

const umbrellaProduct = await db.realmInterface.getMetadata(
{
'associated_products.name': siteMetadata.project,
},
{ associated_products: 1 }
);

await createAssociatedProductNodes({ createNode, createNodeId, createContentDigest }, umbrellaProduct);

await createRemoteMetadataNode({ createNode, createNodeId, createContentDigest }, umbrellaProduct);
if (process.env['OFFLINE_DOCS'] !== 'true') {
const umbrellaProduct = await db.realmInterface.getMetadata(
{
'associated_products.name': siteMetadata.project,
},
{ associated_products: 1 }
);
await createAssociatedProductNodes({ createNode, createNodeId, createContentDigest }, umbrellaProduct);
await createRemoteMetadataNode({ createNode, createNodeId, createContentDigest }, umbrellaProduct);
}

if (siteMetadata.project === 'cloud-docs' && hasOpenAPIChangelog)
await createOpenAPIChangelogNode({ createNode, createNodeId, createContentDigest, siteMetadata });
Expand Down
1 change: 0 additions & 1 deletion src/components/Code/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const Code = ({
> div {
border-top-left-radius: ${captionBorderRadius};
border-top-right-radius: ${captionBorderRadius};
display: grid;
border-color: ${palette.gray.light2};
.dark-theme & {
Expand Down
2 changes: 2 additions & 0 deletions src/components/Sidenav/VersionSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { cx, css } from '@leafygreen-ui/emotion';
import Select from '../Select';
import { VersionContext } from '../../context/version-context';
import { theme } from '../../theme/docsTheme';
import { isOfflineDocsBuild } from '../../utils/is-offline-docs-build';

const buildChoice = (branch) => {
return {
Expand Down Expand Up @@ -85,6 +86,7 @@ const VersionSelector = ({ versionedProject = '', tocVersionNames = [] }) => {
popoverZIndex={2}
allowDeselect={false}
choices={options}
disabled={isOfflineDocsBuild}
></Select>
</div>
);
Expand Down
12 changes: 6 additions & 6 deletions src/components/VersionDropdown/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useCallback, useContext } from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { cx, css as LeafyCSS } from '@leafygreen-ui/emotion';
import { palette } from '@leafygreen-ui/palette';
import { Option, OptionGroup, Select } from '@leafygreen-ui/select';
Expand All @@ -9,8 +8,9 @@ import { useSiteMetadata } from '../../hooks/use-site-metadata';
import { theme } from '../../theme/docsTheme';
import { useCurrentUrlSlug, getBranchSlug } from '../../hooks/use-current-url-slug';
import useSnootyMetadata from '../../utils/use-snooty-metadata';
import { isOfflineDocsBuild } from '../../utils/is-offline-docs-build';

const StyledSelect = styled(Select)`
const selectStyling = LeafyCSS`
margin: ${theme.size.small} ${theme.size.medium} ${theme.size.small} ${theme.size.medium};
${'' /* Render version dropdown text in front of the Sidebar text */}
Expand Down Expand Up @@ -152,18 +152,18 @@ const VersionDropdown = ({ eol }) => {
// OR have the OptionGroup not take up space when a label is empty-string. For now,
// ungrouped branches are handled in a separate array.
return (
<StyledSelect
<Select
role="button"
allowDeselect={false}
className={cx(eol ? eolVersionFlipperStyle : '')}
className={cx(selectStyling, eol ? eolVersionFlipperStyle : '')}
aria-labelledby="View a different version of documentation."
defaultValue="master"
onChange={onSelectChange}
placeholder={'Select a version'}
popoverZIndex={3}
value={activeVersions[project]}
usePortal={false}
disabled={eol}
disabled={isOfflineDocsBuild || eol}
>
{activeUngroupedBranches?.map((b) => createOption(b))}
{groups?.map((group) => {
Expand All @@ -183,7 +183,7 @@ const VersionDropdown = ({ eol }) => {
);
})}
{showEol && <Option value="legacy">Legacy Docs</Option>}
</StyledSelect>
</Select>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-remote-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export const useRemoteMetadata = () => {
}
`
);
return data.allRemoteMetadata.nodes[0].remoteMetadata;
return data.allRemoteMetadata.nodes[0]?.remoteMetadata ?? {};
};
7 changes: 7 additions & 0 deletions src/utils/setup/save-asset-files.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const fs = require('fs').promises;
const path = require('path');
const { siteMetadata } = require('../site-metadata');

const GATSBY_IMAGE_EXTENSIONS = ['webp', 'png', 'avif'];

const needsImageOptimization = ['dotcomprd', 'dotcomstg'].includes(siteMetadata.snootyEnv);

const saveFile = async (file, data) => {
// save files both to "public" and "src/images" directories
// the first is for public access, and the second is for image processing
Expand All @@ -11,6 +14,10 @@ const saveFile = async (file, data) => {
});
await fs.writeFile(path.join('public', file), data, 'binary');

// For staging, skip adding images to src/images dir
// This will functionally skip image optimization, as the plugins source from that dir
if (!needsImageOptimization) return;

const pathList = GATSBY_IMAGE_EXTENSIONS.some((ext) => file.endsWith(ext)) ? ['src', 'images'] : ['public'];
await fs.mkdir(path.join(...pathList, path.dirname(file)), {
recursive: true,
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/__snapshots__/Code.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ exports[`renders correctly 1`] = `
.emotion-0>div {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
display: grid;
border-color: #E8EDEB;
}
Expand Down Expand Up @@ -434,7 +433,6 @@ exports[`renders correctly when none is passed in as a language 1`] = `
.emotion-0>div {
border-top-left-radius: 12px;
border-top-right-radius: 12px;
display: grid;
border-color: #E8EDEB;
}
Expand Down
1 change: 0 additions & 1 deletion tests/unit/__snapshots__/CodeIO.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ exports[`CodeIO renders correctly 1`] = `
.emotion-1>div {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
display: grid;
border-color: #E8EDEB;
}
Expand Down
1 change: 0 additions & 1 deletion tests/unit/__snapshots__/Collapsible.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ exports[`collapsible component renders all the content in the options and childr
.emotion-12>div {
border-top-left-radius: 12px;
border-top-right-radius: 12px;
display: grid;
border-color: #E8EDEB;
}
Expand Down
1 change: 0 additions & 1 deletion tests/unit/__snapshots__/LiteralInclude.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ exports[`renders correctly 1`] = `
.emotion-0>div {
border-top-left-radius: 12px;
border-top-right-radius: 12px;
display: grid;
border-color: #E8EDEB;
}
Expand Down
1 change: 0 additions & 1 deletion tests/unit/__snapshots__/ReleaseSpecification.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ exports[`renders correctly 1`] = `
.emotion-0>div {
border-top-left-radius: 12px;
border-top-right-radius: 12px;
display: grid;
border-color: #E8EDEB;
}
Expand Down
Loading

0 comments on commit ab7495b

Please sign in to comment.