1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { RootState } from 'store/store';
6 import { connect } from 'react-redux';
7 import { Dispatch } from 'redux';
8 import { ApiClientAuthorization } from 'models/api-client-authorization';
9 import { filterResources } from 'store/resources/resources';
10 import { ResourceKind } from 'models/resource';
13 SharingURLsComponentActionProps,
14 SharingURLsComponentDataProps
15 } from './sharing-urls-component';
19 } from 'store/snackbar/snackbar-actions';
20 import { deleteSharingToken } from 'store/sharing-dialog/sharing-dialog-actions';
22 const mapStateToProps =
23 (state: RootState, ownProps: { uuid: string }): SharingURLsComponentDataProps => {
24 const sharingTokens = filterResources(
25 (resource: ApiClientAuthorization) =>
26 resource.kind === ResourceKind.API_CLIENT_AUTHORIZATION &&
27 resource.scopes.includes(`GET /arvados/v1/collections/${ownProps.uuid}`) &&
28 resource.scopes.includes(`GET /arvados/v1/collections/${ownProps.uuid}/`) &&
29 resource.scopes.includes('GET /arvados/v1/keep_services/accessible')
30 )(state.resources) as ApiClientAuthorization[];
31 const sharingURLsPrefix = state.auth.config.keepWebInlineServiceUrl;
33 collectionUuid: ownProps.uuid,
39 const mapDispatchToProps = (dispatch: Dispatch): SharingURLsComponentActionProps => ({
40 onDeleteSharingToken(uuid: string) {
41 dispatch<any>(deleteSharingToken(uuid));
43 onCopy(message: string) {
44 dispatch(snackbarActions.OPEN_SNACKBAR({
47 kind: SnackbarKind.SUCCESS
52 export const SharingURLsContent = connect(mapStateToProps, mapDispatchToProps)(SharingURLsComponent)