Skip to content

Commit

Permalink
enable add/modify/delete for event triggers and remote schemas in dis…
Browse files Browse the repository at this point in the history
…abled migration mode (fix #1875) (#2366)
  • Loading branch information
AnnieAtHasura authored and rikinsk committed Jun 13, 2019
1 parent 938921e commit 034c550
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LeftSubSidebar extends React.Component {
const styles = require('./LeftSubSidebar.scss');

const {
migrationMode,
showAddBtn,
searchInput,
heading,
addLink,
Expand All @@ -21,7 +21,7 @@ class LeftSubSidebar extends React.Component {
const getAddButton = () => {
let addButton = null;

if (migrationMode) {
if (showAddBtn) {
addButton = (
<div
className={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const leftNavMapStateToProps = state => {
filtered: [...state.customResolverData.listData.filtered],
searchQuery: state.customResolverData.listData.searchQuery,
viewResolver: state.customResolverData.listData.viewResolver,
migrationMode: state.main.migrationMode ? state.main.migrationMode : false,
appPrefix,
};
};
Expand Down Expand Up @@ -84,15 +83,6 @@ const fetchInitialData = ({ dispatch }) => {
};

const getCustomResolverRouter = (connect, store, composeOnEnterHooks) => {
const migrationRedirects = (nextState, replaceState, cb) => {
const state = store.getState();
if (!state.main.migrationMode) {
replaceState(globals.urlPrefix + appPrefix + '/manage');
cb();
}
cb();
};

return (
<Route
path="remote-schemas"
Expand All @@ -108,11 +98,7 @@ const getCustomResolverRouter = (connect, store, composeOnEnterHooks) => {
<Route path="manage" component={rightContainerConnector(connect)}>
<IndexRedirect to="schemas" />
<Route path="schemas" component={landingConnector(connect)} />
<Route
path="add"
component={addConnector(connect)}
onEnter={composeOnEnterHooks([migrationRedirects])}
/>
<Route path="add" component={addConnector(connect)} />
<Route
path=":resolverName/details"
component={viewConnector(connect)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const CustomResolverSubSidebar = ({
location,
filterItem,
viewResolver,
migrationMode,
}) => {
const styles = require('../../Common/Layout/LeftSubSidebar/LeftSubSidebar.scss');

Expand Down Expand Up @@ -81,7 +80,7 @@ const CustomResolverSubSidebar = ({

return (
<LeftSubSidebar
migrationMode={migrationMode}
showAddBtn
searchInput={getSearchInput()}
heading={`Remote Schemas (${dataList.length})`}
addLink={`${appPrefix}/manage/add`}
Expand Down
5 changes: 2 additions & 3 deletions console/src/components/Services/CustomResolver/Edit/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Edit extends React.Component {
render() {
const styles = require('../CustomResolver.scss');

const { isFetching, isRequesting, editState, migrationMode } = this.props;
const { isFetching, isRequesting, editState } = this.props;
const { resolverName } = this.props.params;

const generateMigrateBtns = () => {
Expand Down Expand Up @@ -223,7 +223,7 @@ class Edit extends React.Component {
}}
>
<Common {...this.props} />
{migrationMode ? generateMigrateBtns() : null}
{generateMigrateBtns()}
</form>
)}
</div>
Expand All @@ -234,7 +234,6 @@ const mapStateToProps = state => {
return {
...state.customResolverData.addData,
...state.customResolverData.headerData,
migrationMode: state.main.migrationMode,
dataHeaders: { ...state.tables.dataHeaders },
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CustomResolver extends React.Component {
render() {
const styles = require('../CustomResolver.scss');

const { dispatch, migrationMode, customResolverList } = this.props;
const { dispatch, customResolverList } = this.props;
const showIntroSection = !customResolverList.resolvers.length;
const getIntroSection = () => {
if (!showIntroSection) {
Expand All @@ -35,25 +35,22 @@ class CustomResolver extends React.Component {
const getAddBtn = () => {
let addBtn = null;

if (migrationMode) {
const handleClick = e => {
e.preventDefault();
const handleClick = e => {
e.preventDefault();
dispatch(push(`${globals.urlPrefix}${appPrefix}/manage/add`));
};

dispatch(push(`${globals.urlPrefix}${appPrefix}/manage/add`));
};

addBtn = (
<Button
data-test="data-create-remote-schemas"
color="yellow"
size="sm"
className={styles.add_mar_left}
onClick={handleClick}
>
Add
</Button>
);
}
addBtn = (
<Button
data-test="data-create-remote-schemas"
color="yellow"
size="sm"
className={styles.add_mar_left}
onClick={handleClick}
>
Add
</Button>
);

return addBtn;
};
Expand Down Expand Up @@ -98,7 +95,6 @@ class CustomResolver extends React.Component {

const mapStateToProps = state => {
return {
migrationMode: state.main.migrationMode,
customResolverList: state.customResolverData.listData,
};
};
Expand Down
2 changes: 1 addition & 1 deletion console/src/components/Services/Data/DataSubSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class DataSubSidebar extends React.Component {

return (
<LeftSubSidebar
migrationMode={migrationMode}
showAddBtn={migrationMode}
searchInput={getSearchInput()}
heading={`Tables (${trackedTablesLength})`}
addLink={'/data/schema/' + currentSchema + '/table/add'}
Expand Down
29 changes: 2 additions & 27 deletions console/src/components/Services/EventTrigger/EventRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ import {
loadRunningEvents,
} from '../EventTrigger/EventActions';

import { SERVER_CONSOLE_MODE } from '../../../constants';

const makeEventRouter = (
connect,
store,
composeOnEnterHooks,
requireSchema,
requirePendingEvents,
requireRunningEvents,
migrationRedirects
requireRunningEvents
) => {
return (
<Route
Expand Down Expand Up @@ -64,12 +61,10 @@ const makeEventRouter = (
</Route>
<Route
path="manage/triggers/add"
onEnter={composeOnEnterHooks([migrationRedirects])}
component={addTriggerConnector(connect)}
/>
<Route
path="manage/triggers/:trigger/modify"
onEnter={composeOnEnterHooks([migrationRedirects])}
component={modifyTriggerConnector(connect)}
/>
</Route>
Expand Down Expand Up @@ -148,36 +143,16 @@ const eventRouterUtils = (connect, store, composeOnEnterHooks) => {
);
};

const migrationRedirects = (nextState, replaceState, cb) => {
const state = store.getState();
if (!state.main.migrationMode) {
replaceState(globals.urlPrefix + '/events/manage');
cb();
}
cb();
};

const consoleModeRedirects = (nextState, replaceState, cb) => {
if (globals.consoleMode === SERVER_CONSOLE_MODE) {
replaceState(globals.urlPrefix + '/events/manage');
cb();
}
cb();
};

return {
makeEventRouter: makeEventRouter(
connect,
store,
composeOnEnterHooks,
requireSchema,
requirePendingEvents,
requireRunningEvents,
migrationRedirects,
consoleModeRedirects
requireRunningEvents
),
requireSchema,
migrationRedirects,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const EventSubSidebar = ({
currentTrigger,
triggerList,
listingTrigger,
migrationMode,
// children,
dispatch,
location,
Expand Down Expand Up @@ -93,7 +92,7 @@ const EventSubSidebar = ({

return (
<LeftSubSidebar
migrationMode={migrationMode}
showAddBtn
searchInput={getSearchInput()}
heading={`Event Triggers (${triggerList.length})`}
addLink={'/events/manage/triggers/add'}
Expand All @@ -111,7 +110,6 @@ const mapStateToProps = state => {
currentTrigger: state.triggers.currentTrigger,
triggerList: state.triggers.triggerList,
listingTrigger: state.triggers.listingTrigger,
migrationMode: state.main.migrationMode,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EventTrigger extends Component {
}

render() {
const { migrationMode, dispatch, listingTrigger } = this.props;
const { dispatch, listingTrigger } = this.props;

const styles = require('../../../Common/Layout/LeftSubSidebar/LeftSubSidebar.scss');

Expand Down Expand Up @@ -52,29 +52,23 @@ class EventTrigger extends Component {
};

const getAddBtn = () => {
let addBtn = null;

if (migrationMode) {
const handleClick = e => {
e.preventDefault();

dispatch(push(`${appPrefix}/manage/triggers/add`));
};

addBtn = (
<Button
data-test="data-create-trigger"
color="yellow"
size="sm"
className={styles.add_mar_left}
onClick={handleClick}
>
Create
</Button>
);
}
const handleClick = e => {
e.preventDefault();

dispatch(push(`${appPrefix}/manage/triggers/add`));
};

return addBtn;
return (
<Button
data-test="data-create-trigger"
color="yellow"
size="sm"
className={styles.add_mar_left}
onClick={handleClick}
>
Create
</Button>
);
};

const footerEvent = (
Expand Down Expand Up @@ -123,15 +117,13 @@ class EventTrigger extends Component {
EventTrigger.propTypes = {
schema: PropTypes.array.isRequired,
untrackedRelations: PropTypes.array.isRequired,
migrationMode: PropTypes.bool.isRequired,
currentSchema: PropTypes.string.isRequired,
dispatch: PropTypes.func.isRequired,
};

const mapStateToProps = state => ({
schema: state.tables.allSchemas,
schemaList: state.tables.schemaList,
migrationMode: state.main.migrationMode,
untrackedRelations: state.tables.untrackedRelations,
currentSchema: state.tables.currentSchema,
listingTrigger: state.triggers.listingTrigger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const mapStateToProps = (state, ownProps) => {
schemaList: state.tables.schemaList,
allSchemas: state.tables.allSchemas,
serverVersion: state.main.serverVersion,
migrationMode: state.main.migrationMode,
currentSchema: state.tables.currentSchema,
};
};
Expand Down
2 changes: 0 additions & 2 deletions console/src/components/Services/EventTrigger/Modify/Modify.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Modify extends React.Component {
modifyTriggerName,
modifyTrigger,
triggerList,
migrationMode,
dispatch,
} = this.props;

Expand All @@ -59,7 +58,6 @@ class Modify extends React.Component {
dispatch={dispatch}
triggerName={modifyTriggerName}
tabName="modify"
migrationMode={migrationMode}
/>
<br />
<div className={styles.container}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class ViewTable extends Component {
rows,
count, // eslint-disable-line no-unused-vars
activePath,
migrationMode,
ongoingRequest,
lastError,
lastSuccess,
Expand Down Expand Up @@ -168,7 +167,6 @@ class ViewTable extends Component {
dispatch={dispatch}
triggerName={triggerName}
tabName="pending"
migrationMode={migrationMode}
/>
);

Expand All @@ -187,7 +185,6 @@ ViewTable.propTypes = {
activePath: PropTypes.array.isRequired,
query: PropTypes.object.isRequired,
curFilter: PropTypes.object.isRequired,
migrationMode: PropTypes.bool.isRequired,
ongoingRequest: PropTypes.bool.isRequired,
rows: PropTypes.array.isRequired,
expandedRow: PropTypes.string.isRequired,
Expand All @@ -201,7 +198,6 @@ const mapStateToProps = (state, ownProps) => {
return {
triggerName: ownProps.params.trigger,
triggerList: state.triggers.pendingEvents,
migrationMode: state.main.migrationMode,
...state.triggers.view,
};
};
Expand Down

0 comments on commit 034c550

Please sign in to comment.