Skip to content

Moved components warning #1489

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

Merged
merged 2 commits into from
Aug 13, 2018
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
7 changes: 7 additions & 0 deletions components/bread-crumb/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@

// Alias
import Breadcrumb from '../breadcrumb';
import componentHasMoved from '../../utilities/warning/component-has-moved';
import { BREADCRUMB } from '../../utilities/constants';

componentHasMoved(BREADCRUMB, {
oldFileLocation: 'components/bread-crumb',
newFileLocation: 'components/breadcrumb',
});

export default Breadcrumb;
7 changes: 7 additions & 0 deletions components/forms/input/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@

// Alias
import Input from '../../input';
import componentHasMoved from '../../../utilities/warning/component-has-moved';
import { INPUT } from '../../../utilities/constants';

componentHasMoved(INPUT, {
oldFileLocation: 'components/forms/input',
newFileLocation: 'components/input',
});

export default Input;
7 changes: 7 additions & 0 deletions components/forms/radio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@

// Alias
import Radio from '../../radio';
import componentHasMoved from '../../../utilities/warning/component-has-moved';
import { RADIO } from '../../../utilities/constants';

componentHasMoved(RADIO, {
oldFileLocation: 'components/forms/radio',
newFileLocation: 'components/radio',
});

export default Radio;
7 changes: 7 additions & 0 deletions components/forms/textarea/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@

// Alias
import TextArea from '../../textarea';
import componentHasMoved from '../../../utilities/warning/component-has-moved';
import { TEXTAREA } from '../../../utilities/constants';

componentHasMoved(TEXTAREA, {
oldFileLocation: 'components/forms/textarea',
newFileLocation: 'components/textarea',
});

export default TextArea;
7 changes: 7 additions & 0 deletions components/navigation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@

// Alias
import VerticalNavigation from '../vertical-navigation';
import componentHasMoved from '../../utilities/warning/component-has-moved';
import { NAVIGATION } from '../../utilities/constants';

componentHasMoved(NAVIGATION, {
oldFileLocation: 'components/navigation',
newFileLocation: 'components/vertical-navigation',
});

export default VerticalNavigation;
8 changes: 8 additions & 0 deletions components/popover-tooltip/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
// Alias
import Tooltip from '../tooltip';

import componentHasMoved from '../../utilities/warning/component-has-moved';
import { POPOVER_TOOLTIP } from '../../utilities/constants';

componentHasMoved(POPOVER_TOOLTIP, {
oldFileLocation: 'components/popover-tooltip',
newFileLocation: 'components/tooltip',
});

export default Tooltip;
27 changes: 27 additions & 0 deletions utilities/warning/component-has-moved.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */

/* eslint-disable import/no-mutable-exports */

import warning from 'warning';

let hasMoved = function () {};

if (process.env.NODE_ENV !== 'production') {
const hasWarned = {};

hasMoved = function (control, { oldFileLocation, newFileLocation, comment }) {
const additionalComment = comment ? ` ${comment}` : '';
if (!hasWarned[control]) {
/* eslint-disable max-len */
warning(
false,
`[Design System React] ${control} file import path has changed. Old import path was \`design-system-react/${oldFileLocation}\`. New import path is \`design-system-react/${newFileLocation}\`.${additionalComment}`
);
/* eslint-enable max-len */
hasWarned[control] = true;
}
};
}

export default hasMoved;