Skip to content

Commit

Permalink
EPMRPP-89414 || fix routing
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazarQSO committed Feb 15, 2024
1 parent efba73f commit d9ac5eb
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 42 deletions.
10 changes: 5 additions & 5 deletions app/src/common/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export const URLS = {
`${urlBase}${projectKey}/launch/compare${getQueryParams({ ids })}`,

launchImport: (projectKey) => `${urlBase}${projectKey}/launch/import`,
exportLaunch: (projectId, launchId, exportType) =>
`${urlBase}${projectId}/launch/${launchId}/report${getQueryParams({
exportLaunch: (projectKey, launchId, exportType) =>
`${urlBase}${projectKey}/launch/${launchId}/report${getQueryParams({
view: exportType,
})}`,
launchAnalyze: (projectKey) => `${urlBase}${projectKey}/launch/analyze`,
Expand Down Expand Up @@ -246,9 +246,9 @@ export const URLS = {
userInviteExternal: () => `${urlCommonBase}users/bid`,
userUnassign: (projectKey) => `${urlBase}project/${projectKey}/unassign`,

generateDemoData: (projectId) => `${urlBase}demo/${projectId}/generate`,
getFileById: (projectId, dataId, loadThumbnail) =>
`${urlBase}data/${projectId}/${dataId}${getQueryParams({ loadThumbnail })}`,
generateDemoData: (projectKey) => `${urlBase}demo/${projectKey}/generate`,
getFileById: (projectKey, dataId, loadThumbnail) =>
`${urlBase}data/${projectKey}/${dataId}${getQueryParams({ loadThumbnail })}`,

authSettings: (authTypeOrId, id = '') => `${uatBase}settings/auth/${authTypeOrId}/${id}`,
githubAuthSettings: () => `${uatBase}settings/oauth/github`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { injectIntl, defineMessages } from 'react-intl';
import { activeProjectSelector } from 'controllers/user';
import classNames from 'classnames/bind';
import { PatternNameColumn, TestCasesColumn } from './patternGridColumns';
import styles from './patternGrid.scss';
Expand All @@ -43,16 +41,12 @@ const messages = defineMessages({
const PATTERN_NAME_COLUMN = 'pattern';
const TEST_CASES_COLUMN = 'testCases';

@connect((state) => ({
projectId: activeProjectSelector(state),
}))
@injectIntl
export class PatternGrid extends Component {
static propTypes = {
intl: PropTypes.object.isRequired,
widget: PropTypes.object,
selectedAttribute: PropTypes.string,
projectId: PropTypes.string,
onPatternClick: PropTypes.func,
};

Expand All @@ -73,7 +67,6 @@ export class PatternGrid extends Component {
},
},
selectedAttribute: null,
projectId: '',
onPatternClick: () => {},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ import Link from 'redux-first-router-link';
import PropTypes from 'prop-types';
import { ALL } from 'common/constants/reservedFilterIds';
import { PROJECT_LOG_PAGE } from 'controllers/pages';
import { activeProjectSelector } from 'controllers/user';
import { projectKeySelector, projectOrganizationSlugSelector } from 'controllers/project';
import { AttributesBlock } from 'pages/inside/common/itemInfo/attributesBlock';
import styles from './foundIn.scss';

export const cx = classNames.bind(styles);

@connect((state) => ({
projectId: activeProjectSelector(state),
projectKey: projectKeySelector(state),
organizationSlug: projectOrganizationSlugSelector(state),
}))
export class FoundIn extends Component {
static propTypes = {
projectId: PropTypes.string.isRequired,
projectKey: PropTypes.string.isRequired,
organizationSlug: PropTypes.string.isRequired,
className: PropTypes.string.isRequired,
items: PropTypes.array,
};
Expand All @@ -42,14 +44,16 @@ export class FoundIn extends Component {
};

getItemFragment = (item) => {
const { organizationSlug, projectKey } = this.props;
const pathToItem = item.path || '';
const path = `${item.launchId}/${pathToItem.replace(/\./g, '/')}`;
const link = {
type: PROJECT_LOG_PAGE,
payload: {
projectId: this.props.projectId,
projectKey,
filterId: ALL,
testItemIds: path,
organizationSlug,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { URLS } from 'common/urls';
import { arrayRemoveDoubles } from 'common/utils/arrayRemoveDoubles';
import { validate, bindMessageToValidator, commonValidators } from 'common/utils/validation';
import { GROUP_TO_ACTION_MAP, ACTION_TO_GROUP_MAP } from 'common/constants/actionTypes';
import { activeProjectSelector } from 'controllers/user';
import { projectKeySelector } from 'controllers/project';
import { getWidgetCriteriaOptions } from './utils/getWidgetCriteriaOptions';
import { USER_ACTIONS_OPTIONS, ITEMS_INPUT_WIDTH, CONTENT_FIELDS } from './constants';
import { DropdownControl, InputControl, TagsControl } from './controls';
Expand Down Expand Up @@ -60,13 +60,13 @@ const actionTypeValidator = (message) => bindMessageToValidator(validate.isNotEm

@injectIntl
@connect((state) => ({
activeProject: activeProjectSelector(state),
projectKey: projectKeySelector(state),
}))
export class ProjectActivityControls extends Component {
static propTypes = {
intl: PropTypes.object.isRequired,
widgetSettings: PropTypes.object.isRequired,
activeProject: PropTypes.string.isRequired,
projectKey: PropTypes.string.isRequired,
initializeControlsForm: PropTypes.func.isRequired,
};

Expand Down Expand Up @@ -126,7 +126,7 @@ export class ProjectActivityControls extends Component {
render() {
const {
intl: { formatMessage },
activeProject,
projectKey,
} = this.props;

return (
Expand Down Expand Up @@ -168,7 +168,7 @@ export class ProjectActivityControls extends Component {
placeholder={formatMessage(messages.UsersPlaceholder)}
minLength={3}
maxLength={256}
getURI={URLS.projectUsernamesSearch(activeProject)}
getURI={URLS.projectUsernamesSearch(projectKey)}
makeOptions={this.formatUsernames}
multi
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { injectIntl, defineMessages } from 'react-intl';
import { destroy, getFormValues, isDirty, isValid } from 'redux-form';
import { URLS } from 'common/urls';
import { fetch } from 'common/utils';
import { activeProjectSelector } from 'controllers/user';
import { withModal, ModalLayout } from 'components/main/modal';
import { COMMON_LOCALE_KEYS } from 'common/constants/localization';
import { showScreenLockAction, hideScreenLockAction } from 'controllers/screenLock';
Expand Down Expand Up @@ -55,7 +54,6 @@ const messages = defineMessages({
@withModal('editWidgetModal')
@connect(
(state) => ({
projectId: activeProjectSelector(state),
widgetSettings: getFormValues(WIDGET_WIZARD_FORM)(state),
dirty: isDirty(WIDGET_WIZARD_FORM)(state),
valid: isValid(WIDGET_WIZARD_FORM)(state),
Expand Down Expand Up @@ -85,7 +83,6 @@ export class EditWidgetModal extends Component {
widget: PropTypes.object,
eventsInfo: PropTypes.object,
}),
projectId: PropTypes.string,
tracking: PropTypes.shape({
trackEvent: PropTypes.func,
getTrackingData: PropTypes.func,
Expand All @@ -99,7 +96,6 @@ export class EditWidgetModal extends Component {
widget: {},
},
widgetSettings: {},
projectId: '',
};

constructor(props) {
Expand Down Expand Up @@ -222,7 +218,7 @@ export class EditWidgetModal extends Component {
const {
intl: { formatMessage },
data: { widget, eventsInfo },
projectId,
projectKey,
widgetSettings,
valid,
} = this.props;
Expand Down Expand Up @@ -254,7 +250,7 @@ export class EditWidgetModal extends Component {
>
<div className={cx('edit-widget-modal-content')}>
<EditWidgetInfoSection
projectId={projectId}
projectKey={projectKey}
widgetSettings={prepareWidgetDataForSubmit(this.preprocessOutputData(widgetSettings))}
activeWidget={this.widgetInfo}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Parser from 'html-react-parser';
import { connect } from 'react-redux';
import AttachIcon from 'common/img/attachment-inline.svg';
import { Image } from 'components/main/image';
import { activeProjectSelector } from 'controllers/user';
import { projectKeySelector } from 'controllers/project';
import { LOG_PAGE_EVENTS } from 'components/main/analytics/events';
import {
openAttachmentInModalAction,
Expand All @@ -38,7 +38,7 @@ const cx = classNames.bind(styles);

@connect(
(state) => ({
activeProject: activeProjectSelector(state),
projectKey: projectKeySelector(state),
}),
{
openAttachmentInModalAction,
Expand All @@ -52,18 +52,17 @@ export class AttachmentBlock extends Component {
customProps: PropTypes.object,
openAttachmentInModalAction: PropTypes.func,
downloadAttachmentAction: PropTypes.func,
activeProject: PropTypes.string,
tracking: PropTypes.shape({
trackEvent: PropTypes.func,
getTrackingData: PropTypes.func,
}).isRequired,
projectKey: PropTypes.string.isRequired,
};

static defaultProps = {
value: {},
customProps: {},
openAttachmentInModalAction: () => {},
activeProject: '',
};

openAttachmentInModal = () => {
Expand All @@ -80,7 +79,7 @@ export class AttachmentBlock extends Component {
const {
value,
customProps: { consoleView },
activeProject,
projectKey,
} = this.props;
const isValidToOpenInModal = isFileActionAllowed(
value.contentType,
Expand All @@ -97,7 +96,7 @@ export class AttachmentBlock extends Component {
<Fragment>
<Image
className={cx('attachment')}
src={getFileIconSource(value, activeProject, true)}
src={getFileIconSource(value, projectKey, true)}
alt={value.contentType}
onClick={isValidToOpenInModal ? this.openAttachmentInModal : null}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { defineMessages, useIntl } from 'react-intl';
import { projectIdSelector } from 'controllers/pages';
import { activeProjectSelector } from 'controllers/user';
import { activeProjectKeySelector } from 'controllers/user';
import { urlProjectKeySelector } from 'controllers/pages';
import { URLS } from 'common/urls';
import { fetch } from 'common/utils';
import Parser from 'html-react-parser';
Expand Down Expand Up @@ -45,12 +45,12 @@ export const IntegrationCollectionItem = ({
item,
}) => {
const [connected, setConnected] = useState(true);
const projectId = useSelector(projectIdSelector);
const activeProject = useSelector(activeProjectSelector);
const projectKey = useSelector(activeProjectKeySelector);
const payloadProjectKey = useSelector(urlProjectKeySelector);
const { formatMessage } = useIntl();

useEffect(() => {
fetch(URLS.testIntegrationConnection(projectId || activeProject, id))
fetch(URLS.testIntegrationConnection(projectKey || payloadProjectKey, id))
.then(() => {
setConnected(true);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ export class TestItemDetailsModal extends Component {
];
};

testItemAttributeKeyURLCreator = (projectId) => {
testItemAttributeKeyURLCreator = (projectKey) => {
const {
data: { item },
} = this.props;
return URLS.testItemAttributeKeysSearch(projectId, item.launchId || item.id);
return URLS.testItemAttributeKeysSearch(projectKey, item.launchId || item.id);
};

testItemAttributeValueURLCreator = (projectId, key) => {
testItemAttributeValueURLCreator = (projectKey, key) => {
const {
data: { item },
} = this.props;
return URLS.testItemAttributeValuesSearch(projectId, item.launchId || item.id, key);
return URLS.testItemAttributeValuesSearch(projectKey, item.launchId || item.id, key);
};

updateItemAndCloseModal = (closeModal) => (formData) => {
Expand Down

0 comments on commit d9ac5eb

Please sign in to comment.