这是indexloc提供的服务,不要输入任何密码
Skip to content
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
11 changes: 9 additions & 2 deletions console/src/components/Services/Data/RawSQL/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import returnMigrateUrl from '../Common/getMigrateUrl';

const MAKING_REQUEST = 'RawSQL/MAKING_REQUEST';
const SET_SQL = 'RawSQL/SET_SQL';
const SET_CASCADE_CHECKED = 'RawSQL/SET_CASCADE_CHECKED';
const SET_MIGRATION_CHECKED = 'RawSQL/SET_MIGRATION_CHECKED';
const SET_TRACK_TABLE_CHECKED = 'RawSQL/SET_TRACK_TABLE_CHECKED';
const REQUEST_SUCCESS = 'RawSQL/REQUEST_SUCCESS';
Expand All @@ -34,19 +35,20 @@ const executeSQL = isMigration => (dispatch, getState) => {

const migrateUrl = returnMigrateUrl(currMigrationMode);
const currentSchema = getState().tables.currentSchema;
const isCascadeChecked = getState().rawSQL.isCascadeChecked;

let url = Endpoints.rawSQL;
let requestBody = {
type: 'run_sql',
args: { sql },
args: { sql: sql, cascade: isCascadeChecked },
};
// check if its a migration and send to hasuractl migrate
if (isMigration) {
url = migrateUrl;
const schemaChangesUp = [
{
type: 'run_sql',
args: { sql },
args: { sql: sql, cascade: isCascadeChecked },
},
];
// check if track view enabled
Expand Down Expand Up @@ -138,6 +140,8 @@ const executeSQL = isMigration => (dispatch, getState) => {
} else {
parsedErrorMsg.message = { error: parsedErrorMsg.error };
}
} else if (parsedErrorMsg.code === 'dependency-error') {
parsedErrorMsg.message = errorMsg.error;
}
dispatch(
showErrorNotification(
Expand Down Expand Up @@ -181,6 +185,8 @@ const rawSQLReducer = (state = defaultState, action) => {
return { ...state, sql: action.data };
case SET_MIGRATION_CHECKED:
return { ...state, isMigrationChecked: action.data };
case SET_CASCADE_CHECKED:
return { ...state, isCascadeChecked: action.data };
case SET_TRACK_TABLE_CHECKED:
return {
...state,
Expand Down Expand Up @@ -234,6 +240,7 @@ export default rawSQLReducer;
export {
executeSQL,
SET_SQL,
SET_CASCADE_CHECKED,
SET_MIGRATION_CHECKED,
SET_TRACK_TABLE_CHECKED,
modalOpen,
Expand Down
33 changes: 32 additions & 1 deletion console/src/components/Services/Data/RawSQL/RawSQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ import Tooltip from 'react-bootstrap/lib/Tooltip';
import {
executeSQL,
SET_SQL,
SET_CASCADE_CHECKED,
SET_MIGRATION_CHECKED,
SET_TRACK_TABLE_CHECKED,
} from './Actions';
import { modalOpen, modalClose } from './Actions';
import globals from '../../../../Globals';

const cascadeTip = (
<Tooltip id="tooltip-cascade">
Cascade all the dependent metadata references like relationships and
permissions.
</Tooltip>
);
const migrationTip = (
<Tooltip id="tooltip-migration">
Modifications to the underlying postgres schema should be tracked as
Expand All @@ -41,6 +48,7 @@ const RawSQL = ({
lastError,
lastSuccess,
isModalOpen,
isCascadeChecked,
isMigrationChecked,
isTableTrackChecked,
migrationMode,
Expand Down Expand Up @@ -194,6 +202,27 @@ const RawSQL = ({
}}
/>
<hr />
<div>
<input
checked={isCascadeChecked}
className={styles.add_mar_right_small}
id="cascade-checkbox"
type="checkbox"
onChange={() => {
dispatch({
type: SET_CASCADE_CHECKED,
data: !isCascadeChecked,
});
}}
/>
Cascade relationships or permissions metadata
<OverlayTrigger placement="right" overlay={cascadeTip}>
<i
className={`${styles.padd_small_left} fa fa-info-circle`}
aria-hidden="true"
/>
</OverlayTrigger>
</div>
{migrationMode && globals.consoleMode === 'cli' ? (
<div>
<input
Expand Down Expand Up @@ -238,7 +267,9 @@ const RawSQL = ({
</div>
<hr />
</div>
) : null}
) : (
<hr />
)}
<button
type="submit"
className={styles.yellow_button}
Expand Down
2 changes: 1 addition & 1 deletion console/src/components/Services/Data/RawSQL/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const defaultState = {
ongoingRequest: false,
lastError: null,
lastSuccess: null,

resultType: null,
result: [],
resultHeaders: [],
isModalOpen: false,
isCascadeChecked: false,
isMigrationChecked: false,
isTableTrackChecked: false,
showTrackTable: false,
Expand Down