Skip to content
Open
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
27 changes: 27 additions & 0 deletions app/cdap/api/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

import DataSourceConfigurer from 'services/datasource/DataSourceConfigurer';
import { apiCreator } from 'services/resource-helper';

const dataSrc = DataSourceConfigurer.getInstance();
const basePath = '/namespaces/:namespace/configuration';
const userSettingsPath = `${basePath}/user`;

export const SettingsApi = {
getUserSettings: apiCreator(dataSrc, 'GET', 'REQUEST', `${userSettingsPath}`),
updateUserSettings: apiCreator(dataSrc, 'PUT', 'REQUEST', `${userSettingsPath}`),
};
74 changes: 74 additions & 0 deletions app/cdap/components/StudioV2/store/common/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

import { MyArtifactApi } from 'api/artifact';
import { IArtifactSummary, ILabeledArtifactSummary } from 'components/StudioV2/types';
import { getArtifactDisaplayName } from 'components/StudioV2/utils/artifactUtils';
import { getCurrentNamespace } from 'services/NamespaceStore';
import { Theme } from 'services/ThemeHelper';
import VersionStore from 'services/VersionStore';
import { GLOBALS } from 'services/global-constants';
import StudioV2Store from '..';

const PREFIX = 'COMMON_ACTIONS';

export const CommonActions = {
SET_ARTIFACTS: `${PREFIX}/SET_ARTIFACTS`,
SET_SELECTED_ARTIFACT: `${PREFIX}/SET_SELECTED_ARTIFACT`,
};

export const fetchSystemArtifacts = () => {
const cdapVersion = VersionStore.getState().version;
const namespace = getCurrentNamespace();

const uiSupportedArtifacts = [GLOBALS.etlDataPipeline];
if (Theme.showRealtimePipeline !== false) {
uiSupportedArtifacts.push(GLOBALS.etlDataStreams);
}
if (Theme.showSqlPipeline !== false) {
uiSupportedArtifacts.push(GLOBALS.eltSqlPipeline);
}

MyArtifactApi.listScopedArtifacts({
namespace,
scope: 'SYSTEM',
}).subscribe((res: IArtifactSummary[]) => {
if (!res.length) {
return;
}

const filteredArtifacts = res.filter(
(artifact) => artifact.version === cdapVersion && uiSupportedArtifacts.includes(artifact.name)
);

const labeledArtifacts = filteredArtifacts.map((artifact) => ({
...artifact,
label: getArtifactDisaplayName(artifact.name),
}));

StudioV2Store.dispatch({
type: CommonActions.SET_ARTIFACTS,
payload: labeledArtifacts,
});
});
};

export const setSelectedArtifact = (artifact: ILabeledArtifactSummary) => {
StudioV2Store.dispatch({
type: CommonActions.SET_SELECTED_ARTIFACT,
payload: artifact,
});
};
48 changes: 48 additions & 0 deletions app/cdap/components/StudioV2/store/common/reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

import { ILabeledArtifactSummary } from 'components/StudioV2/types';
import { getArtifactDisaplayName } from 'components/StudioV2/utils/artifactUtils';
import { GLOBALS } from 'services/global-constants';
import { CommonActions } from './actions';

interface ICommonState {
artifacts: ILabeledArtifactSummary[];
selectedArtifact: ILabeledArtifactSummary;
}

export const defaultSelectedArtifact: ILabeledArtifactSummary = {
name: GLOBALS.etlDataPipeline,
version: '',
scope: 'SYSTEM',
label: getArtifactDisaplayName(GLOBALS.etlDataPipeline),
};

export const commonDefaultInitialState: ICommonState = {
artifacts: [],
selectedArtifact: defaultSelectedArtifact,
};

export const common = (state: ICommonState = commonDefaultInitialState, action?): ICommonState => {
switch (action.type) {
case CommonActions.SET_ARTIFACTS:
return { ...state, artifacts: action.payload };
case CommonActions.SET_SELECTED_ARTIFACT:
return { ...state, selectedArtifact: action.payload };
default:
return state;
}
};
45 changes: 45 additions & 0 deletions app/cdap/components/StudioV2/store/console/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

import StudioV2Store from '..';

const PREFIX = 'CONSOLE_ACTIONS';

export const ConsoleActions = {
ADD_MESSAGE: `${PREFIX}/ADD_MESSAGE`,
ADD_MESSAGES: `${PREFIX}/ADD_MESSAGES`,
RESET: `${PREFIX}/RESET`,
};

export function resetConsoleMessages() {
StudioV2Store.dispatch({
type: ConsoleActions.RESET,
});
}

export function addConsoleMessage(payload) {
StudioV2Store.dispatch({
type: ConsoleActions.ADD_MESSAGE,
payload,
});
}

export function addConsoleMessages(payload) {
StudioV2Store.dispatch({
type: ConsoleActions.ADD_MESSAGES,
payload,
});
}
44 changes: 44 additions & 0 deletions app/cdap/components/StudioV2/store/console/reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

import { ConsoleActions } from './actions';

interface IConsoleState {
messages: any[];
}

export const consoleInitialState: IConsoleState = {
messages: [],
};

export const consoleReducer = (
state: IConsoleState = consoleInitialState,
action?
): IConsoleState => {
switch (action.type) {
case ConsoleActions.ADD_MESSAGE:
return { ...state, messages: [...state.messages, action.payload] };

case ConsoleActions.ADD_MESSAGES:
return { ...state, messages: action.payload };

case ConsoleActions.RESET:
return { ...consoleInitialState };

default:
return state;
}
};
41 changes: 41 additions & 0 deletions app/cdap/components/StudioV2/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

import { combineReducers, createStore } from 'redux';
import { common, commonDefaultInitialState } from './common/reducer';
import { consoleReducer, consoleInitialState } from './console/reducer';
import { plugins, pluginsInitialState } from './plugins/reducer';
import { nodes, nodesInitialState } from './nodes/reducer';

const defaultInitialState = {
common: commonDefaultInitialState,
console: consoleInitialState,
plugins: pluginsInitialState,
nodes: nodesInitialState,
};

const StudioV2Store = createStore(
combineReducers({
common,
console: consoleReducer,
plugins,
nodes,
}),
defaultInitialState,
(window as any).__REDUX_DEVTOOLS_EXTENSION__ && (window as any).__REDUX_DEVTOOLS_EXTENSION__()
);

export default StudioV2Store;
29 changes: 29 additions & 0 deletions app/cdap/components/StudioV2/store/nodes/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright © 2025 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

const PREFIX = 'NODES_ACTIONS';
export const NodesActions = {
RESET: `${PREFIX}/RESET`,
SET_STATE: `${PREFIX}/SET_STATE`,
UNDO_ACTIONS: `${PREFIX}/UNDO_ACTIONS`,
RESET_ACTIVE_NODE: `${PREFIX}/RESET_ACTIVE_NODE`,
ADD_NODE: `${PREFIX}/ADD_NODE`,
UPDATE_NODE: `${PREFIX}/UPDATE_NODE`,
ADD_CONNECTION: `${PREFIX}/ADD_CONNECTION`,
SET_ACTIVE_NODE: `${PREFIX}/SET_ACTIVE_NODE`,
REMOVE_PREVIOUS_STATE: `${PREFIX}/REMOVE_PREVIOUS_STATE`,
RESET_FUTURE_STATES: `${PREFIX}/RESET_FUTURE_STATES`,
};
Loading