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

Fix version orders #6057

Merged
merged 37 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2964275
add method to sort versions and begin adding to versionBlock component
JKarlavige Sep 11, 2024
2c6d652
revert changes to cumulative-metrics page
JKarlavige Sep 11, 2024
779b415
sortVersions method working
JKarlavige Sep 11, 2024
bd4419d
update versionBlock version handling
JKarlavige Sep 12, 2024
275bd32
update page-version-check
JKarlavige Sep 12, 2024
8187bd2
create util to handle version check
JKarlavige Sep 12, 2024
232566c
update page-version-check to use util version check
JKarlavige Sep 12, 2024
5a41120
update category-version-check to use version check util
JKarlavige Sep 12, 2024
710cfd8
remove custom variable component and variable file
JKarlavige Sep 12, 2024
3707f86
Merge branch 'current' into fix-version-orders
JKarlavige Sep 12, 2024
433941c
update faq
mirnawong1 Sep 12, 2024
c606808
update faq
mirnawong1 Sep 12, 2024
b5a8c7d
Update website/docs/faqs/Troubleshooting/auth-expired-error.md
mirnawong1 Sep 13, 2024
0e6d786
Update website/docs/faqs/Troubleshooting/auth-expired-error.md
mirnawong1 Sep 13, 2024
7c2f7a1
Update website/docs/faqs/Troubleshooting/auth-expired-error.md
mirnawong1 Sep 13, 2024
9a91cfb
replace w with r
mirnawong1 Sep 13, 2024
37fdc03
Update constraints.md
diegoquintanav Sep 11, 2024
6791be9
Update website/docs/reference/resource-properties/constraints.md
mirnawong1 Sep 12, 2024
9257248
Update website/docs/reference/resource-properties/constraints.md
mirnawong1 Sep 13, 2024
274dac1
Update Advanced CI overview and related pages (#6033)
nghi-ly Sep 13, 2024
a56dc30
Fix card (#6062)
nghi-ly Sep 13, 2024
80c9466
Update configure-auto-exposures.md
mirnawong1 Sep 13, 2024
35322f9
Update auto-exposures.md
mirnawong1 Sep 13, 2024
e836844
Update website/docs/docs/collaborate/auto-exposures.md
mirnawong1 Sep 16, 2024
b7e7940
Update vertica-setup.md
mkottakota1 Aug 12, 2024
c45db61
Update vertica-setup.md for DBT core 1.8.5
mkottakota1 Aug 16, 2024
cd7b4be
Update airflow-and-dbt-cloud to new repo (#6064)
runleonarun Sep 13, 2024
4f4efd3
Update website/docs/docs/core/connect-data-platform/vertica-setup.md
mirnawong1 Sep 16, 2024
2e8b117
Update website/docs/docs/cloud-integrations/configure-auto-exposures.md
mirnawong1 Sep 16, 2024
0a8bc7e
Update configure-auto-exposures.md
mirnawong1 Sep 16, 2024
c460460
Update website/docs/docs/cloud-integrations/configure-auto-exposures.md
nataliefiann Sep 16, 2024
e0c44d4
Update website/docs/docs/collaborate/auto-exposures.md
mirnawong1 Sep 16, 2024
dfe7fd0
update version banner messaging
JKarlavige Sep 16, 2024
18a7e20
Merge branch 'current' into fix-version-orders
JKarlavige Sep 16, 2024
9646d9f
remove check to always show banner if page not available
JKarlavige Sep 16, 2024
9651162
revert testing edits
JKarlavige Sep 17, 2024
24e4930
Merge branch 'current' into fix-version-orders
JKarlavige Sep 17, 2024
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
88 changes: 0 additions & 88 deletions contributing/single-sourcing-content.md
Copy link
Collaborator Author

@JKarlavige JKarlavige Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality not used, confirmed with Docs team we can remove the Var component: https://dbt-labs.slack.com/archives/C02NCQ9483C/p1726157412409069

Original file line number Diff line number Diff line change
Expand Up @@ -132,94 +132,6 @@ $ dbt test --models [...] --defer --state path/to/artifacts
</VersionBlock>
```

## Using global variables

---

Global variables can be configured for use throughout the docs.

Using a global variable requires two steps:

1. Set the variable in the `website/dbt-global-variables.js` file.
2. Use the **Var** component to add the global variable to a page.

```jsx
// The dbtCore property is the identifier for the variable,
// while the name property is the value shown on the page.

exports.dbtVariables = {
dbtCore: {
name: "dbt Core"
}
}
```

```markdown
// <Var name="dbtCore" /> is converted to dbt Core

You can install <Var name="dbtCore" /> on the command line by using one of these recommended methods:
```

### Versioning global variables

It is possible to version global variables as well. This creates the ability to show different variations of a string based off the current version a visitor has selected.

To extend our `dbt-global-variables.js` file above, we can add a new variable: *note - these versions are not accurate and only shown for this example.*

```jsx
// A new variable called dbtCloud is added below
// This variable includes a versions array
// "Sinter" will replace "dbt Cloud" for versions 0.21 or lower

exports.dbtVariables = {
dbtCore: {
name: "dbt Core"
},
dbtCloud: {
name: "dbt Cloud",
versions: [
{
"name": "Sinter",
"version": "0.21"
}
]
}
}
```

```markdown
You can get started with <Var name="dbtCloud" /> by [Signing up](https://www.getdbt.com/signup/).
```

In the above example, the **dbtCloud** property has a default name of “dbt Cloud”. The naming for variables cascade down, meaning “dbt Cloud” will show for all versions, until version **0.21** or lower is selected. At that point “Sinter” will replace “dbt Cloud”.

### Global variables properties

**name** (required): Expects the identifier for a global variable.

### Global variables example

The global `<Var />` component can be used inline, for example:

```markdown
This piece of markdown content explains why <Var name="dbt" /> is awesome.
```

However, a Var component cannot start a new line of content. Fortunately, a workaround exists to use the Var component at the beginning of a line of content.

To use the component at the beginning of a sentence, add a non-breaking space character before the component:

```markdown
// When starting a new line with a global variable,
// a non-breaking space is required

// Works
&nbsp;<Var name="dbt" /> is awesome!

// Does not work
<Var name="dbt" /> is awesome!
```

## Reusing content

To reuse content on different pages, you can use some techniques like partial files or snippets. Partial files, a built-in Docusaurus feature, is the recommended method over snippets.
Expand Down
32 changes: 0 additions & 32 deletions website/dbt-global-variables.js

This file was deleted.

25 changes: 21 additions & 4 deletions website/dbt-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
* customDisplay for dbt Cloud should be a version ahead of latest dbt Core release (GA or beta).
*/
exports.versions = [
{
version: "2.1",
EOLDate: "2026-04-15",
},
{
version: "1.10.1",
EOLDate: "2026-04-15",
},
{
version: "1.10",
EOLDate: "2026-04-15",
},
{
version: "1.9.1",
customDisplay: "Cloud (Versionless)",
Expand All @@ -30,7 +42,7 @@ exports.versions = [
version: "1.6",
EOLDate: "2024-07-31",
},
]
];

/**
* Controls doc page visibility in the sidebar based on the current version
Expand All @@ -43,11 +55,11 @@ exports.versions = [
*/
exports.versionedPages = [
{
"page": "/reference/resource-configs/target_database",
"page": "reference/resource-configs/target_database",
"lastVersion": "1.8",
},
{
"page": "/reference/resource-configs/target_schema",
"page": "reference/resource-configs/target_schema",
Copy link
Collaborator Author

@JKarlavige JKarlavige Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep these changes, page paths should not have leading forward slash. Remove all other changes in this file.

"lastVersion": "1.8",
},
{
Expand Down Expand Up @@ -201,5 +213,10 @@ exports.versionedCategories = [
{
"category": "Build your metrics",
"firstVersion": "1.6",
}
},
// TODO: Delete demo entry below
{
"category": "Project configs",
"firstVersion": "1.8",
},
]
16 changes: 16 additions & 0 deletions website/docs/docs/version-testing.md
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this page before merge

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Version Testing"
id: "version-testing"
---

<VersionBlock firstVersion="1.6" lastVersion="1.9.1">
## first version - 1.6 | last version - 1.9.1
</VersionBlock>

<VersionBlock firstVersion="2.1">
## first version - 2.1
</VersionBlock>

<VersionBlock firstVersion="1.10">
## first version - 1.10
</VersionBlock>
45 changes: 0 additions & 45 deletions website/src/components/variable/index.js

This file was deleted.

40 changes: 13 additions & 27 deletions website/src/components/versionBlock/index.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
import React, { useState, useEffect, useContext } from 'react'
import VersionContext from '../../stores/VersionContext';
import { availableInCurrentVersion } from '../../utils/available-in-current-version';

export default function VersionBlock({ firstVersion = 0, lastVersion = undefined, children }) {
const { version } = useContext(VersionContext)
export default function VersionBlock({ firstVersion = "0", lastVersion = undefined, children }) {
const { version } = useContext(VersionContext);

const [loading, setLoading] = useState(true)
const [loading, setLoading] = useState(true);

// Hide versionBlock components until version ready
useEffect(() => {
version && setLoading(false)
}, [version])
version && setLoading(false);
}, [version]);

// Only check version if current version set
if(version) {
const currentVersionVal = parseFloat(version)
const firstVersionVal = parseFloat(firstVersion)
{/*
* If last version set, check if current version greater than last version
* Or if current version less than first version
* If either is true, hide block
* Else, if current version less than first version, hide block
*/}
if(lastVersion) {
if((currentVersionVal > parseFloat(lastVersion))
|| (currentVersionVal < firstVersionVal))
return null
} else {
if(currentVersionVal < firstVersionVal) {
return null
}

}
if (version) {
if (!availableInCurrentVersion(
version,
firstVersion,
lastVersion
)) return null;
}

return loading
? null
: <>{children}</>
return loading ? null : <>{children}</>;
}
56 changes: 36 additions & 20 deletions website/src/theme/DocRoot/Layout/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@
version: dbtVersion,
EOLDate,
isPrerelease,
latestStableRelease,

Check warning on line 43 in website/src/theme/DocRoot/Layout/Main/index.js

View workflow job for this annotation

GitHub Actions / eslint-check

'latestStableRelease' is assigned a value but never used
} = useContext(VersionContext);

const { pageAvailable, firstAvailableVersion } = pageVersionCheck(
dbtVersion,
versionedPages,
currentDocRoute
);
const {
pageAvailable,
firstAvailableVersion,
lastAvailableVersion
} = pageVersionCheck(dbtVersion, versionedPages, currentDocRoute);

const hasFirstAvailableVersion =
firstAvailableVersion && firstAvailableVersion !== "0";

// Check whether this version is a isPrerelease, and show banner if so
const [PreData, setPreData] = useState({
Expand Down Expand Up @@ -116,21 +119,34 @@
hiddenSidebarContainer && styles.docItemWrapperEnhanced
)}
>
{!pageAvailable && dbtVersion && firstAvailableVersion && (
<div className={styles.versionBanner}>
<Admonition type="caution" title={`New feature!`} icon="🎉 ">
<p style={{ marginTop: "5px", marginBottom: "0" }}>
Unfortunately, this feature is not available in dbt Core version{" "}
{dbtVersion}
</p>
<p>
{" "}
You should upgrade to {firstAvailableVersion} or later if you
want to use this feature.
</p>
</Admonition>
</div>
)}
{!pageAvailable &&
dbtVersion && (
<div className={styles.versionBanner}>
<Admonition
type="caution"
title={`${hasFirstAvailableVersion ? "New feature!" : lastAvailableVersion ? "Old feature" : "Note"}`}
icon={
hasFirstAvailableVersion
? "🎉"
: lastAvailableVersion
? "❗"
: ""
}
>
<p style={{ marginTop: "5px", marginBottom: "0" }}>
Unfortunately, this feature is not available in dbt Core
version {dbtVersion}
</p>
{hasFirstAvailableVersion ? (
<p>
{" "}
You should upgrade to {firstAvailableVersion} or later if
you want to use this feature.
</p>
) : null}
</Admonition>
</div>
)}
{PreData.showisPrereleaseBanner && (
<div className={styles.versionBanner}>
<Admonition type="caution" title="Warning">
Expand Down
2 changes: 0 additions & 2 deletions website/src/theme/MDXComponents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Snippet from '@site/src/components/snippet';
import YoutubeVideo from '@site/src/components/youtube';
import WistiaVideo from '@site/src/components/wistia';
import VersionBlock from '@site/src/components/versionBlock';
import Var from '@site/src/components/variable';
import Term from '@site/src/components/term';
import EventsFeed from '@site/src/components/events';
import { DiscourseFeed, DiscourseHelpFeed } from '@site/src/components/discourse';
Expand Down Expand Up @@ -84,7 +83,6 @@ const MDXComponents = {
WHCode: WHCode,
YoutubeVideo: YoutubeVideo,
VersionBlock: VersionBlock,
Var: Var,
Term: Term,
EventsFeed: EventsFeed,
DiscourseFeed: DiscourseFeed,
Expand Down
Loading
Loading