@@ -110,7 +110,7 @@ export function searchIssueTags(data: { | |||
} | |||
export function getIssueChangelog(issue: string): Promise<any> { | |||
return getJSON('/api/issues/changelog', { issue }).then(r => r.changelog); | |||
return getJSON('/api/issues/changelog', { issue }).then(r => r.changelog, throwGlobalError); | |||
} | |||
export function getIssueFilters() { |
@@ -18,6 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { getJSON } from '../helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
export interface Language { | |||
key: string; | |||
@@ -25,5 +26,5 @@ export interface Language { | |||
} | |||
export function getLanguages(): Promise<Language[]> { | |||
return getJSON('/api/languages/list').then(r => r.languages); | |||
return getJSON('/api/languages/list').then(r => r.languages, throwGlobalError); | |||
} |
@@ -28,7 +28,7 @@ export function getOrganizations(data: { | |||
organizations: Organization[]; | |||
paging: Paging; | |||
}> { | |||
return getJSON('/api/organizations/search', data); | |||
return getJSON('/api/organizations/search', data).catch(throwGlobalError); | |||
} | |||
export function getOrganization(key: string): Promise<Organization | undefined> { | |||
@@ -48,18 +48,21 @@ interface GetOrganizationNavigation { | |||
} | |||
export function getOrganizationNavigation(key: string): Promise<GetOrganizationNavigation> { | |||
return getJSON('/api/navigation/organization', { organization: key }).then(r => r.organization); | |||
return getJSON('/api/navigation/organization', { organization: key }).then( | |||
r => r.organization, | |||
throwGlobalError | |||
); | |||
} | |||
export function createOrganization(data: OrganizationBase): Promise<Organization> { | |||
return postJSON('/api/organizations/create', data).then(r => r.organization, throwGlobalError); | |||
} | |||
export function updateOrganization(key: string, changes: OrganizationBase): Promise<void> { | |||
return post('/api/organizations/update', { key, ...changes }); | |||
export function updateOrganization(key: string, changes: OrganizationBase) { | |||
return post('/api/organizations/update', { key, ...changes }).catch(throwGlobalError); | |||
} | |||
export function deleteOrganization(key: string): Promise<void | Response> { | |||
export function deleteOrganization(key: string) { | |||
return post('/api/organizations/delete', { key }).catch(throwGlobalError); | |||
} | |||
@@ -29,7 +29,7 @@ export function grantPermissionToUser( | |||
login: string, | |||
permission: string, | |||
organization?: string | |||
): Promise<void> { | |||
) { | |||
const data: RequestData = { login, permission }; | |||
if (projectKey) { | |||
data.projectKey = projectKey; | |||
@@ -37,7 +37,7 @@ export function grantPermissionToUser( | |||
if (organization && !projectKey) { | |||
data.organization = organization; | |||
} | |||
return post('/api/permissions/add_user', data); | |||
return post('/api/permissions/add_user', data).catch(throwGlobalError); | |||
} | |||
export function revokePermissionFromUser( | |||
@@ -45,7 +45,7 @@ export function revokePermissionFromUser( | |||
login: string, | |||
permission: string, | |||
organization?: string | |||
): Promise<void> { | |||
) { | |||
const data: RequestData = { login, permission }; | |||
if (projectKey) { | |||
data.projectKey = projectKey; | |||
@@ -53,7 +53,7 @@ export function revokePermissionFromUser( | |||
if (organization && !projectKey) { | |||
data.organization = organization; | |||
} | |||
return post('/api/permissions/remove_user', data); | |||
return post('/api/permissions/remove_user', data).catch(throwGlobalError); | |||
} | |||
export function grantPermissionToGroup( | |||
@@ -61,7 +61,7 @@ export function grantPermissionToGroup( | |||
groupName: string, | |||
permission: string, | |||
organization?: string | |||
): Promise<void> { | |||
) { | |||
const data: RequestData = { groupName, permission }; | |||
if (projectKey) { | |||
data.projectKey = projectKey; | |||
@@ -69,7 +69,7 @@ export function grantPermissionToGroup( | |||
if (organization) { | |||
data.organization = organization; | |||
} | |||
return post('/api/permissions/add_group', data); | |||
return post('/api/permissions/add_group', data).catch(throwGlobalError); | |||
} | |||
export function revokePermissionFromGroup( | |||
@@ -77,7 +77,7 @@ export function revokePermissionFromGroup( | |||
groupName: string, | |||
permission: string, | |||
organization?: string | |||
): Promise<void> { | |||
) { | |||
const data: RequestData = { groupName, permission }; | |||
if (projectKey) { | |||
data.projectKey = projectKey; | |||
@@ -85,7 +85,7 @@ export function revokePermissionFromGroup( | |||
if (organization) { | |||
data.organization = organization; | |||
} | |||
return post('/api/permissions/remove_group', data); | |||
return post('/api/permissions/remove_group', data).catch(throwGlobalError); | |||
} | |||
interface GetPermissionTemplatesResponse { |
@@ -95,7 +95,8 @@ export function createQualityProfile(data: RequestData): Promise<any> { | |||
.setData(data) | |||
.submit() | |||
.then(checkStatus) | |||
.then(parseJSON); | |||
.then(parseJSON) | |||
.catch(throwGlobalError); | |||
} | |||
export function restoreQualityProfile(data: RequestData): Promise<any> { | |||
@@ -104,7 +105,8 @@ export function restoreQualityProfile(data: RequestData): Promise<any> { | |||
.setData(data) | |||
.submit() | |||
.then(checkStatus) | |||
.then(parseJSON); | |||
.then(parseJSON) | |||
.catch(throwGlobalError); | |||
} | |||
export interface ProfileProject { | |||
@@ -128,20 +130,22 @@ export function setDefaultProfile(profileKey: string): Promise<void> { | |||
return post('/api/qualityprofiles/set_default', { profileKey }); | |||
} | |||
export function renameProfile(key: string, name: string): Promise<void> { | |||
return post('/api/qualityprofiles/rename', { key, name }); | |||
export function renameProfile(key: string, name: string) { | |||
return post('/api/qualityprofiles/rename', { key, name }).catch(throwGlobalError); | |||
} | |||
export function copyProfile(fromKey: string, toName: string): Promise<any> { | |||
return postJSON('/api/qualityprofiles/copy', { fromKey, toName }); | |||
return postJSON('/api/qualityprofiles/copy', { fromKey, toName }).catch(throwGlobalError); | |||
} | |||
export function deleteProfile(profileKey: string): Promise<void> { | |||
return post('/api/qualityprofiles/delete', { profileKey }); | |||
export function deleteProfile(profileKey: string) { | |||
return post('/api/qualityprofiles/delete', { profileKey }).catch(throwGlobalError); | |||
} | |||
export function changeProfileParent(profileKey: string, parentKey: string): Promise<void> { | |||
return post('/api/qualityprofiles/change_parent', { profileKey, parentKey }); | |||
export function changeProfileParent(profileKey: string, parentKey: string) { | |||
return post('/api/qualityprofiles/change_parent', { profileKey, parentKey }).catch( | |||
throwGlobalError | |||
); | |||
} | |||
export function getImporters(): Promise< |
@@ -23,9 +23,9 @@ import Helmet from 'react-helmet'; | |||
import { connect } from 'react-redux'; | |||
import MarketplaceContext, { defaultPendingPlugins } from './MarketplaceContext'; | |||
import SettingsNav from './nav/settings/SettingsNav'; | |||
import { getAppState } from '../../store/rootReducer'; | |||
import { getAppState, Store } from '../../store/rootReducer'; | |||
import { getSettingsNavigation } from '../../api/nav'; | |||
import { setAdminPages } from '../../store/appState/duck'; | |||
import { setAdminPages } from '../../store/appState'; | |||
import { translate } from '../../helpers/l10n'; | |||
import { Extension, AppState } from '../types'; | |||
import { PluginPendingResult, getPendingPlugins } from '../../api/plugins'; | |||
@@ -121,7 +121,7 @@ class AdminContainer extends React.PureComponent<Props, State> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
appState: getAppState(state) | |||
}); | |||
@@ -129,7 +129,7 @@ const mapDispatchToProps: DispatchToProps = { | |||
setAdminPages | |||
}; | |||
export default connect<StateProps, DispatchToProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(AdminContainer); |
@@ -26,7 +26,7 @@ import { fetchLanguages } from '../../store/rootActions'; | |||
import { fetchMyOrganizations } from '../../apps/account/organizations/actions'; | |||
import { getInstance, isSonarCloud } from '../../helpers/system'; | |||
import { lazyLoad } from '../../components/lazyLoad'; | |||
import { getCurrentUser, getAppState, getGlobalSettingValue } from '../../store/rootReducer'; | |||
import { getCurrentUser, getAppState, getGlobalSettingValue, Store } from '../../store/rootReducer'; | |||
const PageTracker = lazyLoad(() => import('./PageTracker')); | |||
@@ -104,7 +104,7 @@ class App extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
appState: getAppState(state), | |||
currentUser: getCurrentUser(state), | |||
enableGravatar: (getGlobalSettingValue(state, 'sonar.lf.enableGravatar') || {}).value === 'true', |
@@ -315,7 +315,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { | |||
const mapDispatchToProps = { fetchOrganizations }; | |||
export default connect<any, any, any>( | |||
export default connect( | |||
null, | |||
mapDispatchToProps | |||
)(ComponentContainer); |
@@ -19,7 +19,7 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import GlobalFooter from './GlobalFooter'; | |||
import { getAppState } from '../../store/rootReducer'; | |||
import { getAppState, Store } from '../../store/rootReducer'; | |||
import { EditionKey } from '../../apps/marketplace/utils'; | |||
interface StateProps { | |||
@@ -28,14 +28,10 @@ interface StateProps { | |||
sonarqubeVersion?: string; | |||
} | |||
interface OwnProps { | |||
hideLoggedInInfo?: boolean; | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
productionDatabase: getAppState(state).productionDatabase, | |||
sonarqubeEdition: getAppState(state).edition, | |||
sonarqubeVersion: getAppState(state).version | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(GlobalFooter); | |||
export default connect(mapStateToProps)(GlobalFooter); |
@@ -19,10 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import GlobalMessages from '../../components/controls/GlobalMessages'; | |||
import { getGlobalMessages } from '../../store/rootReducer'; | |||
import { closeGlobalMessage } from '../../store/globalMessages/duck'; | |||
import { getGlobalMessages, Store } from '../../store/rootReducer'; | |||
import { closeGlobalMessage } from '../../store/globalMessages'; | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
messages: getGlobalMessages(state) | |||
}); | |||
@@ -22,7 +22,7 @@ import * as PropTypes from 'prop-types'; | |||
import { connect } from 'react-redux'; | |||
import { Location } from 'history'; | |||
import { CurrentUser, isLoggedIn } from '../types'; | |||
import { getCurrentUser } from '../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../store/rootReducer'; | |||
import { getHomePageUrl } from '../../helpers/urls'; | |||
interface StateProps { | |||
@@ -57,8 +57,8 @@ class Landing extends React.PureComponent<StateProps & OwnProps> { | |||
} | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(Landing); | |||
export default connect(mapStateToProps)(Landing); |
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import * as GoogleAnalytics from 'react-ga'; | |||
import { withRouter, WithRouterProps } from 'react-router'; | |||
import { connect } from 'react-redux'; | |||
import { getGlobalSettingValue } from '../../store/rootReducer'; | |||
import { getGlobalSettingValue, Store } from '../../store/rootReducer'; | |||
interface StateProps { | |||
trackingId?: string; | |||
@@ -59,8 +59,8 @@ export class PageTracker extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
trackingId: (getGlobalSettingValue(state, 'sonar.analytics.trackingId') || {}).value | |||
}); | |||
export default withRouter<{}>(connect<StateProps>(mapStateToProps)(PageTracker)); | |||
export default withRouter(connect(mapStateToProps)(PageTracker)); |
@@ -23,8 +23,8 @@ import { connect } from 'react-redux'; | |||
import { CurrentUser, isLoggedIn, Organization } from '../types'; | |||
import { differenceInDays, parseDate, toShortNotSoISOString } from '../../helpers/dates'; | |||
import { EditionKey } from '../../apps/marketplace/utils'; | |||
import { getCurrentUser, getAppState } from '../../store/rootReducer'; | |||
import { skipOnboarding as skipOnboardingAction } from '../../store/users/actions'; | |||
import { getCurrentUser, getAppState, Store } from '../../store/rootReducer'; | |||
import { skipOnboarding as skipOnboardingAction } from '../../store/users'; | |||
import { showLicense } from '../../api/marketplace'; | |||
import { hasMessage } from '../../helpers/l10n'; | |||
import { save, get } from '../../helpers/storage'; | |||
@@ -49,7 +49,7 @@ const TeamOnboardingModal = lazyLoad(() => | |||
); | |||
interface StateProps { | |||
canAdmin: boolean; | |||
canAdmin?: boolean; | |||
currentEdition?: EditionKey; | |||
currentUser: CurrentUser; | |||
} | |||
@@ -215,7 +215,7 @@ export class StartupModal extends React.PureComponent<Props, State> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
canAdmin: getAppState(state).canAdmin, | |||
currentEdition: getAppState(state).edition, | |||
currentUser: getCurrentUser(state) | |||
@@ -223,7 +223,7 @@ const mapStateToProps = (state: any): StateProps => ({ | |||
const mapDispatchToProps: DispatchProps = { skipOnboardingAction }; | |||
export default connect<StateProps, DispatchProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(StartupModal); |
@@ -20,7 +20,7 @@ | |||
import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { fetchPrismicRefs, fetchPrismicNews, PrismicNews } from '../../../api/news'; | |||
import { getGlobalSettingValue } from '../../../store/rootReducer'; | |||
import { getGlobalSettingValue, Store } from '../../../store/rootReducer'; | |||
import DateFormatter from '../../../components/intl/DateFormatter'; | |||
import ChevronRightIcon from '../../../components/icons-components/ChevronRightcon'; | |||
import PlaceholderBar from '../../../components/ui/PlaceholderBar'; | |||
@@ -124,8 +124,8 @@ export class ProductNewsMenuItem extends React.PureComponent<Props, State> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
accessToken: (getGlobalSettingValue(state, 'sonar.prismic.accessToken') || {}).value | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(ProductNewsMenuItem); | |||
export default connect(mapStateToProps)(ProductNewsMenuItem); |
@@ -19,16 +19,16 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import Extension from './Extension'; | |||
import { getCurrentUser } from '../../../store/rootReducer'; | |||
import { addGlobalErrorMessage } from '../../../store/globalMessages/duck'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
import { addGlobalErrorMessage } from '../../../store/globalMessages'; | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
const mapDispatchToProps = { onFail: addGlobalErrorMessage }; | |||
export default connect<any, any, any>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(Extension); |
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import ExtensionContainer from './ExtensionContainer'; | |||
import NotFound from '../NotFound'; | |||
import { getOrganizationByKey } from '../../../store/rootReducer'; | |||
import { getOrganizationByKey, Store } from '../../../store/rootReducer'; | |||
import { fetchOrganization } from '../../../apps/organizations/actions'; | |||
import { Organization } from '../../types'; | |||
@@ -74,13 +74,13 @@ class OrganizationPageExtension extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any, ownProps: OwnProps) => ({ | |||
const mapStateToProps = (state: Store, ownProps: OwnProps) => ({ | |||
organization: getOrganizationByKey(state, ownProps.params.organizationKey) | |||
}); | |||
const mapDispatchToProps = { fetchOrganization }; | |||
export default connect<StateToProps, DispatchProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(OrganizationPageExtension); |
@@ -22,7 +22,7 @@ import React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import ExtensionContainer from './ExtensionContainer'; | |||
import NotFound from '../NotFound'; | |||
import { addGlobalErrorMessage } from '../../../store/globalMessages/duck'; | |||
import { addGlobalErrorMessage } from '../../../store/globalMessages'; | |||
/*:: | |||
type Props = { |
@@ -23,7 +23,11 @@ import { Link } from 'react-router'; | |||
import ComponentNavBranch from './ComponentNavBranch'; | |||
import { Component, Organization, BranchLike, Breadcrumb } from '../../../types'; | |||
import QualifierIcon from '../../../../components/icons-components/QualifierIcon'; | |||
import { getOrganizationByKey, areThereCustomOrganizations } from '../../../../store/rootReducer'; | |||
import { | |||
getOrganizationByKey, | |||
areThereCustomOrganizations, | |||
Store | |||
} from '../../../../store/rootReducer'; | |||
import OrganizationAvatar from '../../../../components/common/OrganizationAvatar'; | |||
import OrganizationHelmet from '../../../../components/common/OrganizationHelmet'; | |||
import OrganizationLink from '../../../../components/ui/OrganizationLink'; | |||
@@ -34,7 +38,7 @@ import { isSonarCloud } from '../../../../helpers/system'; | |||
interface StateProps { | |||
organization?: Organization; | |||
shouldOrganizationBeDisplayed: boolean; | |||
shouldOrganizationBeDisplayed?: boolean; | |||
} | |||
interface OwnProps { | |||
@@ -118,7 +122,7 @@ function renderBreadcrumbs(breadcrumbs: Breadcrumb[]) { | |||
}); | |||
} | |||
const mapStateToProps = (state: any, ownProps: OwnProps): StateProps => ({ | |||
const mapStateToProps = (state: Store, ownProps: OwnProps): StateProps => ({ | |||
organization: getOrganizationByKey(state, ownProps.component.organization), | |||
shouldOrganizationBeDisplayed: areThereCustomOrganizations(state) | |||
}); |
@@ -40,7 +40,7 @@ import { | |||
isPullRequest | |||
} from '../../../../helpers/branches'; | |||
import { translate } from '../../../../helpers/l10n'; | |||
import { getCurrentUser } from '../../../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../../../store/rootReducer'; | |||
interface StateProps { | |||
currentUser: CurrentUser; | |||
@@ -121,7 +121,7 @@ function getCurrentPage(component: Component, branchLike: BranchLike | undefined | |||
return currentPage; | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
@@ -30,7 +30,7 @@ import * as theme from '../../../theme'; | |||
import { isLoggedIn, CurrentUser, AppState } from '../../../types'; | |||
import NavBar from '../../../../components/nav/NavBar'; | |||
import { lazyLoad } from '../../../../components/lazyLoad'; | |||
import { getCurrentUser, getAppState } from '../../../../store/rootReducer'; | |||
import { getCurrentUser, getAppState, Store } from '../../../../store/rootReducer'; | |||
import { SuggestionLink } from '../../embed-docs-modal/SuggestionsProvider'; | |||
import { isSonarCloud } from '../../../../helpers/system'; | |||
import './GlobalNav.css'; | |||
@@ -38,7 +38,7 @@ import './GlobalNav.css'; | |||
const GlobalNavPlus = lazyLoad(() => import('./GlobalNavPlus')); | |||
interface StateProps { | |||
appState: AppState; | |||
appState: Pick<AppState, 'canAdmin' | 'globalPages' | 'organizationsEnabled' | 'qualifiers'>; | |||
currentUser: CurrentUser; | |||
} | |||
@@ -78,9 +78,9 @@ export class GlobalNav extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
currentUser: getCurrentUser(state), | |||
appState: getAppState(state) | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(GlobalNav); | |||
export default connect(mapStateToProps)(GlobalNav); |
@@ -20,7 +20,7 @@ | |||
import * as React from 'react'; | |||
import { Link } from 'react-router'; | |||
import { connect } from 'react-redux'; | |||
import { getGlobalSettingValue } from '../../../../store/rootReducer'; | |||
import { getGlobalSettingValue, Store } from '../../../../store/rootReducer'; | |||
import { translate } from '../../../../helpers/l10n'; | |||
import { getBaseUrl } from '../../../../helpers/urls'; | |||
@@ -50,9 +50,9 @@ export function SonarCloudNavBranding() { | |||
); | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
customLogoUrl: (getGlobalSettingValue(state, 'sonar.lf.logoUrl') || {}).value, | |||
customLogoWidth: (getGlobalSettingValue(state, 'sonar.lf.logoWidthPx') || {}).value | |||
}); | |||
export default connect<StateProps>(mapStateToProps)(GlobalNavBranding); | |||
export default connect(mapStateToProps)(GlobalNavBranding); |
@@ -29,7 +29,7 @@ import DropdownIcon from '../../../../components/icons-components/DropdownIcon'; | |||
import { isSonarCloud } from '../../../../helpers/system'; | |||
interface Props { | |||
appState: AppState; | |||
appState: Pick<AppState, 'canAdmin' | 'globalPages' | 'organizationsEnabled' | 'qualifiers'>; | |||
currentUser: CurrentUser; | |||
location: { pathname: string }; | |||
} |
@@ -20,13 +20,13 @@ | |||
import { connect } from 'react-redux'; | |||
import GlobalNavUser from './GlobalNavUser'; | |||
import { Organization } from '../../../types'; | |||
import { getMyOrganizations } from '../../../../store/rootReducer'; | |||
import { getMyOrganizations, Store } from '../../../../store/rootReducer'; | |||
interface StateProps { | |||
organizations: Organization[]; | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
organizations: getMyOrganizations(state) | |||
}); | |||
@@ -24,7 +24,12 @@ import { isSonarCloud } from '../../../../../helpers/system'; | |||
jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); | |||
const appState = { qualifiers: [] }; | |||
const appState: GlobalNav['props']['appState'] = { | |||
globalPages: [], | |||
canAdmin: false, | |||
organizationsEnabled: false, | |||
qualifiers: [] | |||
}; | |||
const currentUser = { isLoggedIn: false }; | |||
const location = { pathname: '' }; | |||
@@ -10,6 +10,9 @@ exports[`should render for SonarCloud 1`] = ` | |||
<GlobalNavMenu | |||
appState={ | |||
Object { | |||
"canAdmin": false, | |||
"globalPages": Array [], | |||
"organizationsEnabled": false, | |||
"qualifiers": Array [], | |||
} | |||
} | |||
@@ -47,6 +50,9 @@ exports[`should render for SonarCloud 1`] = ` | |||
<Search | |||
appState={ | |||
Object { | |||
"canAdmin": false, | |||
"globalPages": Array [], | |||
"organizationsEnabled": false, | |||
"qualifiers": Array [], | |||
} | |||
} | |||
@@ -59,6 +65,9 @@ exports[`should render for SonarCloud 1`] = ` | |||
<Connect(GlobalNavUser) | |||
appState={ | |||
Object { | |||
"canAdmin": false, | |||
"globalPages": Array [], | |||
"organizationsEnabled": false, | |||
"qualifiers": Array [], | |||
} | |||
} | |||
@@ -88,6 +97,9 @@ exports[`should render for SonarQube 1`] = ` | |||
<GlobalNavMenu | |||
appState={ | |||
Object { | |||
"canAdmin": false, | |||
"globalPages": Array [], | |||
"organizationsEnabled": false, | |||
"qualifiers": Array [], | |||
} | |||
} | |||
@@ -118,6 +130,9 @@ exports[`should render for SonarQube 1`] = ` | |||
<Search | |||
appState={ | |||
Object { | |||
"canAdmin": false, | |||
"globalPages": Array [], | |||
"organizationsEnabled": false, | |||
"qualifiers": Array [], | |||
} | |||
} | |||
@@ -130,6 +145,9 @@ exports[`should render for SonarQube 1`] = ` | |||
<Connect(GlobalNavUser) | |||
appState={ | |||
Object { | |||
"canAdmin": false, | |||
"globalPages": Array [], | |||
"organizationsEnabled": false, | |||
"qualifiers": Array [], | |||
} | |||
} |
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import { CurrentUser, AppState } from '../../types'; | |||
export interface Props { | |||
appState: AppState; | |||
appState: Pick<AppState, 'organizationsEnabled'>; | |||
currentUser: CurrentUser; | |||
} | |||
@@ -31,10 +31,3 @@ | |||
qualitative?: boolean, | |||
type: string | |||
}; */ | |||
export const RECEIVE_METRICS = 'RECEIVE_METRICS'; | |||
export const receiveMetrics = (metrics /*: Array<Metric> */) => ({ | |||
type: RECEIVE_METRICS, | |||
metrics | |||
}); |
@@ -17,6 +17,8 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { EditionKey } from '../apps/marketplace/utils'; | |||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |||
// Type ordered alphabetically to prevent merge conflicts | |||
@@ -34,9 +36,14 @@ export interface AppState { | |||
authorizationError?: boolean; | |||
branchesEnabled?: boolean; | |||
canAdmin?: boolean; | |||
defaultOrganization: string; | |||
edition: EditionKey; | |||
globalPages?: Extension[]; | |||
organizationsEnabled?: boolean; | |||
productionDatabase: boolean; | |||
qualifiers: string[]; | |||
standalone?: boolean; | |||
version: string; | |||
} | |||
export interface Branch { |
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import getStore from './getStore'; | |||
import * as globalMessages from '../../store/globalMessages/duck'; | |||
import * as globalMessages from '../../store/globalMessages'; | |||
export default function addGlobalSuccessMessage(message: string): void { | |||
const store = getStore(); |
@@ -19,9 +19,9 @@ | |||
*/ | |||
import { Store } from 'redux'; | |||
import { AppState, CurrentUser } from '../types'; | |||
import { setAppState } from '../../store/appState/duck'; | |||
import { setAppState } from '../../store/appState'; | |||
import rootReducer from '../../store/rootReducer'; | |||
import { receiveCurrentUser } from '../../store/users/actions'; | |||
import { receiveCurrentUser } from '../../store/users'; | |||
import configureStore from '../../store/utils/configureStore'; | |||
let store: Store<any>; |
@@ -20,7 +20,7 @@ | |||
// @flow | |||
import getStore from './getStore'; | |||
import getHistory from './getHistory'; | |||
import { requireAuthorization } from '../../store/appState/duck'; | |||
import { requireAuthorization } from '../../store/appState'; | |||
export default () => { | |||
const store = getStore(); |
@@ -18,10 +18,18 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import getStore from './getStore'; | |||
import { onFail } from '../../store/rootActions'; | |||
import { parseError } from '../../helpers/request'; | |||
import { addGlobalErrorMessage } from '../../store/globalMessages'; | |||
export default function throwGlobalError({ response }: { response: Response }): Promise<Response> { | |||
export default function throwGlobalError(error: { response: Response }): Promise<Response> { | |||
const store = getStore(); | |||
onFail(store.dispatch)({ response }); | |||
return Promise.reject(response); | |||
// eslint-disable-next-line promise/no-promise-in-callback | |||
parseError(error) | |||
.then(message => { | |||
store.dispatch(addGlobalErrorMessage(message)); | |||
}) | |||
.catch(() => {}); | |||
return Promise.reject(error.response); | |||
} |
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { withRouter, WithRouterProps } from 'react-router'; | |||
import Footer from './Footer'; | |||
import { getCurrentUser, getMyOrganizations } from '../../../store/rootReducer'; | |||
import { getCurrentUser, getMyOrganizations, Store } from '../../../store/rootReducer'; | |||
import { CurrentUser, Organization } from '../../../app/types'; | |||
import GlobalContainer from '../../../app/components/GlobalContainer'; | |||
@@ -57,11 +57,9 @@ class SonarCloudPage extends React.Component<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state), | |||
userOrganizations: getMyOrganizations(state) | |||
}); | |||
export default withRouter<OwnProps>( | |||
connect<StateProps, {}, OwnProps>(mapStateToProps)(SonarCloudPage) | |||
); | |||
export default withRouter<OwnProps>(connect(mapStateToProps)(SonarCloudPage)); |
@@ -24,14 +24,19 @@ import OrganizationsList from './OrganizationsList'; | |||
import CreateOrganizationForm from './CreateOrganizationForm'; | |||
import { fetchIfAnyoneCanCreateOrganizations } from './actions'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { getAppState, getMyOrganizations, getGlobalSettingValue } from '../../../store/rootReducer'; | |||
import { | |||
getAppState, | |||
getMyOrganizations, | |||
getGlobalSettingValue, | |||
Store | |||
} from '../../../store/rootReducer'; | |||
import { Organization } from '../../../app/types'; | |||
import { Button } from '../../../components/ui/buttons'; | |||
interface StateProps { | |||
anyoneCanCreate?: { value: string }; | |||
canAdmin: boolean; | |||
organizations: Array<Organization>; | |||
canAdmin?: boolean; | |||
organizations: Organization[]; | |||
} | |||
interface DispatchProps { | |||
@@ -110,7 +115,7 @@ class UserOrganizations extends React.PureComponent<Props, State> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
anyoneCanCreate: getGlobalSettingValue(state, 'sonar.organizations.anyoneCanCreate'), | |||
canAdmin: getAppState(state).canAdmin, | |||
organizations: getMyOrganizations(state) |
@@ -19,17 +19,18 @@ | |||
*/ | |||
import { Dispatch } from 'redux'; | |||
import { getOrganizations } from '../../../api/organizations'; | |||
import { receiveMyOrganizations } from '../../../store/organizations/duck'; | |||
import { receiveMyOrganizations } from '../../../store/organizations'; | |||
import { getValues } from '../../../api/settings'; | |||
import { receiveValues } from '../../settings/store/values/actions'; | |||
import { Store } from '../../../store/rootReducer'; | |||
export const fetchMyOrganizations = () => (dispatch: Dispatch<any>) => { | |||
export const fetchMyOrganizations = () => (dispatch: Dispatch<Store>) => { | |||
return getOrganizations({ member: true }).then(({ organizations }) => { | |||
return dispatch(receiveMyOrganizations(organizations)); | |||
}); | |||
}; | |||
export const fetchIfAnyoneCanCreateOrganizations = () => (dispatch: Dispatch<any>) => { | |||
export const fetchIfAnyoneCanCreateOrganizations = () => (dispatch: Dispatch<Store>) => { | |||
return getValues({ keys: 'sonar.organizations.anyoneCanCreate' }).then(values => { | |||
dispatch(receiveValues(values, undefined)); | |||
}); |
@@ -19,9 +19,9 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import Stats from './Stats'; | |||
import { getAppState } from '../../../store/rootReducer'; | |||
import { getAppState, Store } from '../../../store/rootReducer'; | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
isSystemAdmin: !!getAppState(state).canAdmin | |||
}); | |||
@@ -51,7 +51,7 @@ import FiltersHeader from '../../../components/common/FiltersHeader'; | |||
import SearchBox from '../../../components/controls/SearchBox'; | |||
import { searchRules, getRulesApp } from '../../../api/rules'; | |||
import { searchQualityProfiles, Profile } from '../../../api/quality-profiles'; | |||
import { getCurrentUser, getMyOrganizations } from '../../../store/rootReducer'; | |||
import { getCurrentUser, getMyOrganizations, Store } from '../../../store/rootReducer'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { RawQuery } from '../../../helpers/query'; | |||
import { scrollToElement } from '../../../helpers/scrolling'; | |||
@@ -634,9 +634,9 @@ function parseFacets(rawFacets: { property: string; values: { count: number; val | |||
return facets; | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state), | |||
userOrganizations: getMyOrganizations(state) | |||
}); | |||
export default withRouter(connect<StateToProps, {}, OwnProps>(mapStateToProps)(App)); | |||
export default withRouter(connect(mapStateToProps)(App)); |
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { uniqBy } from 'lodash'; | |||
import { BasicProps } from './Facet'; | |||
import { getLanguages } from '../../../store/rootReducer'; | |||
import { getLanguages, Store } from '../../../store/rootReducer'; | |||
import ListStyleFacet from '../../../components/facet/ListStyleFacet'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { highlightTerm } from '../../../helpers/search'; | |||
@@ -92,7 +92,7 @@ class LanguageFacet extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
installedLanguages: Object.values(getLanguages(state)) | |||
}); | |||
@@ -20,7 +20,7 @@ | |||
import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import Facet, { BasicProps } from './Facet'; | |||
import { getLanguages } from '../../../store/rootReducer'; | |||
import { getLanguages, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
referencedLanguages: { [language: string]: { key: string; name: string } }; | |||
@@ -69,7 +69,7 @@ class RepositoryFacet extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
referencedLanguages: getLanguages(state) | |||
}); | |||
@@ -36,7 +36,7 @@ import { | |||
import { getDisplayMetrics } from '../../../helpers/measures'; | |||
/*:: import type { Component, Query, Period } from '../types'; */ | |||
/*:: import type { RawQuery } from '../../../helpers/query'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: import type { MeasureEnhanced } from '../../../components/measure/types'; */ | |||
import '../../../components/search-navigator.css'; | |||
import '../style.css'; |
@@ -31,7 +31,7 @@ import { getMeasureHistoryUrl } from '../../../helpers/urls'; | |||
import { isDiffMetric } from '../../../helpers/measures'; | |||
/*:: import type { Component, Period } from '../types'; */ | |||
/*:: import type { MeasureEnhanced } from '../../../components/measure/types'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: type Props = {| | |||
branchLike?: { id?: string; name: string }, |
@@ -30,7 +30,7 @@ import { enhanceComponent, getBubbleMetrics, isFileType } from '../utils'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
import DeferredSpinner from '../../../components/common/DeferredSpinner'; | |||
/*:: import type { Component, ComponentEnhanced, Paging, Period } from '../types'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: type Props = {| | |||
branchLike?: { id?: string; name: string }, |
@@ -26,7 +26,7 @@ import { isViewType } from '../utils'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
/*:: import type { Component, Period, Query } from '../types'; */ | |||
/*:: import type { RawQuery } from '../../../helpers/query'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: type Props = {| | |||
branchLike?: { id?: string; name: string }, |
@@ -33,7 +33,7 @@ import { | |||
import { getBubbleMetrics, getBubbleYDomain, isProjectOverview } from '../utils'; | |||
import { RATING_COLORS } from '../../../helpers/constants'; | |||
/*:: import type { Component, ComponentEnhanced } from '../types'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
const HEIGHT = 500; | |||
@@ -32,7 +32,7 @@ import { | |||
} from '../../../helpers/urls'; | |||
import { translate } from '../../../helpers/l10n'; | |||
/*:: import type { Component, ComponentEnhanced } from '../types'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: type Props = { | |||
branchLike?: { id?: string; name: string }, |
@@ -23,7 +23,7 @@ import classNames from 'classnames'; | |||
import ComponentCell from './ComponentCell'; | |||
import MeasureCell from './MeasureCell'; | |||
/*:: import type { Component, ComponentEnhanced } from '../types'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: type Props = {| | |||
branchLike?: { id?: string; name: string }, |
@@ -23,7 +23,7 @@ import Measure from '../../../components/measure/Measure'; | |||
import { isDiffMetric } from '../../../helpers/measures'; | |||
/*:: import type { ComponentEnhanced } from '../types'; */ | |||
/*:: import type { MeasureEnhanced } from '../../../components/measure/types'; */ | |||
/*:: import type { Metric } from '../../../store/metrics/actions'; */ | |||
/*:: import type { Metric } from '../../../app/flow-types'; */ | |||
/*:: type Props = { | |||
component: ComponentEnhanced, |
@@ -22,7 +22,7 @@ import { connect } from 'react-redux'; | |||
import AppContainer from './components/AppContainer'; | |||
import { CurrentUser, isLoggedIn } from '../../app/types'; | |||
import { RawQuery } from '../../helpers/query'; | |||
import { getCurrentUser } from '../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../store/rootReducer'; | |||
import { isSonarCloud } from '../../helpers/system'; | |||
interface StateProps { | |||
@@ -38,8 +38,8 @@ function IssuesPage({ currentUser, location }: Props) { | |||
return <AppContainer location={location} myIssues={myIssues} />; | |||
} | |||
const stateToProps = (state: any) => ({ | |||
const stateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
export default connect<StateProps>(stateToProps)(IssuesPage); | |||
export default connect(stateToProps)(IssuesPage); |
@@ -27,24 +27,25 @@ import throwGlobalError from '../../../app/utils/throwGlobalError'; | |||
import { | |||
getCurrentUser, | |||
areThereCustomOrganizations, | |||
getMyOrganizations | |||
getMyOrganizations, | |||
Store | |||
} from '../../../store/rootReducer'; | |||
import { lazyLoad } from '../../../components/lazyLoad'; | |||
import { parseIssueFromResponse } from '../../../helpers/issues'; | |||
import { RawQuery } from '../../../helpers/query'; | |||
import { receiveOrganizations } from '../../../store/organizations/duck'; | |||
import { receiveOrganizations } from '../../../store/organizations'; | |||
interface StateProps { | |||
currentUser: CurrentUser; | |||
userOrganizations: Organization[]; | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
currentUser: getCurrentUser(state), | |||
userOrganizations: getMyOrganizations(state) | |||
}); | |||
const fetchIssueOrganizations = (organizationKeys: string[]) => (dispatch: Dispatch<any>) => { | |||
const fetchIssueOrganizations = (organizationKeys: string[]) => (dispatch: Dispatch<Store>) => { | |||
if (!organizationKeys.length) { | |||
return Promise.resolve(); | |||
} | |||
@@ -58,7 +59,7 @@ const fetchIssueOrganizations = (organizationKeys: string[]) => (dispatch: Dispa | |||
const fetchIssues = (query: RawQuery, requestOrganizations = true) => ( | |||
// use `Function` to be able to do `dispatch(...).then(...)` | |||
dispatch: Function, | |||
getState: () => any | |||
getState: () => Store | |||
) => { | |||
const organizationsEnabled = areThereCustomOrganizations(getState()); | |||
return searchIssues({ ...query, additionalFields: '_all' }) | |||
@@ -87,13 +88,7 @@ interface DispatchProps { | |||
// have to type cast this, because of async action | |||
const mapDispatchToProps = { fetchIssues: fetchIssues as any } as DispatchProps; | |||
interface OwnProps { | |||
location: { pathname: string; query: RawQuery }; | |||
hideAuthorFacet?: boolean; | |||
myIssues?: boolean; | |||
} | |||
export default connect<StateProps, DispatchProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(lazyLoad(() => import('./App'))); |
@@ -22,7 +22,7 @@ import { uniqBy, omit } from 'lodash'; | |||
import { connect } from 'react-redux'; | |||
import ListStyleFacet from '../../../components/facet/ListStyleFacet'; | |||
import { Query, ReferencedLanguage, Facet } from '../utils'; | |||
import { getLanguages } from '../../../store/rootReducer'; | |||
import { getLanguages, Store } from '../../../store/rootReducer'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { highlightTerm } from '../../../helpers/search'; | |||
@@ -107,7 +107,7 @@ class LanguageFacet extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
installedLanguages: Object.values(getLanguages(state)) | |||
}); | |||
@@ -45,7 +45,7 @@ export interface Props { | |||
fetchPendingPlugins: () => void; | |||
location: { pathname: string; query: RawQuery }; | |||
pendingPlugins: PluginPendingResult; | |||
standaloneMode: boolean; | |||
standaloneMode?: boolean; | |||
updateCenterActive: boolean; | |||
} | |||
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import App from './App'; | |||
import { EditionKey } from './utils'; | |||
import { getAppState, getGlobalSettingValue } from '../../store/rootReducer'; | |||
import { getAppState, getGlobalSettingValue, Store } from '../../store/rootReducer'; | |||
import { RawQuery } from '../../helpers/query'; | |||
import MarketplaceContext from '../../app/components/MarketplaceContext'; | |||
@@ -31,11 +31,11 @@ interface OwnProps { | |||
interface StateToProps { | |||
currentEdition?: EditionKey; | |||
standaloneMode: boolean; | |||
standaloneMode?: boolean; | |||
updateCenterActive: boolean; | |||
} | |||
const mapStateToProps = (state: any) => { | |||
const mapStateToProps = (state: Store) => { | |||
return { | |||
currentEdition: getAppState(state).edition, | |||
standaloneMode: getAppState(state).standalone, | |||
@@ -52,4 +52,4 @@ const WithMarketplaceContext = (props: StateToProps & OwnProps) => ( | |||
</MarketplaceContext.Consumer> | |||
); | |||
export default connect<StateToProps, {}, OwnProps>(mapStateToProps)(WithMarketplaceContext); | |||
export default connect(mapStateToProps)(WithMarketplaceContext); |
@@ -20,7 +20,7 @@ | |||
import { connect } from 'react-redux'; | |||
import OrganizationMembers from './OrganizationMembers'; | |||
import { Organization } from '../../app/types'; | |||
import { getOrganizationByKey } from '../../store/rootReducer'; | |||
import { getOrganizationByKey, Store } from '../../store/rootReducer'; | |||
interface OwnProps { | |||
params: { organizationKey: string }; | |||
@@ -30,11 +30,8 @@ interface StateProps { | |||
organization: Organization; | |||
} | |||
const mapStateToProps = (state: any, ownProps: OwnProps): StateProps => { | |||
const { organizationKey } = ownProps.params; | |||
return { | |||
organization: getOrganizationByKey(state, organizationKey)! | |||
}; | |||
const mapStateToProps = (state: Store, ownProps: OwnProps): StateProps => { | |||
return { organization: getOrganizationByKey(state, ownProps.params.organizationKey) }; | |||
}; | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(OrganizationMembers); | |||
export default connect(mapStateToProps)(OrganizationMembers); |
@@ -19,51 +19,47 @@ | |||
*/ | |||
import { Dispatch } from 'redux'; | |||
import * as api from '../../api/organizations'; | |||
import * as actions from '../../store/organizations/duck'; | |||
import { onFail } from '../../store/rootActions'; | |||
import { addGlobalSuccessMessage } from '../../store/globalMessages/duck'; | |||
import * as actions from '../../store/organizations'; | |||
import { addGlobalSuccessMessage } from '../../store/globalMessages'; | |||
import { translate, translateWithParameters } from '../../helpers/l10n'; | |||
import { Organization, OrganizationBase } from '../../app/types'; | |||
import { Store } from '../../store/rootReducer'; | |||
const onRejected = (dispatch: Dispatch<any>) => (error: any) => { | |||
onFail(dispatch)(error); | |||
return Promise.reject(error); | |||
}; | |||
export const fetchOrganization = (key: string) => (dispatch: Dispatch<any>) => { | |||
export const fetchOrganization = (key: string) => (dispatch: Dispatch<Store>) => { | |||
return Promise.all([api.getOrganization(key), api.getOrganizationNavigation(key)]).then( | |||
([organization, navigation]) => { | |||
if (organization) { | |||
const organizationWithPermissions = { ...organization, ...navigation }; | |||
dispatch(actions.receiveOrganizations([organizationWithPermissions])); | |||
} | |||
}, | |||
onFail(dispatch) | |||
} | |||
); | |||
}; | |||
export const createOrganization = (organization: OrganizationBase) => (dispatch: Dispatch<any>) => { | |||
export const createOrganization = (organization: OrganizationBase) => ( | |||
dispatch: Dispatch<Store> | |||
) => { | |||
return api.createOrganization(organization).then((organization: Organization) => { | |||
dispatch(actions.createOrganization(organization)); | |||
dispatch( | |||
addGlobalSuccessMessage(translateWithParameters('organization.created', organization.name)) | |||
); | |||
return organization; | |||
}, onRejected(dispatch)); | |||
}); | |||
}; | |||
export const updateOrganization = (key: string, changes: OrganizationBase) => ( | |||
dispatch: Dispatch<any> | |||
dispatch: Dispatch<Store> | |||
) => { | |||
return api.updateOrganization(key, changes).then(() => { | |||
dispatch(actions.updateOrganization(key, changes)); | |||
dispatch(addGlobalSuccessMessage(translate('organization.updated'))); | |||
}, onFail(dispatch)); | |||
}); | |||
}; | |||
export const deleteOrganization = (key: string) => (dispatch: Dispatch<any>) => { | |||
export const deleteOrganization = (key: string) => (dispatch: Dispatch<Store>) => { | |||
return api.deleteOrganization(key).then(() => { | |||
dispatch(actions.deleteOrganization(key)); | |||
dispatch(addGlobalSuccessMessage(translate('organization.deleted'))); | |||
}, onFail(dispatch)); | |||
}); | |||
}; |
@@ -20,7 +20,7 @@ | |||
import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { RouterState } from 'react-router'; | |||
import { getCurrentUser, getOrganizationByKey } from '../../../store/rootReducer'; | |||
import { getCurrentUser, getOrganizationByKey, Store } from '../../../store/rootReducer'; | |||
import handleRequiredAuthorization from '../../../app/utils/handleRequiredAuthorization'; | |||
import { Organization, CurrentUser, isLoggedIn } from '../../../app/types'; | |||
@@ -63,14 +63,12 @@ export class OrganizationAccess extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any, ownProps: OwnProps) => ({ | |||
const mapStateToProps = (state: Store, ownProps: OwnProps) => ({ | |||
currentUser: getCurrentUser(state), | |||
organization: getOrganizationByKey(state, ownProps.params.organizationKey) | |||
}); | |||
const OrganizationAccessContainer = connect<StateToProps, {}, OwnProps>(mapStateToProps)( | |||
OrganizationAccess | |||
); | |||
const OrganizationAccessContainer = connect(mapStateToProps)(OrganizationAccess); | |||
export function hasAdminAccess({ | |||
currentUser, |
@@ -20,7 +20,7 @@ | |||
import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { RouterState } from 'react-router'; | |||
import { getCurrentUser, getOrganizationByKey } from '../../../store/rootReducer'; | |||
import { getCurrentUser, getOrganizationByKey, Store } from '../../../store/rootReducer'; | |||
import { Organization, CurrentUser } from '../../../app/types'; | |||
interface StateToProps { | |||
@@ -44,9 +44,9 @@ class OrganizationContainer extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any, ownProps: OwnProps) => ({ | |||
const mapStateToProps = (state: Store, ownProps: OwnProps) => ({ | |||
organization: getOrganizationByKey(state, ownProps.params.organizationKey), | |||
currentUser: getCurrentUser(state) | |||
}); | |||
export default connect<StateToProps, {}, OwnProps>(mapStateToProps)(OrganizationContainer); | |||
export default connect(mapStateToProps)(OrganizationContainer); |
@@ -128,7 +128,7 @@ export class OrganizationDelete extends React.PureComponent<Props, State> { | |||
const mapDispatchToProps: DispatchToProps = { deleteOrganization: deleteOrganization as any }; | |||
export default connect<null, DispatchToProps, OwnProps>( | |||
export default connect( | |||
null, | |||
mapDispatchToProps | |||
)(OrganizationDelete); |
@@ -197,7 +197,7 @@ export class OrganizationEdit extends React.PureComponent<Props, State> { | |||
const mapDispatchToProps = { updateOrganization: updateOrganization as any }; | |||
export default connect<{}, DispatchProps, OwnProps>( | |||
export default connect( | |||
null, | |||
mapDispatchToProps | |||
)(OrganizationEdit); |
@@ -28,7 +28,8 @@ import { Organization, CurrentUser } from '../../../app/types'; | |||
import { | |||
getOrganizationByKey, | |||
getCurrentUser, | |||
getMyOrganizations | |||
getMyOrganizations, | |||
Store | |||
} from '../../../store/rootReducer'; | |||
interface OwnProps { | |||
@@ -110,7 +111,7 @@ export class OrganizationPage extends React.PureComponent<Props, State> { | |||
} | |||
} | |||
const mapStateToProps = (state: any, ownProps: OwnProps) => ({ | |||
const mapStateToProps = (state: Store, ownProps: OwnProps) => ({ | |||
currentUser: getCurrentUser(state), | |||
organization: getOrganizationByKey(state, ownProps.params.organizationKey), | |||
userOrganizations: getMyOrganizations(state) | |||
@@ -118,7 +119,7 @@ const mapStateToProps = (state: any, ownProps: OwnProps) => ({ | |||
const mapDispatchToProps = { fetchOrganization: fetchOrganization as any }; | |||
export default connect<StateProps, DispatchToProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(OrganizationPage); |
@@ -20,7 +20,7 @@ | |||
import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { withRouter, WithRouterProps } from 'react-router'; | |||
import { areThereCustomOrganizations } from '../../store/rootReducer'; | |||
import { areThereCustomOrganizations, Store } from '../../store/rootReducer'; | |||
type ReactComponent<P> = React.ComponentClass<P> | React.StatelessComponent<P>; | |||
@@ -44,7 +44,7 @@ export default function forSingleOrganization<P>(ComposedComponent: ReactCompone | |||
} | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
customOrganizations: areThereCustomOrganizations(state) | |||
}); | |||
@@ -20,13 +20,13 @@ | |||
import { connect } from 'react-redux'; | |||
import OrganizationNavigationHeader from './OrganizationNavigationHeader'; | |||
import { Organization } from '../../../app/types'; | |||
import { getMyOrganizations } from '../../../store/rootReducer'; | |||
import { getMyOrganizations, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
organizations: Organization[]; | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
organizations: getMyOrganizations(state) | |||
}); | |||
@@ -27,7 +27,7 @@ import NavBarTabs from '../../../components/nav/NavBarTabs'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { getQualityGatesUrl } from '../../../helpers/urls'; | |||
import { hasPrivateAccess, isCurrentUserMemberOf } from '../../../helpers/organizations'; | |||
import { getCurrentUser, getMyOrganizations } from '../../../store/rootReducer'; | |||
import { getCurrentUser, getMyOrganizations, Store } from '../../../store/rootReducer'; | |||
interface StateToProps { | |||
currentUser: CurrentUser; | |||
@@ -99,9 +99,9 @@ export function OrganizationNavigationMenu({ | |||
); | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state), | |||
userOrganizations: getMyOrganizations(state) | |||
}); | |||
export default connect<StateToProps, {}, OwnProps>(mapStateToProps)(OrganizationNavigationMenu); | |||
export default connect(mapStateToProps)(OrganizationNavigationMenu); |
@@ -47,7 +47,7 @@ import { | |||
isLongLivingBranch | |||
} from '../../../helpers/branches'; | |||
import { fetchMetrics } from '../../../store/rootActions'; | |||
import { getMetrics } from '../../../store/rootReducer'; | |||
import { getMetrics, Store } from '../../../store/rootReducer'; | |||
import { BranchLike, Component, Metric, MeasureEnhanced } from '../../../app/types'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import '../styles.css'; | |||
@@ -262,11 +262,11 @@ export class OverviewApp extends React.PureComponent<Props, State> { | |||
const mapDispatchToProps: DispatchToProps = { fetchMetrics }; | |||
const mapStateToProps = (state: any): StateToProps => ({ | |||
const mapStateToProps = (state: Store): StateToProps => ({ | |||
metrics: getMetrics(state) | |||
}); | |||
export default connect<StateToProps, DispatchToProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(OverviewApp); |
@@ -25,7 +25,7 @@ import MetaContainer from '../meta/MetaContainer'; | |||
import { BranchLike, Component, CurrentUser, isLoggedIn } from '../../../app/types'; | |||
import { isLongLivingBranch, isBranch, isMainBranch } from '../../../helpers/branches'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { getCurrentUser } from '../../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
import '../../../app/styles/sonarcloud.css'; | |||
interface OwnProps { | |||
@@ -119,8 +119,8 @@ export function WarningMessage({ | |||
); | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(SonarCloudEmptyOverview); | |||
export default connect(mapStateToProps)(SonarCloudEmptyOverview); |
@@ -44,7 +44,8 @@ import { hasPrivateAccess } from '../../../helpers/organizations'; | |||
import { | |||
getCurrentUser, | |||
getMyOrganizations, | |||
getOrganizationByKey | |||
getOrganizationByKey, | |||
Store | |||
} from '../../../store/rootReducer'; | |||
import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; | |||
@@ -170,10 +171,10 @@ export class Meta extends React.PureComponent<Props> { | |||
} | |||
} | |||
const mapStateToProps = (state: any, { component }: OwnProps) => ({ | |||
const mapStateToProps = (state: Store, { component }: OwnProps) => ({ | |||
currentUser: getCurrentUser(state), | |||
organization: getOrganizationByKey(state, component.organization), | |||
userOrganizations: getMyOrganizations(state) | |||
}); | |||
export default connect<StateToProps, {}, OwnProps>(mapStateToProps)(Meta); | |||
export default connect(mapStateToProps)(Meta); |
@@ -25,7 +25,7 @@ import Tooltip from '../../../components/controls/Tooltip'; | |||
import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
import { getQualityProfileUrl } from '../../../helpers/urls'; | |||
import { searchRules } from '../../../api/rules'; | |||
import { getLanguages } from '../../../store/rootReducer'; | |||
import { getLanguages, Store } from '../../../store/rootReducer'; | |||
import { ComponentQualityProfile } from '../../../app/types'; | |||
interface StateProps { | |||
@@ -147,8 +147,8 @@ class MetaQualityProfiles extends React.PureComponent<StateProps & OwnProps, Sta | |||
} | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
languages: getLanguages(state) | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(mapStateToProps)(MetaQualityProfiles); | |||
export default connect(mapStateToProps)(MetaQualityProfiles); |
@@ -67,7 +67,7 @@ export default class MetaSize extends React.PureComponent<Props> { | |||
const className = | |||
this.props.component.qualifier === 'TRK' ? 'overview-meta-size-lang-dist' : 'big-spacer-top'; | |||
return languageDistribution ? ( | |||
return languageDistribution && languageDistribution.value !== undefined ? ( | |||
<div className={className} id="overview-language-distribution"> | |||
<LanguageDistributionContainer distribution={languageDistribution.value} width={160} /> | |||
</div> |
@@ -17,6 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { Dispatch } from 'redux'; | |||
import { connect } from 'react-redux'; | |||
import AllHoldersList from './AllHoldersList'; | |||
import { | |||
@@ -34,35 +35,16 @@ import { | |||
getPermissionsAppGroups, | |||
getPermissionsAppQuery, | |||
getPermissionsAppFilter, | |||
getPermissionsAppSelectedPermission | |||
getPermissionsAppSelectedPermission, | |||
Store | |||
} from '../../../../store/rootReducer'; | |||
import { Organization } from '../../../../app/types'; | |||
import { PermissionUser, PermissionGroup } from '../../../../api/permissions'; | |||
interface OwnProps { | |||
organization?: Organization; | |||
} | |||
interface StateToProps { | |||
filter: string; | |||
groups: PermissionGroup[]; | |||
query: string; | |||
selectedPermission?: string; | |||
users: PermissionUser[]; | |||
} | |||
interface DispatchToProps { | |||
grantPermissionToGroup: (groupName: string, permission: string) => Promise<void>; | |||
grantPermissionToUser: (login: string, permission: string) => Promise<void>; | |||
loadHolders: () => void; | |||
onFilter: (filter: string) => void; | |||
onSearch: (query: string) => void; | |||
onSelectPermission: (permission: string) => void; | |||
revokePermissionFromGroup: (groupName: string, permission: string) => Promise<void>; | |||
revokePermissionFromUser: (login: string, permission: string) => Promise<void>; | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
filter: getPermissionsAppFilter(state), | |||
groups: getPermissionsAppGroups(state), | |||
query: getPermissionsAppQuery(state), | |||
@@ -70,7 +52,7 @@ const mapStateToProps = (state: any) => ({ | |||
users: getPermissionsAppUsers(state) | |||
}); | |||
const mapDispatchToProps = (dispatch: Function, ownProps: OwnProps) => { | |||
const mapDispatchToProps = (dispatch: Dispatch<Store>, ownProps: OwnProps) => { | |||
const organizationKey = ownProps.organization ? ownProps.organization.key : undefined; | |||
return { | |||
grantPermissionToGroup: (groupName: string, permission: string) => | |||
@@ -89,7 +71,7 @@ const mapDispatchToProps = (dispatch: Function, ownProps: OwnProps) => { | |||
}; | |||
}; | |||
export default connect<StateToProps, DispatchToProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(AllHoldersList); |
@@ -45,8 +45,7 @@ export type Props = {| | |||
qualifier: string, | |||
visibility: string | |||
}, | |||
onComponentChange: (changes: {}) => void, | |||
onRequestFail: Object => void | |||
onComponentChange: (changes: {}) => void | |||
|}; | |||
*/ | |||
@@ -208,7 +207,6 @@ export default class App extends React.PureComponent { | |||
loading: false, | |||
groups: this.removePermissionFromGroup(group, permission) | |||
}); | |||
this.props.onRequestFail(error); | |||
} | |||
}); | |||
} | |||
@@ -231,7 +229,6 @@ export default class App extends React.PureComponent { | |||
loading: false, | |||
users: this.removePermissionFromUser(user, permission) | |||
}); | |||
this.props.onRequestFail(error); | |||
} | |||
}); | |||
} | |||
@@ -254,7 +251,6 @@ export default class App extends React.PureComponent { | |||
loading: false, | |||
groups: this.addPermissionToGroup(group, permission) | |||
}); | |||
this.props.onRequestFail(error); | |||
} | |||
}); | |||
} | |||
@@ -277,7 +273,6 @@ export default class App extends React.PureComponent { | |||
loading: false, | |||
users: this.addPermissionToUser(user, permission) | |||
}); | |||
this.props.onRequestFail(error); | |||
} | |||
}); | |||
} |
@@ -19,18 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import App from './App'; | |||
import { onFail } from '../../../../store/rootActions'; | |||
import { getCurrentUser } from '../../../../store/rootReducer'; | |||
const mapStateToProps = state => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
const mapDispatchToProps = dispatch => ({ | |||
onRequestFail: onFail(dispatch) | |||
}); | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(App); | |||
export default connect(mapStateToProps)(App); |
@@ -19,7 +19,7 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import { connect } from 'react-redux'; | |||
import { getPermissionsAppError } from '../../../../store/rootReducer'; | |||
import { getPermissionsAppError, Store } from '../../../../store/rootReducer'; | |||
interface Props { | |||
message: string; | |||
@@ -33,7 +33,7 @@ function PageError({ message }: Props) { | |||
return <div className="alert alert-danger">{message}</div>; | |||
} | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
message: getPermissionsAppError(state) | |||
}); | |||
@@ -33,7 +33,7 @@ import { getMeasures } from '../../../api/measures'; | |||
import { getChildren } from '../../../api/components'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { fetchMetrics } from '../../../store/rootActions'; | |||
import { getMetrics } from '../../../store/rootReducer'; | |||
import { getMetrics, Store } from '../../../store/rootReducer'; | |||
import { Metric, Component } from '../../../app/types'; | |||
import '../styles.css'; | |||
import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; | |||
@@ -220,11 +220,11 @@ export class App extends React.PureComponent<Props, State> { | |||
const mapDispatchToProps: DispatchToProps = { fetchMetrics }; | |||
const mapStateToProps = (state: any): StateToProps => ({ | |||
const mapStateToProps = (state: Store): StateToProps => ({ | |||
metrics: getMetrics(state) | |||
}); | |||
export default connect<StateToProps, DispatchToProps, Props>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(App); |
@@ -22,10 +22,11 @@ import AlertSuccessIcon from '../../../components/icons-components/AlertSuccessI | |||
import { ReportStatus, subscribe, unsubscribe } from '../../../api/report'; | |||
import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
import { Button } from '../../../components/ui/buttons'; | |||
import { CurrentUser, isLoggedIn } from '../../../app/types'; | |||
interface Props { | |||
component: string; | |||
currentUser: { email?: string }; | |||
currentUser: CurrentUser; | |||
status: ReportStatus; | |||
} | |||
@@ -116,7 +117,7 @@ export default class Subscription extends React.PureComponent<Props, State> { | |||
); | |||
render() { | |||
const hasEmail = !!this.props.currentUser.email; | |||
const hasEmail = isLoggedIn(this.props.currentUser) && !!this.props.currentUser.email; | |||
const { subscribed } = this.state; | |||
let inner; |
@@ -19,10 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import Subscription from './Subscription'; | |||
import { getCurrentUser } from '../../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
export default connect<any, any, any>(mapStateToProps)(Subscription); | |||
export default connect(mapStateToProps)(Subscription); |
@@ -41,7 +41,7 @@ const status = { | |||
subscribed: true | |||
}; | |||
const currentUser = { email: 'foo@example.com' }; | |||
const currentUser = { isLoggedIn: true, email: 'foo@example.com' }; | |||
beforeEach(() => { | |||
subscribe.mockClear(); | |||
@@ -68,7 +68,7 @@ it('renders when not subscribed', () => { | |||
it('renders when no email', () => { | |||
expect( | |||
shallow(<Subscription component="foo" currentUser={{}} status={status} />) | |||
shallow(<Subscription component="foo" currentUser={{ isLoggedIn: false }} status={status} />) | |||
).toMatchSnapshot(); | |||
}); | |||
@@ -30,7 +30,7 @@ import { | |||
addGlobalErrorMessage, | |||
addGlobalSuccessMessage, | |||
closeAllGlobalMessages | |||
} from '../../../store/globalMessages/duck'; | |||
} from '../../../store/globalMessages'; | |||
import RecentHistory from '../../../app/components/RecentHistory'; | |||
class BulkUpdate extends React.PureComponent { |
@@ -32,7 +32,7 @@ import { | |||
addGlobalErrorMessage, | |||
addGlobalSuccessMessage, | |||
closeAllGlobalMessages | |||
} from '../../../store/globalMessages/duck'; | |||
} from '../../../store/globalMessages'; | |||
import RecentHistory from '../../../app/components/RecentHistory'; | |||
import { getProjectAdminProjectModules } from '../../../store/rootReducer'; | |||
@@ -19,10 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import App from './App'; | |||
import { getAppState } from '../../../store/rootReducer'; | |||
import { getAppState, Store } from '../../../store/rootReducer'; | |||
const mapStateToProps = (state: any) => ({ | |||
const mapStateToProps = (state: Store) => ({ | |||
canAdmin: getAppState(state).canAdmin | |||
}); | |||
export default connect<any, any, any>(mapStateToProps)(App); | |||
export default connect(mapStateToProps)(App); |
@@ -46,7 +46,7 @@ export interface Props { | |||
isFavorite: boolean; | |||
location: { pathname: string; query: RawQuery }; | |||
organization: Organization | undefined; | |||
organizationsEnabled: boolean; | |||
organizationsEnabled?: boolean; | |||
storageOptionsSuffix?: string; | |||
} | |||
@@ -18,28 +18,12 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import { CurrentUser, Organization } from '../../../app/types'; | |||
import { lazyLoad } from '../../../components/lazyLoad'; | |||
import { getCurrentUser, areThereCustomOrganizations } from '../../../store/rootReducer'; | |||
import { RawQuery } from '../../../helpers/query'; | |||
import { getCurrentUser, areThereCustomOrganizations, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
currentUser: CurrentUser; | |||
organizationsEnabled: boolean; | |||
} | |||
interface OwnProps { | |||
isFavorite: boolean; | |||
location: { pathname: string; query: RawQuery }; | |||
organization: Organization | undefined; | |||
storageOptionsSuffix?: string; | |||
} | |||
const stateToProps = (state: any) => ({ | |||
const stateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state), | |||
organizationsEnabled: areThereCustomOrganizations(state) | |||
}); | |||
export default connect<StateProps, {}, OwnProps>(stateToProps)( | |||
lazyLoad(() => import('./AllProjects')) | |||
); | |||
export default connect(stateToProps)(lazyLoad(() => import('./AllProjects'))); |
@@ -19,15 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import DefaultPageSelector from './DefaultPageSelector'; | |||
import { CurrentUser } from '../../../app/types'; | |||
import { getCurrentUser } from '../../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
currentUser: CurrentUser; | |||
} | |||
const stateToProps = (state: any) => ({ | |||
const stateToProps = (state: Store) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
export default connect<StateProps>(stateToProps)(DefaultPageSelector); | |||
export default connect(stateToProps)(DefaultPageSelector); |
@@ -19,9 +19,9 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import FavoriteFilter from './FavoriteFilter'; | |||
import { getCurrentUser } from '../../../store/rootReducer'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
function mapStateToProps(state: any) { | |||
function mapStateToProps(state: Store) { | |||
return { currentUser: getCurrentUser(state) }; | |||
} | |||
@@ -26,7 +26,7 @@ import DropdownIcon from '../../../components/icons-components/DropdownIcon'; | |||
import Dropdown from '../../../components/controls/Dropdown'; | |||
import OrganizationListItem from '../../../components/ui/OrganizationListItem'; | |||
import { Button } from '../../../components/ui/buttons'; | |||
import { getMyOrganizations } from '../../../store/rootReducer'; | |||
import { getMyOrganizations, Store } from '../../../store/rootReducer'; | |||
import { isSonarCloud } from '../../../helpers/system'; | |||
import { Organization } from '../../../app/types'; | |||
import { translate } from '../../../helpers/l10n'; | |||
@@ -95,7 +95,7 @@ export class NoFavoriteProjects extends React.PureComponent<StateProps> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
organizations: getMyOrganizations(state) | |||
}); | |||
@@ -21,7 +21,7 @@ import * as React from 'react'; | |||
import { sortBy } from 'lodash'; | |||
import Tooltip from '../../../components/controls/Tooltip'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { Languages } from '../../../store/languages/reducer'; | |||
import { Languages } from '../../../store/languages'; | |||
interface Props { | |||
distribution?: string; |
@@ -19,15 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import ProjectCardLanguages from './ProjectCardLanguages'; | |||
import { Languages } from '../../../store/languages/reducer'; | |||
import { getLanguages } from '../../../store/rootReducer'; | |||
import { getLanguages, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
languages: Languages; | |||
} | |||
const stateToProps = (state: any) => ({ | |||
const stateToProps = (state: Store) => ({ | |||
languages: getLanguages(state) | |||
}); | |||
export default connect<StateProps>(stateToProps)(ProjectCardLanguages); | |||
export default connect(stateToProps)(ProjectCardLanguages); |
@@ -22,7 +22,7 @@ import OrganizationLink from '../../../components/ui/OrganizationLink'; | |||
interface Props { | |||
organization?: { key: string; name: string }; | |||
organizationsEnabled: boolean; | |||
organizationsEnabled?: boolean; | |||
} | |||
export default function ProjectCardOrganization({ organization, organizationsEnabled }: Props) { |
@@ -19,14 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import ProjectCardOrganization from './ProjectCardOrganization'; | |||
import { areThereCustomOrganizations } from '../../../store/rootReducer'; | |||
import { areThereCustomOrganizations, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
organizationsEnabled: boolean; | |||
} | |||
const stateToProps = (state: any) => ({ | |||
const stateToProps = (state: Store) => ({ | |||
organizationsEnabled: areThereCustomOrganizations(state) | |||
}); | |||
export default connect<StateProps>(stateToProps)(ProjectCardOrganization); | |||
export default connect(stateToProps)(ProjectCardOrganization); |
@@ -28,9 +28,9 @@ import ManualProjectCreate from './ManualProjectCreate'; | |||
import { serializeQuery, Query, parseQuery } from './utils'; | |||
import DeferredSpinner from '../../../components/common/DeferredSpinner'; | |||
import handleRequiredAuthentication from '../../../app/utils/handleRequiredAuthentication'; | |||
import { getCurrentUser } from '../../../store/rootReducer'; | |||
import { addGlobalErrorMessage } from '../../../store/globalMessages/duck'; | |||
import { skipOnboarding as skipOnboardingAction } from '../../../store/users/actions'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
import { addGlobalErrorMessage } from '../../../store/globalMessages'; | |||
import { skipOnboarding as skipOnboardingAction } from '../../../store/users'; | |||
import { CurrentUser, IdentityProvider, isLoggedIn, LoggedInUser } from '../../../app/types'; | |||
import { skipOnboarding, getIdentityProviders } from '../../../api/users'; | |||
import { translate } from '../../../helpers/l10n'; | |||
@@ -212,13 +212,13 @@ export class CreateProjectPage extends React.PureComponent<Props, State> { | |||
} | |||
} | |||
const mapStateToProps = (state: any): StateProps => ({ | |||
const mapStateToProps = (state: Store): StateProps => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
const mapDispatchToProps: DispatchProps = { addGlobalErrorMessage, skipOnboardingAction }; | |||
export default connect<StateProps, DispatchProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(CreateProjectPage); |
@@ -25,7 +25,7 @@ import Select from '../../../components/controls/Select'; | |||
import { Button, SubmitButton } from '../../../components/ui/buttons'; | |||
import { LoggedInUser, Organization } from '../../../app/types'; | |||
import { fetchMyOrganizations } from '../../account/organizations/actions'; | |||
import { getMyOrganizations } from '../../../store/rootReducer'; | |||
import { getMyOrganizations, Store } from '../../../store/rootReducer'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { createProject } from '../../../api/components'; | |||
import DeferredSpinner from '../../../components/common/DeferredSpinner'; | |||
@@ -217,12 +217,12 @@ const mapDispatchToProps = ({ | |||
fetchMyOrganizations | |||
} as any) as DispatchProps; | |||
const mapStateToProps = (state: any): StateProps => { | |||
const mapStateToProps = (state: Store): StateProps => { | |||
return { | |||
userOrganizations: getMyOrganizations(state) | |||
}; | |||
}; | |||
export default connect<StateProps, DispatchProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(ManualProjectCreate); |
@@ -23,7 +23,7 @@ import Filter from './Filter'; | |||
import FilterHeader from './FilterHeader'; | |||
import SearchableFilterFooter from './SearchableFilterFooter'; | |||
import SearchableFilterOption from './SearchableFilterOption'; | |||
import { getLanguageByKey, Languages } from '../../../store/languages/reducer'; | |||
import { getLanguageByKey, Languages } from '../../../store/languages'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { Facet } from '../types'; | |||
import { RawQuery } from '../../../helpers/query'; |
@@ -19,15 +19,10 @@ | |||
*/ | |||
import { connect } from 'react-redux'; | |||
import LanguagesFilter from './LanguagesFilter'; | |||
import { Languages } from '../../../store/languages/reducer'; | |||
import { getLanguages } from '../../../store/rootReducer'; | |||
import { getLanguages, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
languages: Languages; | |||
} | |||
const stateToProps = (state: any) => ({ | |||
const stateToProps = (state: Store) => ({ | |||
languages: getLanguages(state) | |||
}); | |||
export default connect<StateProps>(stateToProps)(LanguagesFilter); | |||
export default connect(stateToProps)(LanguagesFilter); |
@@ -29,7 +29,7 @@ import { Project } from '../types'; | |||
import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
interface Props { | |||
displayOrganizations: boolean; | |||
displayOrganizations?: boolean; | |||
projects: Project[]; | |||
sort?: string; | |||
total?: number; |
@@ -22,8 +22,8 @@ import { connect } from 'react-redux'; | |||
import App from './App'; | |||
import forSingleOrganization from '../organizations/forSingleOrganization'; | |||
import { Organization, LoggedInUser, Visibility } from '../../app/types'; | |||
import { getAppState, getOrganizationByKey, getCurrentUser } from '../../store/rootReducer'; | |||
import { receiveOrganizations } from '../../store/organizations/duck'; | |||
import { getAppState, getOrganizationByKey, getCurrentUser, Store } from '../../store/rootReducer'; | |||
import { receiveOrganizations } from '../../store/organizations'; | |||
import { changeProjectDefaultVisibility } from '../../api/permissions'; | |||
import { fetchOrganization } from '../organizations/actions'; | |||
@@ -40,6 +40,7 @@ interface DispatchProps { | |||
interface OwnProps { | |||
onRequestFail: (error: any) => void; | |||
organization: Organization; | |||
} | |||
class AppContainer extends React.PureComponent<OwnProps & StateProps & DispatchProps> { | |||
@@ -78,7 +79,7 @@ class AppContainer extends React.PureComponent<OwnProps & StateProps & DispatchP | |||
} | |||
} | |||
const mapStateToProps = (state: any, ownProps: any) => ({ | |||
const mapStateToProps = (state: Store, ownProps: OwnProps) => ({ | |||
appState: getAppState(state), | |||
currentUser: getCurrentUser(state) as LoggedInUser, | |||
organization: | |||
@@ -102,7 +103,7 @@ const mapDispatchToProps = (dispatch: Function) => ({ | |||
}); | |||
export default forSingleOrganization( | |||
connect<StateProps, DispatchProps, OwnProps>( | |||
connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(AppContainer) |
@@ -23,7 +23,7 @@ import Helmet from 'react-helmet'; | |||
import { connect } from 'react-redux'; | |||
import DetailsHeader from './DetailsHeader'; | |||
import DetailsContent from './DetailsContent'; | |||
import { getMetrics } from '../../../store/rootReducer'; | |||
import { getMetrics, Store } from '../../../store/rootReducer'; | |||
import { fetchMetrics } from '../../../store/rootActions'; | |||
import { fetchQualityGate } from '../../../api/quality-gates'; | |||
import { Metric, QualityGate, Condition } from '../../../app/types'; | |||
@@ -170,11 +170,11 @@ export class DetailsApp extends React.PureComponent<Props, State> { | |||
const mapDispatchToProps: DispatchToProps = { fetchMetrics }; | |||
const mapStateToProps = (state: any): StateToProps => ({ | |||
const mapStateToProps = (state: Store): StateToProps => ({ | |||
metrics: getMetrics(state) | |||
}); | |||
export default connect<StateToProps, DispatchToProps, OwnProps>( | |||
export default connect( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(DetailsApp); |
@@ -24,13 +24,12 @@ import { sortProfiles } from '../utils'; | |||
import { Exporter, Profile } from '../types'; | |||
import OrganizationHelmet from '../../../components/common/OrganizationHelmet'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { Languages } from '../../../store/languages/reducer'; | |||
import { Languages } from '../../../store/languages'; | |||
import '../styles.css'; | |||
interface Props { | |||
children: React.ReactElement<any>; | |||
languages: Languages; | |||
onRequestFail: (reasong: any) => void; | |||
organization: { name: string; key: string } | undefined; | |||
} | |||
@@ -103,7 +102,6 @@ export default class App extends React.PureComponent<Props, State> { | |||
languages: finalLanguages, | |||
exporters: this.state.exporters, | |||
updateProfiles: this.updateProfiles, | |||
onRequestFail: this.props.onRequestFail, | |||
organization: organization ? organization.key : null | |||
}); | |||
} |
@@ -20,33 +20,13 @@ | |||
import { connect } from 'react-redux'; | |||
import App from './App'; | |||
import forSingleOrganization from '../../organizations/forSingleOrganization'; | |||
import { getLanguages, getOrganizationByKey } from '../../../store/rootReducer'; | |||
import { onFail } from '../../../store/rootActions'; | |||
import { Languages } from '../../../store/languages/reducer'; | |||
import { getLanguages, getOrganizationByKey, Store } from '../../../store/rootReducer'; | |||
interface StateProps { | |||
languages: Languages; | |||
organization: { name: string; key: string } | undefined; | |||
} | |||
interface DispatchProps { | |||
onRequestFail: (reasong: any) => void; | |||
} | |||
const mapStateToProps = (state: any, ownProps: any) => ({ | |||
const mapStateToProps = (state: Store, ownProps: any) => ({ | |||
languages: getLanguages(state), | |||
organization: ownProps.params.organizationKey | |||
? getOrganizationByKey(state, ownProps.params.organizationKey) | |||
: undefined | |||
}); | |||
const mapDispatchToProps = (dispatch: any) => ({ | |||
onRequestFail: (error: any) => onFail(dispatch)(error) | |||
}); | |||
export default forSingleOrganization( | |||
connect<StateProps, DispatchProps>( | |||
mapStateToProps, | |||
mapDispatchToProps | |||
)(App) | |||
); | |||
export default forSingleOrganization(connect(mapStateToProps)(App)); |
@@ -27,7 +27,6 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
interface Props { | |||
onClose: () => void; | |||
onCopy: (name: string) => void; | |||
onRequestFail: (reasong: any) => void; | |||
profile: Profile; | |||
} | |||
@@ -61,11 +60,10 @@ export default class CopyProfileForm extends React.PureComponent<Props, State> { | |||
this.setState({ loading: true }); | |||
copyProfile(this.props.profile.key, name).then( | |||
(profile: any) => this.props.onCopy(profile.name), | |||
(error: any) => { | |||
() => { | |||
if (this.mounted) { | |||
this.setState({ loading: false }); | |||
} | |||
this.props.onRequestFail(error); | |||
} | |||
); | |||
} |
@@ -27,7 +27,6 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
interface Props { | |||
onClose: () => void; | |||
onDelete: () => void; | |||
onRequestFail: (reason: any) => void; | |||
profile: Profile; | |||
} | |||
@@ -51,11 +50,10 @@ export default class DeleteProfileForm extends React.PureComponent<Props, State> | |||
handleFormSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => { | |||
event.preventDefault(); | |||
this.setState({ loading: true }); | |||
deleteProfile(this.props.profile.key).then(this.props.onDelete, (error: any) => { | |||
deleteProfile(this.props.profile.key).then(this.props.onDelete, () => { | |||
if (this.mounted) { | |||
this.setState({ loading: false }); | |||
} | |||
this.props.onRequestFail(error); | |||
}); | |||
}; | |||
@@ -35,7 +35,6 @@ import ActionsDropdown, { | |||
interface Props { | |||
className?: string; | |||
fromList?: boolean; | |||
onRequestFail: (reasong: any) => void; | |||
organization: string | null; | |||
profile: Profile; | |||
updateProfiles: () => Promise<void>; | |||
@@ -198,7 +197,6 @@ export default class ProfileActions extends React.PureComponent<Props, State> { | |||
<CopyProfileForm | |||
onClose={this.closeCopyForm} | |||
onCopy={this.handleProfileCopy} | |||
onRequestFail={this.props.onRequestFail} | |||
profile={profile} | |||
/> | |||
)} | |||
@@ -207,7 +205,6 @@ export default class ProfileActions extends React.PureComponent<Props, State> { | |||
<DeleteProfileForm | |||
onClose={this.closeDeleteForm} | |||
onDelete={this.handleProfileDelete} | |||
onRequestFail={this.props.onRequestFail} | |||
profile={profile} | |||
/> | |||
)} | |||
@@ -216,7 +213,6 @@ export default class ProfileActions extends React.PureComponent<Props, State> { | |||
<RenameProfileForm | |||
onClose={this.closeRenameForm} | |||
onRename={this.handleProfileRename} | |||
onRequestFail={this.props.onRequestFail} | |||
profile={profile} | |||
/> | |||
)} |