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

add deprecation warning to Tabs constructor #767

Merged
merged 1 commit into from
Mar 3, 2017
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
2 changes: 2 additions & 0 deletions packages/core/src/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const RANGESLIDER_NULL_VALUE = `${ns} <RangeSlider> value prop must be an

export const TABS_FIRST_CHILD = `${ns} First child of <Tabs> component should be a <TabList>`;
export const TABS_MISMATCH = `${ns} Number of <Tab> components should equal number of <TabPanel> components`;
export const TABS_DEPRECATED = `${ns} <Tabs> is deprecated since v1.11.0; consider upgrading to <Tabs2>.`
+ " https://blueprintjs.com/#components.tabs.js";

export const TOASTER_INLINE_WARNING = `${ns} Toaster.create() ignores inline prop as it always creates a new element`;

Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
* and https://github.com/palantir/blueprint/blob/master/PATENTS
*/

// only accessible within this file, so use `Utils.isNodeEnv` from the outside.
declare var process: { env: any };

/** Returns whether `process.env.NODE_ENV` exists and equals `env`. */
export function isNodeEnv(env: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider limiting this string type to just "development" | "production" | "test"

Copy link
Contributor Author

@giladgray giladgray Mar 3, 2017

Choose a reason for hiding this comment

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

seems overkill. also you don't get autocomplete so there's little advantage.

Copy link
Contributor

Choose a reason for hiding this comment

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

no, I think it's actually quite meaningful -- why would you compare to other values?

vscode actually does give me autocomplete :P

image

return typeof process !== "undefined" && process.env && process.env.NODE_ENV === env;
}

/** Returns whether the value is a function. Acts as a type guard. */
export function isFunction(value: any): value is Function {
return typeof value === "function";
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Styleguide components.tabs.css
/*
JavaScript API

<div class="pt-callout pt-intent-danger pt-icon-error">
<h5>Deprecated in v1.11.0</h5>
This `Tabs` API has been deprecated in v1.11.0 favor of the simpler and more flexible
`Tabs2` API [described above](#components.tabs.js).
</div>

The `Tabs`, `TabList`, `Tab`, and `TabPanel` components are available in the __@blueprintjs/core__
package. Make sure to review the [general usage docs for JS components](#components.usage).

Expand All @@ -57,6 +63,8 @@ because of how the library manages the virtual DOM for you.
### Sample Usage

```
import { Tab, TabList, TabPanel, Tabs } from "@blueprintjs/core";

<Tabs>
<TabList>
<Tab>First tab</Tab>
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export class Tabs extends AbstractComponent<ITabsProps, ITabsState> {
constructor(props?: ITabsProps, context?: any) {
super(props, context);
this.state = this.getStateFromProps(this.props);

if (!Utils.isNodeEnv("production")) {
console.warn(Errors.TABS_DEPRECATED);
}
}

public render() {
Expand Down