Merge branch 'layout-refactor' into collection-home

This commit is contained in:
Tom Moor 2017-11-19 18:09:17 -08:00
commit b0b76aab70
41 changed files with 326 additions and 376 deletions

View File

@ -8,7 +8,7 @@ type Props = {
const Container = styled.div`
width: 100%;
margin: 60px 20px;
margin: 60px;
`;
const Content = styled.div`

View File

@ -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<any>,
actions?: ?React.Element<any>,
@ -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 (
<Container column auto>
@ -116,44 +84,7 @@ class Layout extends React.Component {
{this.props.notifications}
<Flex auto>
{auth.authenticated &&
user &&
team && (
<Sidebar column editMode={ui.editMode}>
<AccountMenu
label={
<HeaderBlock user={user} team={team}>
<Avatar src={user.avatarUrl} />
</HeaderBlock>
}
/>
<Flex auto column>
<Scrollable innerRef={this.setScrollableRef}>
<LinkSection>
<SidebarLink to="/dashboard" icon={<HomeIcon />}>
Home
</SidebarLink>
<SidebarLink to="/search" icon={<SearchIcon />}>
Search
</SidebarLink>
<SidebarLink to="/starred" icon={<StarredIcon />}>
Starred
</SidebarLink>
</LinkSection>
<LinkSection>
<SidebarCollections
history={this.props.history}
location={this.props.location}
activeDocument={documents.active}
onCreateCollection={this.handleCreateCollection}
activeDocumentRef={this.scrollToActiveDocument}
/>
</LinkSection>
</Scrollable>
</Flex>
</Sidebar>
)}
{showSidebar && <Sidebar />}
<Content auto justify="center" editMode={ui.editMode}>
{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));

View File

@ -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 (
<span>
{title && <span>&nbsp;/&nbsp;</span>}
<TitleText title={this.props.content} untitled={usePlaceholder}>
{title}
</TitleText>
</span>
);
}
}
const TitleText = styled.span`
opacity: ${props => (props.untitled ? 0.5 : 1)};
`;
export default Title;

View File

@ -1,7 +1,3 @@
// @flow
import Layout from './Layout';
import Title from './components/Title';
export default Layout;
export { Title };

View File

@ -0,0 +1,3 @@
// @flow
import Modals from './Modals';
export default Modals;

View File

@ -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 (
<Container column editMode={ui.editMode}>
<AccountMenu
label={
<HeaderBlock user={user} team={team}>
<Avatar src={user.avatarUrl} />
</HeaderBlock>
}
/>
<Flex auto column>
<Scrollable innerRef={this.setScrollableRef}>
<Section>
<SidebarLink to="/dashboard" icon={<HomeIcon />}>
Home
</SidebarLink>
<SidebarLink to="/search" icon={<SearchIcon />}>
Search
</SidebarLink>
<SidebarLink to="/starred" icon={<StarredIcon />}>
Starred
</SidebarLink>
</Section>
<Section>
<Collections
history={this.props.history}
location={this.props.location}
onCreateCollection={this.handleCreateCollection}
activeDocumentRef={this.scrollToActiveDocument}
/>
</Section>
</Scrollable>
</Flex>
</Container>
);
}
}
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));

View File

@ -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);

View File

@ -0,0 +1,3 @@
// @flow
import Sidebar from './Sidebar';
export default Sidebar;

View File

@ -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();
},
};

View File

@ -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');
},
};

View File

@ -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']);
},
};

View File

@ -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');
},
};

View File

@ -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?
},
};

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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']);
},
};

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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']);
},
};

View File

@ -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');
},
};

View File

@ -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']);
},
};

View File

@ -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,

View File

@ -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,

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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,

View File

@ -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');
},
};

View File

@ -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');
},
};

View File

@ -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";'
);

View File

@ -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,

View File

@ -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');
},
};

View File

@ -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,
});

View File

@ -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,
});
},

View File

@ -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');
},
};

View File

@ -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');
},
};