diff --git a/app/components/CenteredContent/CenteredContent.js b/app/components/CenteredContent/CenteredContent.js index 85ca677d..578d0055 100644 --- a/app/components/CenteredContent/CenteredContent.js +++ b/app/components/CenteredContent/CenteredContent.js @@ -8,7 +8,7 @@ type Props = { const Container = styled.div` width: 100%; - margin: 60px 20px; + margin: 60px; `; const Content = styled.div` diff --git a/app/components/Layout/Layout.js b/app/components/Layout/Layout.js index 226aea4b..34e7a94b 100644 --- a/app/components/Layout/Layout.js +++ b/app/components/Layout/Layout.js @@ -8,32 +8,21 @@ import { observer, inject } from 'mobx-react'; import keydown from 'react-keydown'; import Analytics from 'shared/components/Analytics'; import Flex from 'shared/components/Flex'; -import { color, layout } from 'shared/styles/constants'; +import { layout } from 'shared/styles/constants'; import { documentEditUrl, homeUrl, searchUrl } from 'utils/routeHelpers'; -import Avatar from 'components/Avatar'; import { LoadingIndicatorBar } from 'components/LoadingIndicator'; -import Scrollable from 'components/Scrollable'; -import HomeIcon from 'components/Icon/HomeIcon'; -import SearchIcon from 'components/Icon/SearchIcon'; -import StarredIcon from 'components/Icon/StarredIcon'; +import Sidebar from 'components/Sidebar'; +import Modals from 'components/Modals'; import Toasts from 'components/Toasts'; -import AccountMenu from 'menus/AccountMenu'; - -import SidebarCollections from './components/SidebarCollections'; -import SidebarLink from './components/SidebarLink'; -import HeaderBlock from './components/HeaderBlock'; -import Modals from './components/Modals'; import AuthStore from 'stores/AuthStore'; import UiStore from 'stores/UiStore'; -import CollectionsStore from 'stores/CollectionsStore'; import DocumentsStore from 'stores/DocumentsStore'; type Props = { history: Object, location: Location, - collections: CollectionsStore, documents: DocumentsStore, children?: ?React.Element, actions?: ?React.Element, @@ -75,31 +64,10 @@ class Layout extends React.Component { this.props.ui.setActiveModal('keyboard-shortcuts'); } - handleCreateCollection = () => { - this.props.ui.setActiveModal('collection-new'); - }; - - handleEditCollection = () => { - this.props.ui.setActiveModal('collection-edit'); - }; - - setScrollableRef = ref => { - this.scrollable = ref; - }; - - scrollToActiveDocument = ref => { - const scrollable = this.scrollable; - if (!ref || !scrollable) return; - - const container = scrollable.getBoundingClientRect(); - const bounds = ref.getBoundingClientRect(); - const scrollTop = bounds.top + container.top; - scrollable.scrollTop = scrollTop; - }; - render() { - const { auth, documents, ui } = this.props; + const { auth, ui } = this.props; const { user, team } = auth; + const showSidebar = auth.authenticated && user && team; return ( @@ -116,44 +84,7 @@ class Layout extends React.Component { {this.props.notifications} - {auth.authenticated && - user && - team && ( - - - - - } - /> - - - - - }> - Home - - }> - Search - - }> - Starred - - - - - - - - - )} + {showSidebar && } {this.props.children} @@ -177,23 +108,4 @@ const Content = styled(Flex)` transition: margin-left 200ms ease-in-out; `; -const Sidebar = styled(Flex)` - position: fixed; - top: 0; - bottom: 0; - left: ${props => (props.editMode ? `-${layout.sidebarWidth}` : 0)}; - width: ${layout.sidebarWidth}; - background: ${color.smoke}; - transition: left 200ms ease-in-out; -`; - -const LinkSection = styled(Flex)` - flex-direction: column; - margin: 24px 0; - padding: 0 24px; - position: relative; -`; - -export default withRouter( - inject('user', 'auth', 'ui', 'documents', 'collections')(Layout) -); +export default withRouter(inject('user', 'auth', 'ui', 'documents')(Layout)); diff --git a/app/components/Layout/components/Title.js b/app/components/Layout/components/Title.js deleted file mode 100644 index 532fe0e4..00000000 --- a/app/components/Layout/components/Title.js +++ /dev/null @@ -1,44 +0,0 @@ -// @flow -import React from 'react'; -import _ from 'lodash'; -import styled from 'styled-components'; - -type Props = { - content: string, - truncate?: number, - placeholder?: ?string, -}; - -class Title extends React.Component { - props: Props; - - render() { - let title; - if (this.props.truncate) { - title = _.truncate(this.props.content, { length: this.props.truncate }); - } else { - title = this.props.content; - } - - let usePlaceholder; - if (this.props.children === null && this.props.placeholder) { - title = this.props.placeholder; - usePlaceholder = true; - } - - return ( - - {title &&  / } - - {title} - - - ); - } -} - -const TitleText = styled.span` - opacity: ${props => (props.untitled ? 0.5 : 1)}; -`; - -export default Title; diff --git a/app/components/Layout/index.js b/app/components/Layout/index.js index fb7b105d..62fb061d 100644 --- a/app/components/Layout/index.js +++ b/app/components/Layout/index.js @@ -1,7 +1,3 @@ // @flow import Layout from './Layout'; -import Title from './components/Title'; - export default Layout; - -export { Title }; diff --git a/app/components/Layout/components/Modals.js b/app/components/Modals/Modals.js similarity index 100% rename from app/components/Layout/components/Modals.js rename to app/components/Modals/Modals.js diff --git a/app/components/Modals/index.js b/app/components/Modals/index.js new file mode 100644 index 00000000..df1b9302 --- /dev/null +++ b/app/components/Modals/index.js @@ -0,0 +1,3 @@ +// @flow +import Modals from './Modals'; +export default Modals; diff --git a/app/components/Sidebar/Sidebar.js b/app/components/Sidebar/Sidebar.js new file mode 100644 index 00000000..1242e663 --- /dev/null +++ b/app/components/Sidebar/Sidebar.js @@ -0,0 +1,117 @@ +// @flow +import React, { Component } from 'react'; +import { withRouter } from 'react-router-dom'; +import type { Location } from 'react-router-dom'; +import styled from 'styled-components'; +import { observer, inject } from 'mobx-react'; +import Flex from 'shared/components/Flex'; +import { color, layout } from 'shared/styles/constants'; + +import AccountMenu from 'menus/AccountMenu'; +import Avatar from 'components/Avatar'; +import Scrollable from 'components/Scrollable'; +import HomeIcon from 'components/Icon/HomeIcon'; +import SearchIcon from 'components/Icon/SearchIcon'; +import StarredIcon from 'components/Icon/StarredIcon'; +import Collections from './components/Collections'; +import SidebarLink from './components/SidebarLink'; +import HeaderBlock from './components/HeaderBlock'; + +import AuthStore from 'stores/AuthStore'; +import UiStore from 'stores/UiStore'; + +type Props = { + history: Object, + location: Location, + auth: AuthStore, + ui: UiStore, +}; + +@observer +class Sidebar extends Component { + props: Props; + scrollable: ?HTMLDivElement; + + handleCreateCollection = () => { + this.props.ui.setActiveModal('collection-new'); + }; + + handleEditCollection = () => { + this.props.ui.setActiveModal('collection-edit'); + }; + + setScrollableRef = ref => { + this.scrollable = ref; + }; + + scrollToActiveDocument = ref => { + const scrollable = this.scrollable; + if (!ref || !scrollable) return; + + const container = scrollable.getBoundingClientRect(); + const bounds = ref.getBoundingClientRect(); + const scrollTop = bounds.top + container.top; + scrollable.scrollTop = scrollTop; + }; + + render() { + const { auth, ui } = this.props; + const { user, team } = auth; + if (!user || !team) return; + + return ( + + + + + } + /> + + + +
+ }> + Home + + }> + Search + + }> + Starred + +
+
+ +
+
+
+
+ ); + } +} + +const Container = styled(Flex)` + position: fixed; + top: 0; + bottom: 0; + left: ${props => (props.editMode ? `-${layout.sidebarWidth}` : 0)}; + width: ${layout.sidebarWidth}; + background: ${color.smoke}; + transition: left 200ms ease-in-out; +`; + +const Section = styled(Flex)` + flex-direction: column; + margin: 24px 0; + padding: 0 24px; + position: relative; +`; + +export default withRouter(inject('user', 'auth', 'ui')(Sidebar)); diff --git a/app/components/Layout/components/SidebarCollections.js b/app/components/Sidebar/components/Collections.js similarity index 96% rename from app/components/Layout/components/SidebarCollections.js rename to app/components/Sidebar/components/Collections.js index e68f6f7f..157c410f 100644 --- a/app/components/Layout/components/SidebarCollections.js +++ b/app/components/Sidebar/components/Collections.js @@ -25,14 +25,13 @@ type Props = { location: Location, collections: CollectionsStore, documents: DocumentsStore, - activeDocument: ?Document, onCreateCollection: () => void, activeDocumentRef: HTMLElement => void, ui: UiStore, }; @observer -class SidebarCollections extends Component { +class Collections extends Component { props: Props; render() { @@ -40,7 +39,6 @@ class SidebarCollections extends Component { history, location, collections, - activeDocument, ui, activeDocumentRef, documents, @@ -55,7 +53,7 @@ class SidebarCollections extends Component { history={history} location={location} collection={collection} - activeDocument={activeDocument} + activeDocument={documents.active} activeDocumentRef={activeDocumentRef} prefetchDocument={documents.prefetchDocument} ui={ui} @@ -276,4 +274,4 @@ const Children = styled(Flex)` margin-left: 12px; `; -export default inject('collections', 'ui', 'documents')(SidebarCollections); +export default inject('collections', 'ui', 'documents')(Collections); diff --git a/app/components/Layout/components/HeaderBlock.js b/app/components/Sidebar/components/HeaderBlock.js similarity index 100% rename from app/components/Layout/components/HeaderBlock.js rename to app/components/Sidebar/components/HeaderBlock.js diff --git a/app/components/Layout/components/SidebarLink.js b/app/components/Sidebar/components/SidebarLink.js similarity index 100% rename from app/components/Layout/components/SidebarLink.js rename to app/components/Sidebar/components/SidebarLink.js diff --git a/app/components/Sidebar/index.js b/app/components/Sidebar/index.js new file mode 100644 index 00000000..c1b441c2 --- /dev/null +++ b/app/components/Sidebar/index.js @@ -0,0 +1,3 @@ +// @flow +import Sidebar from './Sidebar'; +export default Sidebar; diff --git a/server/migrations/20160619080644-initial.js b/server/migrations/20160619080644-initial.js index d03ba39a..851afa8b 100644 --- a/server/migrations/20160619080644-initial.js +++ b/server/migrations/20160619080644-initial.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.createTable('teams', { + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('teams', { id: { type: 'UUID', allowNull: false, @@ -29,7 +29,7 @@ module.exports = { }, }); - queryInterface.createTable('atlases', { + await queryInterface.createTable('atlases', { id: { type: 'UUID', allowNull: false, @@ -61,15 +61,11 @@ module.exports = { }, teamId: { type: 'UUID', - allowNull: false, - // references: { - // model: "teams", - // key: "id", - // } + allowNull: false }, }); - queryInterface.createTable('users', { + await queryInterface.createTable('users', { id: { type: 'UUID', allowNull: false, @@ -119,15 +115,11 @@ module.exports = { }, teamId: { type: 'UUID', - allowNull: true, - // references: { - // model: "teams", - // key: "id", - // } + allowNull: true }, }); - queryInterface.createTable('documents', { + await queryInterface.createTable('documents', { id: { type: 'UUID', allowNull: false, @@ -169,32 +161,20 @@ module.exports = { }, userId: { type: 'UUID', - allowNull: true, - // references: { - // model: "users", - // key: "id", - // } + allowNull: true }, atlasId: { type: 'UUID', - allowNull: true, - // references: { - // model: "atlases", - // key: "id", - // } + allowNull: true }, teamId: { type: 'UUID', - allowNull: true, - // references: { - // model: "teams", - // key: "id", - // } + allowNull: true }, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.dropAllTables(); + down: async (queryInterface, Sequelize) => { + await queryInterface.dropAllTables(); }, }; diff --git a/server/migrations/20160622043741-add-parent-document.js b/server/migrations/20160622043741-add-parent-document.js index 8fc0fd98..9aeadb50 100644 --- a/server/migrations/20160622043741-add-parent-document.js +++ b/server/migrations/20160622043741-add-parent-document.js @@ -1,12 +1,12 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('documents', 'parentDocumentId', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('documents', 'parentDocumentId', { type: Sequelize.UUID, allowNull: true, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('documents', 'parentDocumentId'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('documents', 'parentDocumentId'); }, }; diff --git a/server/migrations/20160626063409-add-indexes.js b/server/migrations/20160626063409-add-indexes.js index 5e8042c8..70f7be1c 100644 --- a/server/migrations/20160626063409-add-indexes.js +++ b/server/migrations/20160626063409-add-indexes.js @@ -1,27 +1,27 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addIndex('documents', ['urlId']); - queryInterface.addIndex('documents', ['id', 'atlasId']); - queryInterface.addIndex('documents', ['id', 'teamId']); - queryInterface.addIndex('documents', ['parentDocumentId', 'atlasId']); + up: async (queryInterface, Sequelize) => { + await queryInterface.addIndex('documents', ['urlId']); + await queryInterface.addIndex('documents', ['id', 'atlasId']); + await queryInterface.addIndex('documents', ['id', 'teamId']); + await queryInterface.addIndex('documents', ['parentDocumentId', 'atlasId']); - queryInterface.addIndex('atlases', ['id', 'teamId']); + await queryInterface.addIndex('atlases', ['id', 'teamId']); - queryInterface.addIndex('teams', ['slackId']); + await queryInterface.addIndex('teams', ['slackId']); - queryInterface.addIndex('users', ['slackId']); + await queryInterface.addIndex('users', ['slackId']); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeIndex('documents', ['urlId']); - queryInterface.removeIndex('documents', ['id', 'atlasId']); - queryInterface.removeIndex('documents', ['id', 'teamId']); - queryInterface.removeIndex('documents', ['parentDocumentId', 'atlasId']); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex('documents', ['urlId']); + await queryInterface.removeIndex('documents', ['id', 'atlasId']); + await queryInterface.removeIndex('documents', ['id', 'teamId']); + await queryInterface.removeIndex('documents', ['parentDocumentId', 'atlasId']); - queryInterface.removeIndex('atlases', ['id', 'teamId']); + await queryInterface.removeIndex('atlases', ['id', 'teamId']); - queryInterface.removeIndex('teams', ['slackId']); + await queryInterface.removeIndex('teams', ['slackId']); - queryInterface.removeIndex('users', ['slackId']); + await queryInterface.removeIndex('users', ['slackId']); }, }; diff --git a/server/migrations/20160626175224-add-revisions.js b/server/migrations/20160626175224-add-revisions.js index f3d85af6..b4385bef 100644 --- a/server/migrations/20160626175224-add-revisions.js +++ b/server/migrations/20160626175224-add-revisions.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.createTable('revisions', { + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('revisions', { id: { type: 'UUID', allowNull: false, @@ -47,7 +47,7 @@ module.exports = { }, }); - queryInterface.addColumn('documents', 'lastModifiedById', { + await queryInterface.addColumn('documents', 'lastModifiedById', { type: 'UUID', allowNull: false, references: { @@ -55,16 +55,16 @@ module.exports = { }, }); - queryInterface.addColumn('documents', 'revisionCount', { + await queryInterface.addColumn('documents', 'revisionCount', { type: 'INTEGER', defaultValue: 0, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.dropTable('revisions'); + down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('revisions'); - queryInterface.removeColumn('documents', 'lastModifiedById'); - queryInterface.removeColumn('documents', 'revisionCount'); + await queryInterface.removeColumn('documents', 'lastModifiedById'); + await queryInterface.removeColumn('documents', 'revisionCount'); }, }; diff --git a/server/migrations/20160711071958-search-index.js b/server/migrations/20160711071958-search-index.js index 6b70ab1d..2c22c613 100644 --- a/server/migrations/20160711071958-search-index.js +++ b/server/migrations/20160711071958-search-index.js @@ -1,5 +1,5 @@ module.exports = { - up: function(queryInterface, Sequelize) { + up: async (queryInterface, Sequelize) => { const searchDocument = ` ALTER TABLE documents ADD COLUMN "searchVector" tsvector; CREATE INDEX documents_tsv_idx ON documents USING gin("searchVector"); @@ -34,11 +34,11 @@ CREATE TRIGGER atlases_tsvectorupdate BEFORE INSERT OR UPDATE ON atlases FOR EACH ROW EXECUTE PROCEDURE atlases_search_trigger(); `; - queryInterface.sequelize.query(searchDocument); - queryInterface.sequelize.query(searchCollection); + await queryInterface.sequelize.query(searchDocument); + await queryInterface.sequelize.query(searchCollection); }, - down: function(queryInterface, Sequelize) { + down: async (queryInterface, Sequelize) => { // TODO? }, }; diff --git a/server/migrations/20160726061511-atlas-creator.js b/server/migrations/20160726061511-atlas-creator.js index e2f567c3..ae3b5ae6 100644 --- a/server/migrations/20160726061511-atlas-creator.js +++ b/server/migrations/20160726061511-atlas-creator.js @@ -1,12 +1,12 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('atlases', 'creatorId', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('atlases', 'creatorId', { type: Sequelize.UUID, allowNull: true, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('atlases', 'creatorId'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('atlases', 'creatorId'); }, }; diff --git a/server/migrations/20160812145029-document-atlas-soft-delete.js b/server/migrations/20160812145029-document-atlas-soft-delete.js index 6c59a803..bfefc82d 100644 --- a/server/migrations/20160812145029-document-atlas-soft-delete.js +++ b/server/migrations/20160812145029-document-atlas-soft-delete.js @@ -1,18 +1,18 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('atlases', 'deletedAt', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('atlases', 'deletedAt', { type: Sequelize.DATE, allowNull: true, }); - queryInterface.addColumn('documents', 'deletedAt', { + await queryInterface.addColumn('documents', 'deletedAt', { type: Sequelize.DATE, allowNull: true, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('atlases', 'deletedAt'); - queryInterface.removeColumn('documents', 'deletedAt'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('atlases', 'deletedAt'); + await queryInterface.removeColumn('documents', 'deletedAt'); }, }; diff --git a/server/migrations/20160814083127-paranoia-indeces.js b/server/migrations/20160814083127-paranoia-indeces.js index 2d8338a2..a903cec1 100644 --- a/server/migrations/20160814083127-paranoia-indeces.js +++ b/server/migrations/20160814083127-paranoia-indeces.js @@ -1,47 +1,47 @@ module.exports = { - up: function(queryInterface, Sequelize) { + up: async (queryInterface, Sequelize) => { // Remove old indeces - queryInterface.removeIndex('documents', ['urlId']); - queryInterface.removeIndex('documents', ['id', 'atlasId']); - queryInterface.removeIndex('documents', ['id', 'teamId']); - queryInterface.removeIndex('documents', ['parentDocumentId', 'atlasId']); + await queryInterface.removeIndex('documents', ['urlId']); + await queryInterface.removeIndex('documents', ['id', 'atlasId']); + await queryInterface.removeIndex('documents', ['id', 'teamId']); + await queryInterface.removeIndex('documents', ['parentDocumentId', 'atlasId']); - queryInterface.removeIndex('atlases', ['id', 'teamId']); + await queryInterface.removeIndex('atlases', ['id', 'teamId']); // Add new ones - queryInterface.addIndex('documents', ['id', 'deletedAt']); - queryInterface.addIndex('documents', ['urlId', 'deletedAt']); - queryInterface.addIndex('documents', ['id', 'atlasId', 'deletedAt']); - queryInterface.addIndex('documents', ['id', 'teamId', 'deletedAt']); - queryInterface.addIndex('documents', [ + await queryInterface.addIndex('documents', ['id', 'deletedAt']); + await queryInterface.addIndex('documents', ['urlId', 'deletedAt']); + await queryInterface.addIndex('documents', ['id', 'atlasId', 'deletedAt']); + await queryInterface.addIndex('documents', ['id', 'teamId', 'deletedAt']); + await queryInterface.addIndex('documents', [ 'parentDocumentId', 'atlasId', 'deletedAt', ]); - queryInterface.addIndex('atlases', ['id', 'deletedAt']); - queryInterface.addIndex('atlases', ['id', 'teamId', 'deletedAt']); + await queryInterface.addIndex('atlases', ['id', 'deletedAt']); + await queryInterface.addIndex('atlases', ['id', 'teamId', 'deletedAt']); }, - down: function(queryInterface, Sequelize) { - queryInterface.addIndex('documents', ['urlId']); - queryInterface.addIndex('documents', ['id', 'atlasId']); - queryInterface.addIndex('documents', ['id', 'teamId']); - queryInterface.addIndex('documents', ['parentDocumentId', 'atlasId']); + down: async (queryInterface, Sequelize) => { + await queryInterface.addIndex('documents', ['urlId']); + await queryInterface.addIndex('documents', ['id', 'atlasId']); + await queryInterface.addIndex('documents', ['id', 'teamId']); + await queryInterface.addIndex('documents', ['parentDocumentId', 'atlasId']); - queryInterface.addIndex('atlases', ['id', 'teamId']); + await queryInterface.addIndex('atlases', ['id', 'teamId']); - queryInterface.removeIndex('documents', ['id', 'deletedAt']); - queryInterface.removeIndex('documents', ['urlId', 'deletedAt']); - queryInterface.removeIndex('documents', ['id', 'atlasId', 'deletedAt']); - queryInterface.removeIndex('documents', ['id', 'teamId', 'deletedAt']); - queryInterface.removeIndex('documents', [ + await queryInterface.removeIndex('documents', ['id', 'deletedAt']); + await queryInterface.removeIndex('documents', ['urlId', 'deletedAt']); + await queryInterface.removeIndex('documents', ['id', 'atlasId', 'deletedAt']); + await queryInterface.removeIndex('documents', ['id', 'teamId', 'deletedAt']); + await queryInterface.removeIndex('documents', [ 'parentDocumentId', 'atlasId', 'deletedAt', ]); - queryInterface.removeIndex('atlases', ['id', 'deletedAt']); - queryInterface.removeIndex('atlases', ['id', 'teamId', 'deletedAt']); + await queryInterface.removeIndex('atlases', ['id', 'deletedAt']); + await queryInterface.removeIndex('atlases', ['id', 'teamId', 'deletedAt']); }, }; diff --git a/server/migrations/20160814095336-add-document-createdById.js b/server/migrations/20160814095336-add-document-createdById.js index cb70ac09..1a3b8171 100644 --- a/server/migrations/20160814095336-add-document-createdById.js +++ b/server/migrations/20160814095336-add-document-createdById.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('documents', 'createdById', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('documents', 'createdById', { type: 'UUID', allowNull: true, references: { @@ -9,7 +9,7 @@ module.exports = { }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('documents', 'createdById'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('documents', 'createdById'); }, }; diff --git a/server/migrations/20160814111419-add-document-collaboratorIds.js b/server/migrations/20160814111419-add-document-collaboratorIds.js index 4eab7090..c10d2663 100644 --- a/server/migrations/20160814111419-add-document-collaboratorIds.js +++ b/server/migrations/20160814111419-add-document-collaboratorIds.js @@ -1,10 +1,10 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('documents', 'collaboratorIds', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('documents', 'collaboratorIds', { type: Sequelize.ARRAY(Sequelize.UUID), }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('documents', 'collaboratorIds'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('documents', 'collaboratorIds'); }, }; diff --git a/server/migrations/20160815142720-app-collection-urlId.js b/server/migrations/20160815142720-app-collection-urlId.js index 243395d0..47d4ae61 100644 --- a/server/migrations/20160815142720-app-collection-urlId.js +++ b/server/migrations/20160815142720-app-collection-urlId.js @@ -1,12 +1,12 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('atlases', 'urlId', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('atlases', 'urlId', { type: Sequelize.STRING, unique: true, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('atlases', 'urlId'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('atlases', 'urlId'); }, }; diff --git a/server/migrations/20160816082738-add-revision-index.js b/server/migrations/20160816082738-add-revision-index.js index c907c6d8..0b7caba9 100644 --- a/server/migrations/20160816082738-add-revision-index.js +++ b/server/migrations/20160816082738-add-revision-index.js @@ -1,9 +1,9 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addIndex('revisions', ['documentId']); + up: async (queryInterface, Sequelize) => { + await queryInterface.addIndex('revisions', ['documentId']); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeIndex('revisions', ['documentId']); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex('revisions', ['documentId']); }, }; diff --git a/server/migrations/20160824061730-add-apikeys.js b/server/migrations/20160824061730-add-apikeys.js index 048754e3..fb476197 100644 --- a/server/migrations/20160824061730-add-apikeys.js +++ b/server/migrations/20160824061730-add-apikeys.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.createTable('apiKeys', { + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('apiKeys', { id: { type: 'UUID', allowNull: false, @@ -17,11 +17,7 @@ module.exports = { }, userId: { type: 'UUID', - allowNull: true, - // references: { - // model: 'users', - // key: 'id', - // }, + allowNull: true }, createdAt: { type: 'TIMESTAMP WITH TIME ZONE', @@ -38,7 +34,7 @@ module.exports = { }); }, - down: function(queryInterface, Sequelize) { - queryInterface.dropTable('apiKeys'); + down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('apiKeys'); }, }; diff --git a/server/migrations/20160824062457-add-apikey-indeces.js b/server/migrations/20160824062457-add-apikey-indeces.js index b5803243..0b31d2c8 100644 --- a/server/migrations/20160824062457-add-apikey-indeces.js +++ b/server/migrations/20160824062457-add-apikey-indeces.js @@ -1,11 +1,11 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addIndex('apiKeys', ['secret', 'deletedAt']); - queryInterface.addIndex('apiKeys', ['userId', 'deletedAt']); + up: async (queryInterface, Sequelize) => { + await queryInterface.addIndex('apiKeys', ['secret', 'deletedAt']); + await queryInterface.addIndex('apiKeys', ['userId', 'deletedAt']); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeIndex('apiKeys', ['secret', 'deletedAt']); - queryInterface.removeIndex('apiKeys', ['userId', 'deletedAt']); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex('apiKeys', ['secret', 'deletedAt']); + await queryInterface.removeIndex('apiKeys', ['userId', 'deletedAt']); }, }; diff --git a/server/migrations/20160911230444-user-optional-slack-id.js b/server/migrations/20160911230444-user-optional-slack-id.js index f3531738..1cbb3ef8 100644 --- a/server/migrations/20160911230444-user-optional-slack-id.js +++ b/server/migrations/20160911230444-user-optional-slack-id.js @@ -1,27 +1,24 @@ -/* eslint-disable */ -'use strict'; - module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.changeColumn('users', 'slackId', { + up: async (queryInterface, Sequelize) => { + await queryInterface.changeColumn('users', 'slackId', { type: Sequelize.STRING, unique: false, allowNull: true, }); - queryInterface.changeColumn('teams', 'slackId', { + await queryInterface.changeColumn('teams', 'slackId', { type: Sequelize.STRING, unique: false, allowNull: true, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.changeColumn('users', 'slackId', { + down: async (queryInterface, Sequelize) => { + await queryInterface.changeColumn('users', 'slackId', { type: Sequelize.STRING, unique: true, allowNull: false, }); - queryInterface.changeColumn('teams', 'slackId', { + await queryInterface.changeColumn('teams', 'slackId', { type: Sequelize.STRING, unique: true, allowNull: false, diff --git a/server/migrations/20160911232911-user-unique-fields.js b/server/migrations/20160911232911-user-unique-fields.js index 4dfaffe2..d87731db 100644 --- a/server/migrations/20160911232911-user-unique-fields.js +++ b/server/migrations/20160911232911-user-unique-fields.js @@ -1,25 +1,25 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.changeColumn('users', 'email', { + up: async (queryInterface, Sequelize) => { + await queryInterface.changeColumn('users', 'email', { type: Sequelize.STRING, unique: true, allowNull: false, }); - queryInterface.changeColumn('users', 'username', { + await queryInterface.changeColumn('users', 'username', { type: Sequelize.STRING, unique: true, allowNull: false, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.changeColumn('users', 'email', { + down: async (queryInterface, Sequelize) => { + await queryInterface.changeColumn('users', 'email', { type: Sequelize.STRING, unique: false, allowNull: true, }); - queryInterface.changeColumn('users', 'username', { + await queryInterface.changeColumn('users', 'username', { type: Sequelize.STRING, unique: false, allowNull: true, diff --git a/server/migrations/20160911234928-user-password.js b/server/migrations/20160911234928-user-password.js index f477dcd1..c39671b8 100644 --- a/server/migrations/20160911234928-user-password.js +++ b/server/migrations/20160911234928-user-password.js @@ -1,12 +1,12 @@ module.exports = { - up: (queryInterface, Sequelize) => { - queryInterface.addColumn('users', 'passwordDigest', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('users', 'passwordDigest', { type: Sequelize.STRING, allowNull: true, }); }, - down: (queryInterface, _Sequelize) => { - queryInterface.removeColumn('users', 'passwordDigest'); + down: async (queryInterface, _Sequelize) => { + await queryInterface.removeColumn('users', 'passwordDigest'); }, }; diff --git a/server/migrations/20170603185012-add-collection-documentStructure-migration.js b/server/migrations/20170603185012-add-collection-documentStructure-migration.js index 671b2e67..55b26ed4 100644 --- a/server/migrations/20170603185012-add-collection-documentStructure-migration.js +++ b/server/migrations/20170603185012-add-collection-documentStructure-migration.js @@ -1,16 +1,14 @@ module.exports = { - up: (queryInterface, Sequelize) => { - queryInterface.renameTable('atlases', 'collections').then(() => { - queryInterface.addColumn('collections', 'documentStructure', { - type: Sequelize.JSONB, - allowNull: true, - }); + up: async (queryInterface, Sequelize) => { + await queryInterface.renameTable('atlases', 'collections'); + await queryInterface.addColumn('collections', 'documentStructure', { + type: Sequelize.JSONB, + allowNull: true, }); }, - down: (queryInterface, _Sequelize) => { - queryInterface.renameTable('collections', 'atlases').then(() => { - queryInterface.removeColumn('atlases', 'documentStructure'); - }); + down: async (queryInterface, _Sequelize) => { + await queryInterface.renameTable('collections', 'atlases'); + await queryInterface.removeColumn('atlases', 'documentStructure'); }, }; diff --git a/server/migrations/20170604052346-add-views.js b/server/migrations/20170604052346-add-views.js index cbaea808..b15c5030 100644 --- a/server/migrations/20170604052346-add-views.js +++ b/server/migrations/20170604052346-add-views.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface + up: async (queryInterface, Sequelize) => { + await queryInterface .createTable('views', { id: { type: Sequelize.UUID, @@ -28,17 +28,14 @@ module.exports = { type: Sequelize.DATE, allowNull: false, }, - }) - .then(() => { - queryInterface.addIndex('views', ['documentId', 'userId'], { - indicesType: 'UNIQUE', - }); + }); + await queryInterface.addIndex('views', ['documentId', 'userId'], { + indicesType: 'UNIQUE', }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeIndex('views', ['documentId', 'userId']).then(() => { - queryInterface.dropTable('views'); - }); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex('views', ['documentId', 'userId']); + await queryInterface.dropTable('views'); }, }; diff --git a/server/migrations/20170604052347-add-stars.js b/server/migrations/20170604052347-add-stars.js index 1046022d..4b5de728 100644 --- a/server/migrations/20170604052347-add-stars.js +++ b/server/migrations/20170604052347-add-stars.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface + up: async (queryInterface, Sequelize) => { + await queryInterface .createTable('stars', { id: { type: Sequelize.UUID, @@ -23,17 +23,14 @@ module.exports = { type: Sequelize.DATE, allowNull: false, }, - }) - .then(() => { - queryInterface.addIndex('stars', ['documentId', 'userId'], { - indicesType: 'UNIQUE', - }); }); - }, - - down: function(queryInterface, Sequelize) { - queryInterface.removeIndex('stars', ['documentId', 'userId']).then(() => { - queryInterface.dropTable('stars'); + await queryInterface.addIndex('stars', ['documentId', 'userId'], { + indicesType: 'UNIQUE', }); }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex('stars', ['documentId', 'userId']); + await queryInterface.dropTable('stars'); + }, }; diff --git a/server/migrations/20170712055148-non-unique-email.js b/server/migrations/20170712055148-non-unique-email.js index 61615b93..f4547039 100644 --- a/server/migrations/20170712055148-non-unique-email.js +++ b/server/migrations/20170712055148-non-unique-email.js @@ -1,16 +1,16 @@ module.exports = { - up: (queryInterface, Sequelize) => { - queryInterface.removeConstraint('users', 'email_unique_idx'); - queryInterface.removeConstraint('users', 'username_unique_idx'); + up: async (queryInterface, Sequelize) => { + await queryInterface.removeConstraint('users', 'email_unique_idx'); + await queryInterface.removeConstraint('users', 'username_unique_idx'); }, - down: (queryInterface, Sequelize) => { - queryInterface.changeColumn('users', 'email', { + down: async (queryInterface, Sequelize) => { + await queryInterface.changeColumn('users', 'email', { type: Sequelize.STRING, unique: true, allowNull: false, }); - queryInterface.changeColumn('users', 'username', { + await queryInterface.changeColumn('users', 'username', { type: Sequelize.STRING, unique: true, allowNull: false, diff --git a/server/migrations/20170712072234-uniq-slack-id.js b/server/migrations/20170712072234-uniq-slack-id.js index 2b0c37be..980db4e4 100644 --- a/server/migrations/20170712072234-uniq-slack-id.js +++ b/server/migrations/20170712072234-uniq-slack-id.js @@ -1,13 +1,13 @@ module.exports = { - up: (queryInterface, Sequelize) => { - queryInterface.changeColumn('users', 'slackId', { + up: async (queryInterface, Sequelize) => { + await queryInterface.changeColumn('users', 'slackId', { type: Sequelize.STRING, unique: true, allowNull: false, }); }, - down: (queryInterface, Sequelize) => { - queryInterface.removeConstraint('users', 'users_slack_id_idx'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeConstraint('users', 'users_slack_id_idx'); }, }; diff --git a/server/migrations/20170729215619-emoji.js b/server/migrations/20170729215619-emoji.js index 492a4b2e..2dbb49da 100644 --- a/server/migrations/20170729215619-emoji.js +++ b/server/migrations/20170729215619-emoji.js @@ -1,12 +1,12 @@ module.exports = { - up: (queryInterface, Sequelize) => { - queryInterface.addColumn('documents', 'emoji', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('documents', 'emoji', { type: Sequelize.STRING, allowNull: true, }); }, - down: (queryInterface, _Sequelize) => { - queryInterface.removeColumn('documents', 'emoji'); + down: async (queryInterface, _Sequelize) => { + await queryInterface.removeColumn('documents', 'emoji'); }, }; diff --git a/server/migrations/20170827182423-improve-references.js b/server/migrations/20170827182423-improve-references.js index 788f3b60..01ce0043 100644 --- a/server/migrations/20170827182423-improve-references.js +++ b/server/migrations/20170827182423-improve-references.js @@ -1,5 +1,5 @@ module.exports = { - up: async function(queryInterface, Sequelize) { + up: async (queryInterface, Sequelize) => { await queryInterface.changeColumn('documents', 'atlasId', { type: Sequelize.UUID, allowNull: true, @@ -32,7 +32,7 @@ module.exports = { }); }, - down: async function(queryInterface, Sequelize) { + down: async (queryInterface, Sequelize) => { await queryInterface.sequelize.query( 'ALTER TABLE documents DROP CONSTRAINT "atlasId_foreign_idx";' ); diff --git a/server/migrations/20170904202454-allow-null-username.js b/server/migrations/20170904202454-allow-null-username.js index 399dc4e8..0bd5d599 100644 --- a/server/migrations/20170904202454-allow-null-username.js +++ b/server/migrations/20170904202454-allow-null-username.js @@ -1,12 +1,12 @@ module.exports = { - up: async function(queryInterface, Sequelize) { + up: async (queryInterface, Sequelize) => { await queryInterface.changeColumn('users', 'username', { type: Sequelize.STRING, allowNull: true, }); }, - down: async function(queryInterface, Sequelize) { + down: async (queryInterface, Sequelize) => { await queryInterface.changeColumn('users', 'username', { type: Sequelize.STRING, allowNull: false, diff --git a/server/migrations/20171010042938-add-event.js b/server/migrations/20171010042938-add-event.js index 60874fbc..c38b577c 100644 --- a/server/migrations/20171010042938-add-event.js +++ b/server/migrations/20171010042938-add-event.js @@ -1,6 +1,6 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.createTable('events', { + up: async (queryInterface, Sequelize) => { + await queryInterface.createTable('events', { id: { type: Sequelize.UUID, allowNull: false, @@ -46,7 +46,7 @@ module.exports = { }); }, - down: function(queryInterface, Sequelize) { - queryInterface.dropTable('events'); + down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('events'); }, }; diff --git a/server/migrations/20171016012353-remove-collection-navigationtree.js b/server/migrations/20171016012353-remove-collection-navigationtree.js index 0ba1eb4c..a53c2aa1 100644 --- a/server/migrations/20171016012353-remove-collection-navigationtree.js +++ b/server/migrations/20171016012353-remove-collection-navigationtree.js @@ -1,10 +1,10 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.removeColumn('collections', 'navigationTree'); + up: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('collections', 'navigationTree'); }, - down: function(queryInterface, Sequelize) { - queryInterface.addColumn('collections', 'navigationTree', { + down: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('collections', 'navigationTree', { type: Sequelize.JSONB, allowNull: true, }); diff --git a/server/migrations/20171017055026-remove-document-html.js b/server/migrations/20171017055026-remove-document-html.js index b9cdd821..8fec2009 100644 --- a/server/migrations/20171017055026-remove-document-html.js +++ b/server/migrations/20171017055026-remove-document-html.js @@ -1,22 +1,22 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.removeColumn('documents', 'html'); - queryInterface.removeColumn('documents', 'preview'); - queryInterface.removeColumn('revisions', 'html'); - queryInterface.removeColumn('revisions', 'preview'); + up: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('documents', 'html'); + await queryInterface.removeColumn('documents', 'preview'); + await queryInterface.removeColumn('revisions', 'html'); + await queryInterface.removeColumn('revisions', 'preview'); }, - down: function(queryInterface, Sequelize) { - queryInterface.addColumn('documents', 'html', { + down: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('documents', 'html', { type: Sequelize.TEXT, }); - queryInterface.addColumn('documents', 'preview', { + await queryInterface.addColumn('documents', 'preview', { type: Sequelize.TEXT, }); - queryInterface.addColumn('revisions', 'html', { + await queryInterface.addColumn('revisions', 'html', { type: Sequelize.TEXT, }); - queryInterface.addColumn('revisions', 'preview', { + await queryInterface.addColumn('revisions', 'preview', { type: Sequelize.TEXT, }); }, diff --git a/server/migrations/20171019071915-user-avatar-url.js b/server/migrations/20171019071915-user-avatar-url.js index 5be75d52..1f6370d3 100644 --- a/server/migrations/20171019071915-user-avatar-url.js +++ b/server/migrations/20171019071915-user-avatar-url.js @@ -1,12 +1,12 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('users', 'avatarUrl', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('users', 'avatarUrl', { type: Sequelize.TEXT, allowNull: true, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('users', 'avatarUrl'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('users', 'avatarUrl'); }, }; diff --git a/server/migrations/20171023064220-collection-color.js b/server/migrations/20171023064220-collection-color.js index b67a8b51..15e8016f 100644 --- a/server/migrations/20171023064220-collection-color.js +++ b/server/migrations/20171023064220-collection-color.js @@ -1,11 +1,11 @@ module.exports = { - up: function(queryInterface, Sequelize) { - queryInterface.addColumn('collections', 'color', { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn('collections', 'color', { type: Sequelize.TEXT, }); }, - down: function(queryInterface, Sequelize) { - queryInterface.removeColumn('collections', 'color'); + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn('collections', 'color'); }, };