```
{
"API_HOST": "string",
- "VOCABULARY_URL": "string"
+ "VOCABULARY_URL": "string",
+ "FILE_VIEWERS_CONFIG_URL": "string",
}
```
Local path, or any URL that allows cross-origin requests. See
[Vocabulary JSON file example](public/vocabulary-example.json).
+### FILE_VIEWERS_CONFIG_URL
+Local path, or any URL that allows cross-origin requests. See:
+
+[File viewers config file example](public/file-viewers-example.json)
+
+[File viewers config scheme](src/models/file-viewers-config.ts)
+
### Licensing
Arvados is Free Software. See COPYING for information about Arvados Free
"@material-ui/icons": "3.0.1",
"@types/debounce": "3.0.0",
"@types/js-yaml": "3.11.2",
+ "@types/jssha": "0.0.29",
"@types/lodash": "4.14.116",
"@types/react-copy-to-clipboard": "4.2.6",
"@types/react-dnd": "3.0.2",
"debounce": "1.2.0",
"is-image": "2.0.0",
"js-yaml": "3.12.0",
+ "jssha": "2.3.1",
"lodash": "4.17.11",
"react": "16.5.2",
"react-copy-to-clipboard": "5.0.1",
--- /dev/null
+[
+ {
+ "name": "File browser",
+ "extensions": [
+ ".txt",
+ ".zip"
+ ],
+ "url": "https://doc.arvados.org",
+ "filePathParam": "filePath",
+ "iconUrl": "https://material.io/tools/icons/static/icons/baseline-next_week-24px.svg"
+ },
+ {
+ "name": "Collection browser",
+ "extensions": [],
+ "collections": true,
+ "url": "https://doc.arvados.org",
+ "filePathParam": "collectionPath"
+ },
+ {
+ "name": "Universal browser",
+ "collections": true,
+ "url": "https://doc.arvados.org",
+ "filePathParam": "filePath"
+ }
+]
\ No newline at end of file
packageVersion: string;
parameters: {};
protocol: string;
- remoteHosts: string;
+ remoteHosts: {
+ [key: string]: string
+ };
remoteHostsViaDNS: boolean;
resources: {};
revision: string;
websocketUrl: string;
workbenchUrl: string;
vocabularyUrl: string;
+ fileViewersConfigUrl: string;
}
export const fetchConfig = () => {
.catch(() => Promise.resolve(getDefaultConfig()))
.then(config => Axios
.get<Config>(getDiscoveryURL(config.API_HOST))
- .then(response => ({
+ .then(response => ({
// TODO: After tests delete `|| '/vocabulary-example.json'`
- config: {...response.data, vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json' },
- apiHost: config.API_HOST,
+ // TODO: After tests delete `|| '/file-viewers-example.json'`
+ config: {
+ ...response.data,
+ vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json',
+ fileViewersConfigUrl: config.FILE_VIEWERS_CONFIG_URL || '/file-viewers-example.json'
+ },
+ apiHost: config.API_HOST,
})));
};
packageVersion: '',
parameters: {},
protocol: '',
- remoteHosts: '',
+ remoteHosts: {},
remoteHostsViaDNS: false,
resources: {},
revision: '',
websocketUrl: '',
workbenchUrl: '',
vocabularyUrl: '',
+ fileViewersConfigUrl: '',
...config
});
interface ConfigJSON {
API_HOST: string;
VOCABULARY_URL: string;
+ FILE_VIEWERS_CONFIG_URL: string;
}
const getDefaultConfig = (): ConfigJSON => ({
API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "",
VOCABULARY_URL: "",
+ FILE_VIEWERS_CONFIG_URL: "",
});
-const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/discovery/v1/apis/arvados/v1/rest`;
+export const DISCOVERY_URL = 'discovery/v1/apis/arvados/v1/rest';
+const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}`;
suggestions?: Suggestion[];
error?: boolean;
helperText?: string;
+ autofocus?: boolean;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
suggestionsOpen: boolean;
selectedSuggestionIndex: number;
}
+
export class Autocomplete<Value, Suggestion> extends React.Component<AutocompleteProps<Value, Suggestion>, AutocompleteState> {
state = {
renderInput() {
return <Input
+ autoFocus={this.props.autofocus}
inputRef={this.inputRef}
value={this.props.value}
startAdornment={this.renderChips()}
if (event.key === 'Enter') {
if (this.isSuggestionBoxOpen() && selectedSuggestionIndex < suggestions.length) {
// prevent form submissions when selecting a suggestion
- event.preventDefault();
+ event.preventDefault();
onSelect(suggestions[selectedSuggestionIndex]);
} else if (this.props.value.length > 0) {
onCreate();
renderChips() {
const { items, onDelete } = this.props;
+
+ /**
+ * If input startAdornment prop is not undefined, input's label will stay above the input.
+ * If there is not items, we want the label to go back to placeholder position.
+ * That why we return without a value instead of returning a result of a _map_ which is an empty array.
+ */
+ if (items.length === 0) {
+ return;
+ }
+
return items.map(
(item, index) =>
<Chip
{item.name}
</ListItemText>}
</ListItem>)}
- {groupIndex < items.length - 1 && <Divider />}
+ {
+ items[groupIndex + 1] &&
+ items[groupIndex + 1].length > 0 &&
+ <Divider />
+ }
</React.Fragment>)}
</List>
</Popover>;
paperProps?: PaperProps;
actions?: React.ReactNode;
hideSearchInput?: boolean;
+ paperKey?: string;
}
interface DataExplorerActionProps<T> {
columns, onContextMenu, onFiltersChange, onSortToggle, working, extractKey,
rowsPerPage, rowsPerPageOptions, onColumnToggle, searchValue, onSearch,
items, itemsAvailable, onRowClick, onRowDoubleClick, classes,
- dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput
+ dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput,
+ paperKey
} = this.props;
- return <Paper className={classes.root} {...paperProps}>
+ return <Paper className={classes.root} {...paperProps} key={paperKey}>
<Toolbar className={classes.toolbar}>
<Grid container justify="space-between" wrap="nowrap" alignItems="center">
{!hideSearchInput && <div className={classes.searchBox}>
onSortToggle={onSortToggle}
extractKey={extractKey}
working={working}
- defaultView={dataTableDefaultView}
- />
+ defaultView={dataTableDefaultView} />
<Toolbar className={classes.footer}>
<Grid container justify="flex-end">
<TablePagination
import Mail from '@material-ui/icons/Mail';
import MoveToInbox from '@material-ui/icons/MoveToInbox';
import Notifications from '@material-ui/icons/Notifications';
+import OpenInNew from '@material-ui/icons/OpenInNew';
import People from '@material-ui/icons/People';
import Person from '@material-ui/icons/Person';
import PersonAdd from '@material-ui/icons/PersonAdd';
export const MoveToIcon: IconType = (props) => <Input {...props} />;
export const NewProjectIcon: IconType = (props) => <CreateNewFolder {...props} />;
export const NotificationIcon: IconType = (props) => <Notifications {...props} />;
+export const OpenIcon: IconType = (props) => <OpenInNew {...props} />;
export const OutputIcon: IconType = (props) => <MoveToInbox {...props} />;
export const PaginationDownIcon: IconType = (props) => <ArrowDropDown {...props} />;
export const PaginationLeftArrowIcon: IconType = (props) => <ChevronLeft {...props} />;
import * as React from 'react';
import { WrappedFieldProps } from 'redux-form';
import { ArvadosTheme } from '~/common/custom-theme';
-import { TextField as MaterialTextField, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import {
+ TextField as MaterialTextField,
+ StyleRulesCallback,
+ WithStyles,
+ withStyles,
+ PropTypes
+} from '@material-ui/core';
import RichTextEditor from 'react-rte';
+import Margin = PropTypes.Margin;
type CssRules = 'textField';
type TextFieldProps = WrappedFieldProps & WithStyles<CssRules>;
-export const TextField = withStyles(styles)((props: TextFieldProps & {
- label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode
+export const TextField = withStyles(styles)((props: TextFieldProps & {
+ label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode, margin?: Margin, placeholder?: string
}) =>
<MaterialTextField
helperText={props.meta.touched && props.meta.error}
required={props.required}
select={props.select}
children={props.children}
+ margin={props.margin}
+ placeholder={props.placeholder}
{...props.input}
/>);
onChange={props.input.onChange}
value={props.input.value}
/>
- );
\ No newline at end of file
+ );
import { userActionSet } from '~/views-components/context-menu/action-sets/user-action-set';
import { computeNodeActionSet } from '~/views-components/context-menu/action-sets/compute-node-action-set';
import { apiClientAuthorizationActionSet } from '~/views-components/context-menu/action-sets/api-client-authorization-action-set';
+import { groupActionSet } from '~/views-components/context-menu/action-sets/group-action-set';
+import { groupMemberActionSet } from '~/views-components/context-menu/action-sets/group-member-action-set';
import { linkActionSet } from '~/views-components/context-menu/action-sets/link-action-set';
+import { loadFileViewersConfig } from '~/store/file-viewers/file-viewers-actions';
console.log(`Starting arvados [${getBuildInfo()}]`);
addMenuActionSet(ContextMenuKind.LINK, linkActionSet);
addMenuActionSet(ContextMenuKind.NODE, computeNodeActionSet);
addMenuActionSet(ContextMenuKind.API_CLIENT_AUTHORIZATION, apiClientAuthorizationActionSet);
+addMenuActionSet(ContextMenuKind.GROUPS, groupActionSet);
+addMenuActionSet(ContextMenuKind.GROUP_MEMBER, groupMemberActionSet);
fetchConfig()
.then(({ config, apiHost }) => {
const store = configureStore(history, services);
store.subscribe(initListener(history, store, services, config));
- store.dispatch(initAuth());
+ store.dispatch(initAuth(config));
store.dispatch(setBuildInfo());
store.dispatch(setCurrentTokenDialogApiHost(apiHost));
store.dispatch(setUuidPrefix(config.uuidPrefix));
store.dispatch(loadVocabulary);
+ store.dispatch(loadFileViewersConfig);
- const TokenComponent = (props: any) => <ApiToken authService={services.authService} {...props} />;
+ const TokenComponent = (props: any) => <ApiToken authService={services.authService} config={config} {...props} />;
const MainPanelComponent = (props: any) => <MainPanel {...props} />;
const App = () =>
--- /dev/null
+export interface ClientAuthorizationResource {
+ uuid: string;
+ apiToken: string;
+ apiClientId: number;
+ userId: number;
+ createdByIpAddress: string;
+ lastUsedByIpAddress: string;
+ lastUsedAt: string;
+ expiresAt: string;
+ ownerUuid: string;
+ scopes: string[];
+}
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export type FileViewerList = FileViewer[];
+
+export interface FileViewer {
+ /**
+ * Name is used as a label in file's context menu
+ */
+ name: string;
+
+ /**
+ * Limits files for which viewer is enabled
+ * If not given, viewer will be enabled for all files
+ * Viewer is enabled if file name ends with an extension.
+ *
+ * Example: `['.zip', '.tar.gz', 'bam']`
+ */
+ extensions?: string[];
+
+ /**
+ * Determines whether a viewer is enabled for collections.
+ */
+ collections?: boolean;
+
+ /**
+ * URL that redirects to a viewer
+ * Example: `https://bam-viewer.com`
+ */
+ url: string;
+
+ /**
+ * Name of a search param that will be used to send file's path to a viewer
+ * Example:
+ *
+ * `{ filePathParam: 'filePath' }`
+ *
+ * `https://bam-viewer.com?filePath=/path/to/file`
+ */
+ filePathParam: string;
+
+ /**
+ * Icon that will display next to a label
+ */
+ iconUrl?: string;
+}
//
// SPDX-License-Identifier: AGPL-3.0
-import { Resource } from "./resource";
import { TagProperty } from "~/models/tag";
-import { ResourceKind } from '~/models/resource';
+import { Resource, ResourceKind } from '~/models/resource';
export interface LinkResource extends Resource {
headUuid: string;
linkClass: string;
name: string;
properties: TagProperty;
+ kind: ResourceKind.LINK;
}
export enum LinkClass {
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export enum SessionStatus {
+ INVALIDATED,
+ BEING_VALIDATED,
+ VALIDATED
+}
+
+export interface Session {
+ clusterId: string;
+ remoteHost: string;
+ baseUrl: string;
+ username: string;
+ email: string;
+ token: string;
+ loggedIn: boolean;
+ status: SessionStatus;
+ active: boolean;
+}
import * as WorkbenchActions from '~/store/workbench/workbench-actions';
import { navigateToRootProject } from '~/store/navigation/navigation-action';
import { dialogActions } from '~/store/dialog/dialog-actions';
+import { contextMenuActions } from '~/store/context-menu/context-menu-actions';
+import { searchBarActions } from '~/store/search-bar/search-bar-actions';
export const addRouteChangeHandlers = (history: History, store: RootStore) => {
const handler = handleLocationChange(store);
const workflowMatch = Routes.matchWorkflowRoute(pathname);
const sshKeysUserMatch = Routes.matchSshKeysUserRoute(pathname);
const sshKeysAdminMatch = Routes.matchSshKeysAdminRoute(pathname);
+ const siteManagerMatch = Routes.matchSiteManagerRoute(pathname);
const keepServicesMatch = Routes.matchKeepServicesRoute(pathname);
const computeNodesMatch = Routes.matchComputeNodesRoute(pathname);
const apiClientAuthorizationsMatch = Routes.matchApiClientAuthorizationsRoute(pathname);
const myAccountMatch = Routes.matchMyAccountRoute(pathname);
const userMatch = Routes.matchUsersRoute(pathname);
+ const groupsMatch = Routes.matchGroupsRoute(pathname);
+ const groupDetailsMatch = Routes.matchGroupDetailsRoute(pathname);
const linksMatch = Routes.matchLinksRoute(pathname);
store.dispatch(dialogActions.CLOSE_ALL_DIALOGS());
+ store.dispatch(contextMenuActions.CLOSE_CONTEXT_MENU());
+ store.dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
if (projectMatch) {
store.dispatch(WorkbenchActions.loadProject(projectMatch.params.id));
store.dispatch(WorkbenchActions.loadSshKeys);
} else if (sshKeysAdminMatch) {
store.dispatch(WorkbenchActions.loadSshKeys);
+ } else if (siteManagerMatch) {
+ store.dispatch(WorkbenchActions.loadSiteManager);
} else if (keepServicesMatch) {
store.dispatch(WorkbenchActions.loadKeepServices);
} else if (computeNodesMatch) {
store.dispatch(WorkbenchActions.loadMyAccount);
} else if (userMatch) {
store.dispatch(WorkbenchActions.loadUsers);
+ } else if (groupsMatch) {
+ store.dispatch(WorkbenchActions.loadGroupsPanel);
+ } else if (groupDetailsMatch) {
+ store.dispatch(WorkbenchActions.loadGroupDetailsPanel(groupDetailsMatch.params.id));
} else if (linksMatch) {
store.dispatch(WorkbenchActions.loadLinks);
}
SEARCH_RESULTS: '/search-results',
SSH_KEYS_ADMIN: `/ssh-keys-admin`,
SSH_KEYS_USER: `/ssh-keys-user`,
+ SITE_MANAGER: `/site-manager`,
MY_ACCOUNT: '/my-account',
KEEP_SERVICES: `/keep-services`,
COMPUTE_NODES: `/nodes`,
USERS: '/users',
API_CLIENT_AUTHORIZATIONS: `/api_client_authorizations`,
+ GROUPS: '/groups',
+ GROUP_DETAILS: `/group/:id(${RESOURCE_UUID_PATTERN})`,
LINKS: '/links'
};
export const getProcessLogUrl = (uuid: string) => `/process-logs/${uuid}`;
+export const getGroupUrl = (uuid: string) => `/group/${uuid}`;
+
export interface ResourceRouteParams {
id: string;
}
export const matchSshKeysAdminRoute = (route: string) =>
matchPath(route, { path: Routes.SSH_KEYS_ADMIN });
+export const matchSiteManagerRoute = (route: string) =>
+ matchPath(route, { path: Routes.SITE_MANAGER });
+
export const matchMyAccountRoute = (route: string) =>
matchPath(route, { path: Routes.MY_ACCOUNT });
export const matchApiClientAuthorizationsRoute = (route: string) =>
matchPath(route, { path: Routes.API_CLIENT_AUTHORIZATIONS });
+export const matchGroupsRoute = (route: string) =>
+ matchPath(route, { path: Routes.GROUPS });
+
+export const matchGroupDetailsRoute = (route: string) =>
+ matchPath<ResourceRouteParams>(route, { path: Routes.GROUP_DETAILS });
+
export const matchLinksRoute = (route: string) =>
- matchPath(route, { path: Routes.LINKS });
\ No newline at end of file
+ matchPath(route, { path: Routes.LINKS });
export class FilterBuilder {
constructor(private filters = "") { }
- public addEqual(field: string, value?: string | boolean, resourcePrefix?: string) {
- return this.addCondition(field, "=", value, "", "", resourcePrefix );
+ public addEqual(field: string, value?: string | boolean | null, resourcePrefix?: string) {
+ return this.addCondition(field, "=", value, "", "", resourcePrefix);
}
public addLike(field: string, value?: string, resourcePrefix?: string) {
return this.filters;
}
- private addCondition(field: string, cond: string, value?: string | string[] | boolean, prefix: string = "", postfix: string = "", resourcePrefix?: string) {
- if (value) {
+ private addCondition(field: string, cond: string, value?: string | string[] | boolean | null, prefix: string = "", postfix: string = "", resourcePrefix?: string) {
+ if (value !== undefined) {
if (typeof value === "string") {
value = `"${prefix}${value}${postfix}"`;
} else if (Array.isArray(value)) {
value = `["${value.join(`","`)}"]`;
- } else {
+ } else if (value !== null) {
value = value ? "true" : "false";
}
//
// SPDX-License-Identifier: AGPL-3.0
-import { User, UserPrefs } from "~/models/user";
+import { getUserFullname, User, UserPrefs } from "~/models/user";
import { AxiosInstance } from "axios";
import { ApiActions } from "~/services/api/api-actions";
import * as uuid from "uuid/v4";
+import { Session, SessionStatus } from "~/models/session";
+import { Config } from "~/common/config";
+import { uniqBy } from "lodash";
export const API_TOKEN_KEY = 'apiToken';
export const USER_EMAIL_KEY = 'userEmail';
const uuidParts = uuid ? uuid.split('-') : [];
return uuidParts.length > 1 ? `${uuidParts[0]}-${uuidParts[1]}` : undefined;
}
+
+ public getSessions(): Session[] {
+ try {
+ const sessions = JSON.parse(localStorage.getItem("sessions") || '');
+ return sessions;
+ } catch {
+ return [];
+ }
+ }
+
+ public saveSessions(sessions: Session[]) {
+ localStorage.setItem("sessions", JSON.stringify(sessions));
+ }
+
+ public buildSessions(cfg: Config, user?: User) {
+ const currentSession = {
+ clusterId: cfg.uuidPrefix,
+ remoteHost: cfg.rootUrl,
+ baseUrl: cfg.baseUrl,
+ username: getUserFullname(user),
+ email: user ? user.email : '',
+ token: this.getApiToken(),
+ loggedIn: true,
+ active: true,
+ status: SessionStatus.VALIDATED
+ } as Session;
+ const localSessions = this.getSessions();
+ const cfgSessions = Object.keys(cfg.remoteHosts).map(clusterId => {
+ const remoteHost = cfg.remoteHosts[clusterId];
+ return {
+ clusterId,
+ remoteHost,
+ baseUrl: '',
+ username: '',
+ email: '',
+ token: '',
+ loggedIn: false,
+ active: false,
+ status: SessionStatus.INVALIDATED
+ } as Session;
+ });
+ const sessions = [currentSession]
+ .concat(localSessions)
+ .concat(cfgSessions);
+
+ const uniqSessions = uniqBy(sessions, 'clusterId');
+
+ return uniqSessions;
+ }
}
: this.webdavClient.defaults.baseURL;
return {
...file,
- url: baseUrl + file.url + '?api_token=' + this.authService.getApiToken()
+ url: baseUrl + file.url
};
}
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import Axios from 'axios';
+import { FileViewerList } from '~/models/file-viewers-config';
+
+export class FileViewersConfigService {
+ constructor(
+ private url: string
+ ) { }
+
+ get() {
+ return Axios
+ .get<FileViewerList>(this.url)
+ .then(response => response.data);
+ }
+}
import { AuthorizedKeysService } from '~/services/authorized-keys-service/authorized-keys-service';
import { VocabularyService } from '~/services/vocabulary-service/vocabulary-service';
import { NodeService } from '~/services/node-service/node-service';
+import { FileViewersConfigService } from '~/services/file-viewers-config-service/file-viewers-config-service';
export type ServiceRepository = ReturnType<typeof createServices>;
const tagService = new TagService(linkService);
const searchService = new SearchService();
const vocabularyService = new VocabularyService(config.vocabularyUrl);
+ const fileViewersConfig = new FileViewersConfigService(config.fileViewersConfigUrl);
return {
ancestorsService,
containerRequestService,
containerService,
favoriteService,
+ fileViewersConfig,
groupsService,
keepService,
linkService,
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import Axios from "axios";
+import { getUserFullname, User } from "~/models/user";
+import { authActions } from "~/store/auth/auth-action";
+import { Config, DISCOVERY_URL } from "~/common/config";
+import { Session, SessionStatus } from "~/models/session";
+import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { AuthService, UserDetailsResponse } from "~/services/auth-service/auth-service";
+import * as jsSHA from "jssha";
+
+const getRemoteHostBaseUrl = async (remoteHost: string): Promise<string | null> => {
+ let url = remoteHost;
+ if (url.indexOf('://') < 0) {
+ url = 'https://' + url;
+ }
+ const origin = new URL(url).origin;
+ let baseUrl: string | null = null;
+
+ try {
+ const resp = await Axios.get<Config>(`${origin}/${DISCOVERY_URL}`);
+ baseUrl = resp.data.baseUrl;
+ } catch (err) {
+ try {
+ const resp = await Axios.get<any>(`${origin}/status.json`);
+ baseUrl = resp.data.apiBaseURL;
+ } catch (err) {
+ }
+ }
+
+ if (baseUrl && baseUrl[baseUrl.length - 1] === '/') {
+ baseUrl = baseUrl.substr(0, baseUrl.length - 1);
+ }
+
+ return baseUrl;
+};
+
+const getUserDetails = async (baseUrl: string, token: string): Promise<UserDetailsResponse> => {
+ const resp = await Axios.get<UserDetailsResponse>(`${baseUrl}/users/current`, {
+ headers: {
+ Authorization: `OAuth2 ${token}`
+ }
+ });
+ return resp.data;
+};
+
+const getTokenUuid = async (baseUrl: string, token: string): Promise<string> => {
+ if (token.startsWith("v2/")) {
+ const uuid = token.split("/")[1];
+ return Promise.resolve(uuid);
+ }
+
+ const resp = await Axios.get(`${baseUrl}/api_client_authorizations`, {
+ headers: {
+ Authorization: `OAuth2 ${token}`
+ },
+ data: {
+ filters: JSON.stringify([['api_token', '=', token]])
+ }
+ });
+
+ return resp.data.items[0].uuid;
+};
+
+const getSaltedToken = (clusterId: string, tokenUuid: string, token: string) => {
+ const shaObj = new jsSHA("SHA-1", "TEXT");
+ let secret = token;
+ if (token.startsWith("v2/")) {
+ secret = token.split("/")[2];
+ }
+ shaObj.setHMACKey(secret, "TEXT");
+ shaObj.update(clusterId);
+ const hmac = shaObj.getHMAC("HEX");
+ return `v2/${tokenUuid}/${hmac}`;
+};
+
+const clusterLogin = async (clusterId: string, baseUrl: string, activeSession: Session): Promise<{user: User, token: string}> => {
+ const tokenUuid = await getTokenUuid(activeSession.baseUrl, activeSession.token);
+ const saltedToken = getSaltedToken(clusterId, tokenUuid, activeSession.token);
+ const user = await getUserDetails(baseUrl, saltedToken);
+ return {
+ user: {
+ firstName: user.first_name,
+ lastName: user.last_name,
+ uuid: user.uuid,
+ ownerUuid: user.owner_uuid,
+ email: user.email,
+ isAdmin: user.is_admin,
+ identityUrl: user.identity_url,
+ prefs: user.prefs
+ },
+ token: saltedToken
+ };
+};
+
+const getActiveSession = (sessions: Session[]): Session | undefined => sessions.find(s => s.active);
+
+export const validateCluster = async (remoteHost: string, clusterId: string, activeSession: Session): Promise<{ user: User; token: string, baseUrl: string }> => {
+ const baseUrl = await getRemoteHostBaseUrl(remoteHost);
+ if (!baseUrl) {
+ return Promise.reject(`Could not find base url for ${remoteHost}`);
+ }
+ const { user, token } = await clusterLogin(clusterId, baseUrl, activeSession);
+ return { baseUrl, user, token };
+};
+
+export const validateSession = (session: Session, activeSession: Session) =>
+ async (dispatch: Dispatch): Promise<Session> => {
+ dispatch(authActions.UPDATE_SESSION({ ...session, status: SessionStatus.BEING_VALIDATED }));
+ session.loggedIn = false;
+ try {
+ const { baseUrl, user, token } = await validateCluster(session.remoteHost, session.clusterId, activeSession);
+ session.baseUrl = baseUrl;
+ session.token = token;
+ session.email = user.email;
+ session.username = getUserFullname(user);
+ session.loggedIn = true;
+ } catch {
+ session.loggedIn = false;
+ } finally {
+ session.status = SessionStatus.VALIDATED;
+ dispatch(authActions.UPDATE_SESSION(session));
+ }
+ return session;
+ };
+
+export const validateSessions = () =>
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const sessions = getState().auth.sessions;
+ const activeSession = getActiveSession(sessions);
+ if (activeSession) {
+ dispatch(progressIndicatorActions.START_WORKING("sessionsValidation"));
+ for (const session of sessions) {
+ if (session.status === SessionStatus.INVALIDATED) {
+ await dispatch(validateSession(session, activeSession));
+ }
+ }
+ services.authService.saveSessions(sessions);
+ dispatch(progressIndicatorActions.STOP_WORKING("sessionsValidation"));
+ }
+ };
+
+export const addSession = (remoteHost: string) =>
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const sessions = getState().auth.sessions;
+ const activeSession = getActiveSession(sessions);
+ if (activeSession) {
+ const clusterId = remoteHost.match(/^(\w+)\./)![1];
+ if (sessions.find(s => s.clusterId === clusterId)) {
+ return Promise.reject("Cluster already exists");
+ }
+ try {
+ const { baseUrl, user, token } = await validateCluster(remoteHost, clusterId, activeSession);
+ const session = {
+ loggedIn: true,
+ status: SessionStatus.VALIDATED,
+ active: false,
+ email: user.email,
+ username: getUserFullname(user),
+ remoteHost,
+ baseUrl,
+ clusterId,
+ token
+ };
+
+ dispatch(authActions.ADD_SESSION(session));
+ services.authService.saveSessions(getState().auth.sessions);
+
+ return session;
+ } catch (e) {
+ }
+ }
+ return Promise.reject("Could not validate cluster");
+ };
+
+export const toggleSession = (session: Session) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ let s = { ...session };
+
+ if (session.loggedIn) {
+ s.loggedIn = false;
+ } else {
+ const sessions = getState().auth.sessions;
+ const activeSession = getActiveSession(sessions);
+ if (activeSession) {
+ s = await dispatch<any>(validateSession(s, activeSession)) as Session;
+ }
+ }
+
+ dispatch(authActions.UPDATE_SESSION(s));
+ services.authService.saveSessions(getState().auth.sessions);
+ };
+
+export const initSessions = (authService: AuthService, config: Config, user: User) =>
+ (dispatch: Dispatch<any>) => {
+ const sessions = authService.buildSessions(config, user);
+ authService.saveSessions(sessions);
+ dispatch(authActions.SET_SESSIONS(sessions));
+ };
+
+export const loadSiteManagerPanel = () =>
+ async (dispatch: Dispatch<any>) => {
+ try {
+ dispatch(setBreadcrumbs([{ label: 'Site Manager'}]));
+ dispatch(validateSessions());
+ } catch (e) {
+ return;
+ }
+ };
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { Dispatch } from "redux";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { snackbarActions } from "~/store/snackbar/snackbar-actions";
+import { FormErrors, reset, startSubmit, stopSubmit } from "redux-form";
+import { KeyType } from "~/models/ssh-key";
+import {
+ AuthorizedKeysServiceError,
+ getAuthorizedKeysServiceError
+} from "~/services/authorized-keys-service/authorized-keys-service";
+import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
+import {
+ authActions,
+} from "~/store/auth/auth-action";
+
+export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName';
+export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog';
+export const SSH_KEY_REMOVE_DIALOG = 'sshKeyRemoveDialog';
+export const SSH_KEY_ATTRIBUTES_DIALOG = 'sshKeyAttributesDialog';
+
+export interface SshKeyCreateFormDialogData {
+ publicKey: string;
+ name: string;
+}
+
+export const openSshKeyCreateDialog = () => dialogActions.OPEN_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME, data: {} });
+
+export const openPublicKeyDialog = (name: string, publicKey: string) =>
+ dialogActions.OPEN_DIALOG({ id: SSH_KEY_PUBLIC_KEY_DIALOG, data: { name, publicKey } });
+
+export const openSshKeyAttributesDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const sshKey = getState().auth.sshKeys.find(it => it.uuid === uuid);
+ dispatch(dialogActions.OPEN_DIALOG({ id: SSH_KEY_ATTRIBUTES_DIALOG, data: { sshKey } }));
+ };
+
+export const openSshKeyRemoveDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ dispatch(dialogActions.OPEN_DIALOG({
+ id: SSH_KEY_REMOVE_DIALOG,
+ data: {
+ title: 'Remove public key',
+ text: 'Are you sure you want to remove this public key?',
+ confirmButtonLabel: 'Remove',
+ uuid
+ }
+ }));
+ };
+
+export const removeSshKey = (uuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+ await services.authorizedKeysService.delete(uuid);
+ dispatch(authActions.REMOVE_SSH_KEY(uuid));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Public Key has been successfully removed.', hideDuration: 2000 }));
+ };
+
+export const createSshKey = (data: SshKeyCreateFormDialogData) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const userUuid = getState().auth.user!.uuid;
+ const { name, publicKey } = data;
+ dispatch(startSubmit(SSH_KEY_CREATE_FORM_NAME));
+ try {
+ const newSshKey = await services.authorizedKeysService.create({
+ name,
+ publicKey,
+ keyType: KeyType.SSH,
+ authorizedUserUuid: userUuid
+ });
+ dispatch(authActions.ADD_SSH_KEY(newSshKey));
+ dispatch(dialogActions.CLOSE_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME }));
+ dispatch(reset(SSH_KEY_CREATE_FORM_NAME));
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: "Public key has been successfully created.",
+ hideDuration: 2000
+ }));
+ } catch (e) {
+ const error = getAuthorizedKeysServiceError(e);
+ if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
+ dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' } as FormErrors));
+ } else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
+ dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' } as FormErrors));
+ }
+ }
+ };
+
+export const loadSshKeysPanel = () =>
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ try {
+ dispatch(setBreadcrumbs([{ label: 'SSH Keys'}]));
+ const response = await services.authorizedKeysService.list();
+ dispatch(authActions.SET_SSH_KEYS(response.items));
+ } catch (e) {
+ return;
+ }
+ };
+
import { createServices } from "~/services/services";
import { configureStore, RootStore } from "../store";
import createBrowserHistory from "history/createBrowserHistory";
-import { mockConfig } from '~/common/config';
+import { Config, mockConfig } from '~/common/config';
import { ApiActions } from "~/services/api/api-actions";
describe('auth-actions', () => {
localStorage.setItem(USER_OWNER_UUID_KEY, "ownerUuid");
localStorage.setItem(USER_IS_ADMIN, JSON.stringify("false"));
- store.dispatch(initAuth());
+ const config: any = {
+ remoteHosts: { "xc59": "xc59.api.arvados.com" }
+ };
+
+ store.dispatch(initAuth(config));
expect(store.getState().auth).toEqual({
apiToken: "token",
sshKeys: [],
+ sessions: [{
+ "active": true,
+ "baseUrl": undefined,
+ "clusterId": undefined,
+ "email": "test@test.com",
+ "loggedIn": true,
+ "remoteHost": undefined,
+ "status": 2,
+ "token": "token",
+ "username": "John Doe"
+ }, {
+ "active": false,
+ "baseUrl": "",
+ "clusterId": "xc59",
+ "email": "",
+ "loggedIn": false,
+ "remoteHost": "xc59.api.arvados.com",
+ "status": 0,
+ "token": "",
+ "username": ""
+ }],
user: {
email: "test@test.com",
firstName: "John",
import { ofType, unionize, UnionOf } from '~/common/unionize';
import { Dispatch } from "redux";
-import { reset, stopSubmit, startSubmit, FormErrors } from 'redux-form';
import { AxiosInstance } from "axios";
import { RootState } from "../store";
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { dialogActions } from '~/store/dialog/dialog-actions';
-import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
import { ServiceRepository } from "~/services/services";
-import { getAuthorizedKeysServiceError, AuthorizedKeysServiceError } from '~/services/authorized-keys-service/authorized-keys-service';
-import { KeyType, SshKeyResource } from '~/models/ssh-key';
+import { SshKeyResource } from '~/models/ssh-key';
import { User } from "~/models/user";
-import * as Routes from '~/routes/routes';
+import { Session } from "~/models/session";
+import { Config } from '~/common/config';
+import { initSessions } from "~/store/auth/auth-action-session";
export const authActions = unionize({
SAVE_API_TOKEN: ofType<string>(),
USER_DETAILS_SUCCESS: ofType<User>(),
SET_SSH_KEYS: ofType<SshKeyResource[]>(),
ADD_SSH_KEY: ofType<SshKeyResource>(),
- REMOVE_SSH_KEY: ofType<string>()
+ REMOVE_SSH_KEY: ofType<string>(),
+ SET_SESSIONS: ofType<Session[]>(),
+ ADD_SESSION: ofType<Session>(),
+ REMOVE_SESSION: ofType<string>(),
+ UPDATE_SESSION: ofType<Session>()
});
-export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName';
-export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog';
-export const SSH_KEY_REMOVE_DIALOG = 'sshKeyRemoveDialog';
-export const SSH_KEY_ATTRIBUTES_DIALOG = 'sshKeyAttributesDialog';
-
-export interface SshKeyCreateFormDialogData {
- publicKey: string;
- name: string;
-}
-
function setAuthorizationHeader(services: ServiceRepository, token: string) {
services.apiClient.defaults.headers.common = {
Authorization: `OAuth2 ${token}`
delete client.defaults.headers.common.Authorization;
}
-export const initAuth = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const user = services.authService.getUser();
const token = services.authService.getApiToken();
if (token) {
}
if (token && user) {
dispatch(authActions.INIT({ user, token }));
+ dispatch<any>(initSessions(services.authService, config, user));
}
};
});
};
-export const openSshKeyCreateDialog = () => dialogActions.OPEN_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME, data: {} });
-
-export const openPublicKeyDialog = (name: string, publicKey: string) =>
- dialogActions.OPEN_DIALOG({ id: SSH_KEY_PUBLIC_KEY_DIALOG, data: { name, publicKey } });
-
-export const openSshKeyAttributesDialog = (uuid: string) =>
- (dispatch: Dispatch, getState: () => RootState) => {
- const sshKey = getState().auth.sshKeys.find(it => it.uuid === uuid);
- dispatch(dialogActions.OPEN_DIALOG({ id: SSH_KEY_ATTRIBUTES_DIALOG, data: { sshKey } }));
- };
-
-export const openSshKeyRemoveDialog = (uuid: string) =>
- (dispatch: Dispatch, getState: () => RootState) => {
- dispatch(dialogActions.OPEN_DIALOG({
- id: SSH_KEY_REMOVE_DIALOG,
- data: {
- title: 'Remove public key',
- text: 'Are you sure you want to remove this public key?',
- confirmButtonLabel: 'Remove',
- uuid
- }
- }));
- };
-
-export const removeSshKey = (uuid: string) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
- await services.authorizedKeysService.delete(uuid);
- dispatch(authActions.REMOVE_SSH_KEY(uuid));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Public Key has been successfully removed.', hideDuration: 2000 }));
- };
-
-export const createSshKey = (data: SshKeyCreateFormDialogData) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const userUuid = getState().auth.user!.uuid;
- const { name, publicKey } = data;
- dispatch(startSubmit(SSH_KEY_CREATE_FORM_NAME));
- try {
- const newSshKey = await services.authorizedKeysService.create({
- name,
- publicKey,
- keyType: KeyType.SSH,
- authorizedUserUuid: userUuid
- });
- dispatch(authActions.ADD_SSH_KEY(newSshKey));
- dispatch(dialogActions.CLOSE_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME }));
- dispatch(reset(SSH_KEY_CREATE_FORM_NAME));
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Public key has been successfully created.",
- hideDuration: 2000
- }));
- } catch (e) {
- const error = getAuthorizedKeysServiceError(e);
- if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
- dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' } as FormErrors));
- } else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
- dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' } as FormErrors));
- }
- }
- };
-
-export const loadSshKeysPanel = () =>
- async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
- try {
- const userUuid = getState().auth.user!.uuid;
- const { router } = getState();
- const pathname = router.location ? router.location.pathname : '';
- dispatch(setBreadcrumbs([{ label: 'SSH Keys' }]));
- const response = await services.authorizedKeysService.list();
- const userSshKeys = response.items.find(it => it.ownerUuid === userUuid);
- return Routes.matchSshKeysAdminRoute(pathname) ? dispatch(authActions.SET_SSH_KEYS(response.items)) : dispatch(authActions.SET_SSH_KEYS([userSshKeys!]));
- } catch (e) {
- return;
- }
- };
-
export type AuthAction = UnionOf<typeof authActions>;
expect(state).toEqual({
apiToken: "token",
user,
- sshKeys: []
+ sshKeys: [],
+ sessions: []
});
});
expect(state).toEqual({
apiToken: "token",
user: undefined,
- sshKeys: []
+ sshKeys: [],
+ sessions: []
});
});
expect(state).toEqual({
apiToken: undefined,
sshKeys: [],
+ sessions: [],
user: {
email: "test@test.com",
firstName: "John",
import { User } from "~/models/user";
import { ServiceRepository } from "~/services/services";
import { SshKeyResource } from '~/models/ssh-key';
+import { Session } from "~/models/session";
export interface AuthState {
user?: User;
apiToken?: string;
sshKeys: SshKeyResource[];
+ sessions: Session[];
}
const initialState: AuthState = {
user: undefined,
apiToken: undefined,
- sshKeys: []
+ sshKeys: [],
+ sessions: []
};
export const authReducer = (services: ServiceRepository) => (state = initialState, action: AuthAction) => {
REMOVE_SSH_KEY: (uuid: string) => {
return { ...state, sshKeys: state.sshKeys.filter((sshKey) => sshKey.uuid !== uuid )};
},
+ SET_SESSIONS: (sessions: Session[]) => {
+ return { ...state, sessions };
+ },
+ ADD_SESSION: (session: Session) => {
+ return { ...state, sessions: state.sessions.concat(session) };
+ },
+ REMOVE_SESSION: (clusterId: string) => {
+ return {
+ ...state,
+ sessions: state.sessions.filter(
+ session => session.clusterId !== clusterId
+ )};
+ },
+ UPDATE_SESSION: (session: Session) => {
+ return {
+ ...state,
+ sessions: state.sessions.map(
+ s => s.clusterId === session.clusterId ? session : s
+ )};
+ },
default: () => state
});
};
import { SidePanelTreeCategory, activateSidePanelTreeItem } from '~/store/side-panel-tree/side-panel-tree-actions';
import { updateResources } from '../resources/resources-actions';
import { ResourceKind } from '~/models/resource';
+import { GroupResource } from '~/models/group';
export const BREADCRUMBS = 'breadcrumbs';
dispatch<any>(setProjectBreadcrumbs(process.containerRequest.ownerUuid));
}
};
+
+export const GROUPS_PANEL_LABEL = 'Groups';
+
+export const setGroupsBreadcrumbs = () =>
+ setBreadcrumbs([{ label: GROUPS_PANEL_LABEL }]);
+
+export const setGroupDetailsBreadcrumbs = (groupUuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+
+ const group = getResource<GroupResource>(groupUuid)(getState().resources);
+
+ const breadcrumbs: ResourceBreadcrumb[] = [
+ { label: GROUPS_PANEL_LABEL, uuid: GROUPS_PANEL_LABEL },
+ { label: group ? group.name : groupUuid, uuid: groupUuid },
+ ];
+
+ dispatch(setBreadcrumbs(breadcrumbs));
+
+ };
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from 'redux';
+import { ServiceRepository } from '~/services/services';
+import { propertiesActions } from '~/store/properties/properties-actions';
+import { FILE_VIEWERS_PROPERTY_NAME, DEFAULT_FILE_VIEWERS } from '~/store/file-viewers/file-viewers-selectors';
+import { FileViewerList } from '~/models/file-viewers-config';
+
+export const loadFileViewersConfig = async (dispatch: Dispatch, _: {}, { fileViewersConfig }: ServiceRepository) => {
+
+ let config: FileViewerList;
+ try{
+ config = await fileViewersConfig.get();
+ } catch (e){
+ config = DEFAULT_FILE_VIEWERS;
+ }
+
+ dispatch(propertiesActions.SET_PROPERTY({
+ key: FILE_VIEWERS_PROPERTY_NAME,
+ value: config,
+ }));
+
+};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { PropertiesState, getProperty } from '~/store/properties/properties';
+import { FileViewerList } from '~/models/file-viewers-config';
+
+export const FILE_VIEWERS_PROPERTY_NAME = 'fileViewers';
+
+export const DEFAULT_FILE_VIEWERS: FileViewerList = [];
+export const getFileViewers = (state: PropertiesState) =>
+ getProperty<FileViewerList>(FILE_VIEWERS_PROPERTY_NAME)(state) || DEFAULT_FILE_VIEWERS;
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action';
+import { Dispatch } from 'redux';
+import { propertiesActions } from '~/store/properties/properties-actions';
+import { getProperty } from '~/store/properties/properties';
+import { Person } from '~/views-components/sharing-dialog/people-select';
+import { dialogActions } from '~/store/dialog/dialog-actions';
+import { reset, startSubmit } from 'redux-form';
+import { addGroupMember, deleteGroupMember } from '~/store/groups-panel/groups-panel-actions';
+import { getResource } from '~/store/resources/resources';
+import { GroupResource } from '~/models/group';
+import { RootState } from '~/store/store';
+import { ServiceRepository } from '~/services/services';
+import { PermissionResource } from '~/models/permission';
+import { GroupDetailsPanel } from '~/views/group-details-panel/group-details-panel';
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { UserResource, getUserFullname } from '~/models/user';
+
+export const GROUP_DETAILS_PANEL_ID = 'groupDetailsPanel';
+export const ADD_GROUP_MEMBERS_DIALOG = 'addGrupMembers';
+export const ADD_GROUP_MEMBERS_FORM = 'addGrupMembers';
+export const ADD_GROUP_MEMBERS_USERS_FIELD_NAME = 'users';
+export const MEMBER_ATTRIBUTES_DIALOG = 'memberAttributesDialog';
+export const MEMBER_REMOVE_DIALOG = 'memberRemoveDialog';
+
+export const GroupDetailsPanelActions = bindDataExplorerActions(GROUP_DETAILS_PANEL_ID);
+
+export const loadGroupDetailsPanel = (groupUuid: string) =>
+ (dispatch: Dispatch) => {
+ dispatch(propertiesActions.SET_PROPERTY({ key: GROUP_DETAILS_PANEL_ID, value: groupUuid }));
+ dispatch(GroupDetailsPanelActions.REQUEST_ITEMS());
+ };
+
+export const getCurrentGroupDetailsPanelUuid = getProperty<string>(GROUP_DETAILS_PANEL_ID);
+
+export interface AddGroupMembersFormData {
+ [ADD_GROUP_MEMBERS_USERS_FIELD_NAME]: Person[];
+}
+
+export const openAddGroupMembersDialog = () =>
+ (dispatch: Dispatch) => {
+ dispatch(dialogActions.OPEN_DIALOG({ id: ADD_GROUP_MEMBERS_DIALOG, data: {} }));
+ dispatch(reset(ADD_GROUP_MEMBERS_FORM));
+ };
+
+export const addGroupMembers = ({ users }: AddGroupMembersFormData) =>
+
+ async (dispatch: Dispatch, getState: () => RootState, { permissionService }: ServiceRepository) => {
+
+ const groupUuid = getCurrentGroupDetailsPanelUuid(getState().properties);
+
+ if (groupUuid) {
+
+ dispatch(startSubmit(ADD_GROUP_MEMBERS_FORM));
+
+ const group = getResource<GroupResource>(groupUuid)(getState().resources);
+
+ for (const user of users) {
+
+ await addGroupMember({
+ user,
+ group: {
+ uuid: groupUuid,
+ name: group ? group.name : groupUuid,
+ },
+ dispatch,
+ permissionService,
+ });
+
+ }
+
+ dispatch(dialogActions.CLOSE_DIALOG({ id: ADD_GROUP_MEMBERS_FORM }));
+ dispatch(GroupDetailsPanelActions.REQUEST_ITEMS());
+
+ }
+ };
+
+export const openGroupMemberAttributes = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const { resources } = getState();
+ const data = getResource<PermissionResource>(uuid)(resources);
+ dispatch(dialogActions.OPEN_DIALOG({ id: MEMBER_ATTRIBUTES_DIALOG, data }));
+ };
+
+export const openRemoveGroupMemberDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(dialogActions.OPEN_DIALOG({
+ id: MEMBER_REMOVE_DIALOG,
+ data: {
+ title: 'Remove member',
+ text: 'Are you sure you want to remove this member from this group?',
+ confirmButtonLabel: 'Remove',
+ uuid
+ }
+ }));
+ };
+
+export const removeGroupMember = (uuid: string) =>
+
+ async (dispatch: Dispatch, getState: () => RootState, { permissionService }: ServiceRepository) => {
+
+ const groupUuid = getCurrentGroupDetailsPanelUuid(getState().properties);
+
+ if (groupUuid) {
+
+ const group = getResource<GroupResource>(groupUuid)(getState().resources);
+ const user = getResource<UserResource>(groupUuid)(getState().resources);
+
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+
+ await deleteGroupMember({
+ user: {
+ uuid,
+ name: user ? getUserFullname(user) : uuid,
+ },
+ group: {
+ uuid: groupUuid,
+ name: group ? group.name : groupUuid,
+ },
+ permissionService,
+ dispatch,
+ });
+
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ dispatch(GroupDetailsPanelActions.REQUEST_ITEMS());
+
+ }
+
+ };
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, MiddlewareAPI } from "redux";
+import { DataExplorerMiddlewareService, listResultsToDataExplorerItemsMeta } from "~/store/data-explorer/data-explorer-middleware-service";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { getDataExplorer } from "~/store/data-explorer/data-explorer-reducer";
+import { FilterBuilder } from '~/services/api/filter-builder';
+import { updateResources } from '~/store/resources/resources-actions';
+import { getCurrentGroupDetailsPanelUuid, GroupDetailsPanelActions } from '~/store/group-details-panel/group-details-panel-actions';
+import { LinkClass } from '~/models/link';
+
+export class GroupDetailsPanelMiddlewareService extends DataExplorerMiddlewareService {
+
+ constructor(private services: ServiceRepository, id: string) {
+ super(id);
+ }
+
+ async requestItems(api: MiddlewareAPI<Dispatch, RootState>) {
+
+ const dataExplorer = getDataExplorer(api.getState().dataExplorer, this.getId());
+ const groupUuid = getCurrentGroupDetailsPanelUuid(api.getState().properties);
+
+ if (!dataExplorer || !groupUuid) {
+
+ api.dispatch(groupsDetailsPanelDataExplorerIsNotSet());
+
+ } else {
+
+ try {
+
+ const permissions = await this.services.permissionService.list({
+
+ filters: new FilterBuilder()
+ .addEqual('tailUuid', groupUuid)
+ .addEqual('linkClass', LinkClass.PERMISSION)
+ .getFilters()
+
+ });
+
+ api.dispatch(updateResources(permissions.items));
+
+ const users = await this.services.userService.list({
+
+ filters: new FilterBuilder()
+ .addIn('uuid', permissions.items.map(item => item.headUuid))
+ .getFilters()
+
+ });
+
+ api.dispatch(GroupDetailsPanelActions.SET_ITEMS({
+ ...listResultsToDataExplorerItemsMeta(permissions),
+ items: users.items.map(item => item.uuid),
+ }));
+
+ api.dispatch(updateResources(users.items));
+
+ } catch (e) {
+
+ api.dispatch(couldNotFetchGroupDetailsContents());
+
+ }
+ }
+ }
+}
+
+const groupsDetailsPanelDataExplorerIsNotSet = () =>
+ snackbarActions.OPEN_SNACKBAR({
+ message: 'Group details panel is not ready.'
+ });
+
+const couldNotFetchGroupDetailsContents = () =>
+ snackbarActions.OPEN_SNACKBAR({
+ message: 'Could not fetch group details.',
+ kind: SnackbarKind.ERROR
+ });
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from 'redux';
+import { reset, startSubmit, stopSubmit, FormErrors } from 'redux-form';
+import { bindDataExplorerActions } from "~/store/data-explorer/data-explorer-action";
+import { dialogActions } from '~/store/dialog/dialog-actions';
+import { Person } from '~/views-components/sharing-dialog/people-select';
+import { RootState } from '~/store/store';
+import { ServiceRepository } from '~/services/services';
+import { getResource } from '~/store/resources/resources';
+import { GroupResource } from '~/models/group';
+import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { PermissionLevel, PermissionResource } from '~/models/permission';
+import { PermissionService } from '~/services/permission-service/permission-service';
+import { FilterBuilder } from '~/services/api/filter-builder';
+
+export const GROUPS_PANEL_ID = "groupsPanel";
+export const CREATE_GROUP_DIALOG = "createGroupDialog";
+export const CREATE_GROUP_FORM = "createGroupForm";
+export const CREATE_GROUP_NAME_FIELD_NAME = 'name';
+export const CREATE_GROUP_USERS_FIELD_NAME = 'users';
+export const GROUP_ATTRIBUTES_DIALOG = 'groupAttributesDialog';
+export const GROUP_REMOVE_DIALOG = 'groupRemoveDialog';
+
+export const GroupsPanelActions = bindDataExplorerActions(GROUPS_PANEL_ID);
+
+export const loadGroupsPanel = () => GroupsPanelActions.REQUEST_ITEMS();
+
+export const openCreateGroupDialog = () =>
+ (dispatch: Dispatch) => {
+ dispatch(dialogActions.OPEN_DIALOG({ id: CREATE_GROUP_DIALOG, data: {} }));
+ dispatch(reset(CREATE_GROUP_FORM));
+ };
+
+export const openGroupAttributes = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const { resources } = getState();
+ const data = getResource<GroupResource>(uuid)(resources);
+ dispatch(dialogActions.OPEN_DIALOG({ id: GROUP_ATTRIBUTES_DIALOG, data }));
+ };
+
+export const removeGroup = (uuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+ await services.groupsService.delete(uuid);
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ dispatch<any>(loadGroupsPanel());
+ };
+
+export const openRemoveGroupDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(dialogActions.OPEN_DIALOG({
+ id: GROUP_REMOVE_DIALOG,
+ data: {
+ title: 'Remove group',
+ text: 'Are you sure you want to remove this group?',
+ confirmButtonLabel: 'Remove',
+ uuid
+ }
+ }));
+ };
+
+export interface CreateGroupFormData {
+ [CREATE_GROUP_NAME_FIELD_NAME]: string;
+ [CREATE_GROUP_USERS_FIELD_NAME]?: Person[];
+}
+
+export const createGroup = ({ name, users = [] }: CreateGroupFormData) =>
+ async (dispatch: Dispatch, _: {}, { groupsService, permissionService }: ServiceRepository) => {
+
+ dispatch(startSubmit(CREATE_GROUP_FORM));
+
+ try {
+
+ const newGroup = await groupsService.create({ name });
+
+ for (const user of users) {
+
+ await addGroupMember({
+ user,
+ group: newGroup,
+ dispatch,
+ permissionService,
+ });
+
+ }
+
+ dispatch(dialogActions.CLOSE_DIALOG({ id: CREATE_GROUP_DIALOG }));
+ dispatch(reset(CREATE_GROUP_FORM));
+ dispatch(loadGroupsPanel());
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: `${newGroup.name} group has been created`,
+ kind: SnackbarKind.SUCCESS
+ }));
+
+ return newGroup;
+
+ } catch (e) {
+
+ const error = getCommonResourceServiceError(e);
+ if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+ dispatch(stopSubmit(CREATE_GROUP_FORM, { name: 'Group with the same name already exists.' } as FormErrors));
+ }
+
+ return;
+
+ }
+ };
+
+interface AddGroupMemberArgs {
+ user: { uuid: string, name: string };
+ group: { uuid: string, name: string };
+ dispatch: Dispatch;
+ permissionService: PermissionService;
+}
+
+/**
+ * Group membership is determined by whether the group has can_read permission on an object.
+ * If a group G can_read an object A, then we say A is a member of G.
+ *
+ * [Permission model docs](https://doc.arvados.org/api/permission-model.html)
+ */
+export const addGroupMember = async ({ user, group, ...args }: AddGroupMemberArgs) => {
+
+ await createPermission({
+ head: { ...user },
+ tail: { ...group },
+ permissionLevel: PermissionLevel.CAN_READ,
+ ...args,
+ });
+
+};
+
+interface CreatePermissionLinkArgs {
+ head: { uuid: string, name: string };
+ tail: { uuid: string, name: string };
+ permissionLevel: PermissionLevel;
+ dispatch: Dispatch;
+ permissionService: PermissionService;
+}
+
+const createPermission = async ({ head, tail, permissionLevel, dispatch, permissionService }: CreatePermissionLinkArgs) => {
+
+ try {
+
+ await permissionService.create({
+ tailUuid: tail.uuid,
+ headUuid: head.uuid,
+ name: permissionLevel,
+ });
+
+ } catch (e) {
+
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: `Could not add ${tail.name} -> ${head.name} relation`,
+ kind: SnackbarKind.ERROR,
+ }));
+
+ }
+
+};
+
+interface DeleteGroupMemberArgs {
+ user: { uuid: string, name: string };
+ group: { uuid: string, name: string };
+ dispatch: Dispatch;
+ permissionService: PermissionService;
+}
+
+export const deleteGroupMember = async ({ user, group, ...args }: DeleteGroupMemberArgs) => {
+
+ await deletePermission({
+ tail: group,
+ head: user,
+ ...args,
+ });
+
+};
+
+interface DeletePermissionLinkArgs {
+ head: { uuid: string, name: string };
+ tail: { uuid: string, name: string };
+ dispatch: Dispatch;
+ permissionService: PermissionService;
+}
+
+export const deletePermission = async ({ head, tail, dispatch, permissionService }: DeletePermissionLinkArgs) => {
+
+ try {
+
+ const permissionsResponse = await permissionService.list({
+
+ filters: new FilterBuilder()
+ .addEqual('tailUuid', tail.uuid)
+ .addEqual('headUuid', head.uuid)
+ .getFilters()
+
+ });
+
+ const [permission] = permissionsResponse.items;
+
+ if (permission) {
+
+ await permissionService.delete(permission.uuid);
+
+ } else {
+
+ throw new Error('Permission not found');
+
+ }
+
+
+ } catch (e) {
+
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: `Could not delete ${tail.name} -> ${head.name} relation`,
+ kind: SnackbarKind.ERROR,
+ }));
+
+ }
+
+};
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, MiddlewareAPI } from "redux";
+import { DataExplorerMiddlewareService, listResultsToDataExplorerItemsMeta, dataExplorerToListParams } from "~/store/data-explorer/data-explorer-middleware-service";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { getDataExplorer, DataExplorer, getSortColumn } from "~/store/data-explorer/data-explorer-reducer";
+import { GroupsPanelActions } from '~/store/groups-panel/groups-panel-actions';
+import { FilterBuilder } from '~/services/api/filter-builder';
+import { updateResources } from '~/store/resources/resources-actions';
+import { OrderBuilder, OrderDirection } from '~/services/api/order-builder';
+import { GroupResource, GroupClass } from '~/models/group';
+import { SortDirection } from '~/components/data-table/data-column';
+import { GroupsPanelColumnNames } from '~/views/groups-panel/groups-panel';
+
+export class GroupsPanelMiddlewareService extends DataExplorerMiddlewareService {
+
+ constructor(private services: ServiceRepository, id: string) {
+ super(id);
+ }
+
+ async requestItems(api: MiddlewareAPI<Dispatch, RootState>) {
+
+ const dataExplorer = getDataExplorer(api.getState().dataExplorer, this.getId());
+
+ if (!dataExplorer) {
+
+ api.dispatch(groupsPanelDataExplorerIsNotSet());
+
+ } else {
+
+ try {
+
+ const order = new OrderBuilder<GroupResource>();
+ const sortColumn = getSortColumn(dataExplorer);
+ if (sortColumn) {
+ const direction =
+ sortColumn.sortDirection === SortDirection.ASC && sortColumn.name === GroupsPanelColumnNames.GROUP
+ ? OrderDirection.ASC
+ : OrderDirection.DESC;
+
+ order.addOrder(direction, 'name');
+ }
+
+ const filters = new FilterBuilder()
+ .addNotIn('groupClass', [GroupClass.PROJECT])
+ .addILike('name', dataExplorer.searchValue)
+ .getFilters();
+
+ const response = await this.services.groupsService
+ .list({
+ ...dataExplorerToListParams(dataExplorer),
+ filters,
+ order: order.getOrder(),
+ });
+
+ api.dispatch(updateResources(response.items));
+
+ api.dispatch(GroupsPanelActions.SET_ITEMS({
+ ...listResultsToDataExplorerItemsMeta(response),
+ items: response.items.map(item => item.uuid),
+ }));
+
+ const permissions = await this.services.permissionService.list({
+
+ filters: new FilterBuilder()
+ .addIn('tailUuid', response.items.map(item => item.uuid))
+ .getFilters()
+
+ });
+
+ api.dispatch(updateResources(permissions.items));
+
+
+ } catch (e) {
+
+ api.dispatch(couldNotFetchFavoritesContents());
+
+ }
+ }
+ }
+}
+
+const groupsPanelDataExplorerIsNotSet = () =>
+ snackbarActions.OPEN_SNACKBAR({
+ message: 'Groups panel is not ready.'
+ });
+
+const couldNotFetchFavoritesContents = () =>
+ snackbarActions.OPEN_SNACKBAR({
+ message: 'Could not fetch groups.',
+ kind: SnackbarKind.ERROR
+ });
+
import { getCollectionUrl } from "~/models/collection";
import { getProjectUrl } from "~/models/project";
import { SidePanelTreeCategory } from '../side-panel-tree/side-panel-tree-actions';
-import { Routes, getProcessUrl, getProcessLogUrl } from '~/routes/routes';
+import { Routes, getProcessUrl, getProcessLogUrl, getGroupUrl } from '~/routes/routes';
import { RootState } from '~/store/store';
import { ServiceRepository } from '~/services/services';
+import { GROUPS_PANEL_LABEL } from '~/store/breadcrumbs/breadcrumbs-actions';
export const navigateTo = (uuid: string) =>
async (dispatch: Dispatch) => {
dispatch(navigateToWorkflows);
} else if (uuid === SidePanelTreeCategory.TRASH) {
dispatch(navigateToTrash);
+ } else if (uuid === GROUPS_PANEL_LABEL) {
+ dispatch(navigateToGroups);
}
};
export const navigateToSshKeysUser= push(Routes.SSH_KEYS_USER);
+export const navigateToSiteManager= push(Routes.SITE_MANAGER);
+
export const navigateToMyAccount = push(Routes.MY_ACCOUNT);
export const navigateToKeepServices = push(Routes.KEEP_SERVICES);
export const navigateToApiClientAuthorizations = push(Routes.API_CLIENT_AUTHORIZATIONS);
-export const navigateToLinks = push(Routes.LINKS);
\ No newline at end of file
+export const navigateToGroups = push(Routes.GROUPS);
+
+export const navigateToGroupDetails = compose(push, getGroupUrl);
+
+export const navigateToLinks = push(Routes.LINKS);
import { UserMiddlewareService } from '~/store/users/user-panel-middleware-service';
import { USERS_PANEL_ID } from '~/store/users/users-actions';
import { apiClientAuthorizationsReducer } from '~/store/api-client-authorizations/api-client-authorizations-reducer';
+import { GroupsPanelMiddlewareService } from '~/store/groups-panel/groups-panel-middleware-service';
+import { GROUPS_PANEL_ID } from '~/store/groups-panel/groups-panel-actions';
+import { GroupDetailsPanelMiddlewareService } from '~/store/group-details-panel/group-details-panel-middleware-service';
+import { GROUP_DETAILS_PANEL_ID } from '~/store/group-details-panel/group-details-panel-actions';
import { LINK_PANEL_ID } from '~/store/link-panel/link-panel-actions';
import { LinkMiddlewareService } from '~/store/link-panel/link-panel-middleware-service';
import { COMPUTE_NODE_PANEL_ID } from '~/store/compute-nodes/compute-nodes-actions';
const userPanelMiddleware = dataExplorerMiddleware(
new UserMiddlewareService(services, USERS_PANEL_ID)
);
+ const groupsPanelMiddleware = dataExplorerMiddleware(
+ new GroupsPanelMiddlewareService(services, GROUPS_PANEL_ID)
+ );
+ const groupDetailsPanelMiddleware = dataExplorerMiddleware(
+ new GroupDetailsPanelMiddlewareService(services, GROUP_DETAILS_PANEL_ID)
+ );
+
const linkPanelMiddleware = dataExplorerMiddleware(
new LinkMiddlewareService(services, LINK_PANEL_ID)
);
sharedWithMePanelMiddleware,
workflowPanelMiddleware,
userPanelMiddleware,
+ groupsPanelMiddleware,
+ groupDetailsPanelMiddleware,
linkPanelMiddleware,
- computeNodeMiddleware
+ computeNodeMiddleware,
];
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
return createStore(rootReducer, enhancer);
import { projectPanelColumns } from '~/views/project-panel/project-panel';
import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
import { matchRootRoute } from '~/routes/routes';
-import { setSidePanelBreadcrumbs, setProcessBreadcrumbs, setSharedWithMeBreadcrumbs, setTrashBreadcrumbs, setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
+import { setSidePanelBreadcrumbs, setProcessBreadcrumbs, setSharedWithMeBreadcrumbs, setTrashBreadcrumbs, setBreadcrumbs, setGroupDetailsBreadcrumbs, setGroupsBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
import { navigateToProject } from '~/store/navigation/navigation-action';
import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
import { ServiceRepository } from '~/services/services';
import { loadSharedWithMePanel } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
-import { loadSshKeysPanel } from '~/store/auth/auth-action';
+import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh';
import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
+import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
import { userPanelColumns } from '~/views/user-panel/user-panel';
import { computeNodePanelColumns } from '~/views/compute-node-panel/compute-node-panel-root';
import { loadApiClientAuthorizationsPanel } from '~/store/api-client-authorizations/api-client-authorizations-actions';
+import * as groupPanelActions from '~/store/groups-panel/groups-panel-actions';
+import { groupsPanelColumns } from '~/views/groups-panel/groups-panel';
+import * as groupDetailsPanelActions from '~/store/group-details-panel/group-details-panel-actions';
+import { groupDetailsPanelColumns } from '~/views/group-details-panel/group-details-panel';
export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
dispatch(searchResultsPanelActions.SET_COLUMNS({ columns: searchResultsPanelColumns }));
dispatch(userBindedActions.SET_COLUMNS({ columns: userPanelColumns }));
+ dispatch(groupPanelActions.GroupsPanelActions.SET_COLUMNS({ columns: groupsPanelColumns }));
+ dispatch(groupDetailsPanelActions.GroupDetailsPanelActions.SET_COLUMNS({columns: groupDetailsPanelColumns}));
dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns }));
dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
dispatch<any>(initSidePanelTree());
await dispatch(loadSshKeysPanel());
});
+export const loadSiteManager = handleFirstTimeLoad(
+async (dispatch: Dispatch<any>) => {
+ await dispatch(loadSiteManagerPanel());
+});
+
export const loadMyAccount = handleFirstTimeLoad(
(dispatch: Dispatch<any>) => {
dispatch(loadMyAccountPanel());
await dispatch(loadApiClientAuthorizationsPanel());
});
+export const loadGroupsPanel = handleFirstTimeLoad(
+ (dispatch: Dispatch<any>) => {
+ dispatch(setGroupsBreadcrumbs());
+ dispatch(groupPanelActions.loadGroupsPanel());
+ });
+
+
+export const loadGroupDetailsPanel = (groupUuid: string) =>
+ handleFirstTimeLoad(
+ (dispatch: Dispatch<any>) => {
+ dispatch(setGroupDetailsBreadcrumbs(groupUuid));
+ dispatch(groupDetailsPanelActions.loadGroupDetailsPanel(groupUuid));
+ });
+
const finishLoadingProject = (project: GroupContentsResource | string) =>
async (dispatch: Dispatch<any>) => {
const uuid = typeof project === 'string' ? project : project.uuid;
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+
+const ERROR_MESSAGE = 'Remote host is invalid';
+
+export const isRemoteHost = (value: string) => {
+ return value.match(/\w+\.\w+\.\w+/i) ? undefined : ERROR_MESSAGE;
+};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export const ERROR_MESSAGE = (minLength: number) => `Min length is ${minLength}`;
+
+export const minLength =
+ (minLength: number, errorMessage = ERROR_MESSAGE) =>
+ (value: { length: number }) =>
+ value && value.length >= minLength ? undefined : errorMessage(minLength);
import { require } from './require';
import { maxLength } from './max-length';
import { isRsaKey } from './is-rsa-key';
+import { isRemoteHost } from "./is-remote-host";
export const TAG_KEY_VALIDATION = [require, maxLength(255)];
export const TAG_VALUE_VALIDATION = [require, maxLength(255)];
export const SSH_KEY_PUBLIC_VALIDATION = [require, isRsaKey, maxLength(1024)];
export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)];
+export const SITE_MANAGER_REMOTE_HOST_VALIDATION = [require, isRemoteHost, maxLength(255)];
+
export const MY_ACCOUNT_VALIDATION = [require];
import { RouteProps } from "react-router";
import * as React from "react";
import { connect, DispatchProp } from "react-redux";
-import { getUserDetails, saveApiToken } from "~/store/auth/auth-action";
+import { authActions, getUserDetails, saveApiToken } from "~/store/auth/auth-action";
import { getUrlParameter } from "~/common/url";
import { AuthService } from "~/services/auth-service/auth-service";
import { navigateToRootProject } from "~/store/navigation/navigation-action";
+import { User } from "~/models/user";
+import { Config } from "~/common/config";
+import { initSessions } from "~/store/auth/auth-action-session";
interface ApiTokenProps {
authService: AuthService;
+ config: Config;
}
export const ApiToken = connect()(
const search = this.props.location ? this.props.location.search : "";
const apiToken = getUrlParameter(search, 'api_token');
this.props.dispatch(saveApiToken(apiToken));
- this.props.dispatch<any>(getUserDetails()).finally(() => {
+ this.props.dispatch<any>(getUserDetails()).then((user: User) => {
+ this.props.dispatch(initSessions(this.props.authService, this.props.config, user));
+ }).finally(() => {
this.props.dispatch(navigateToRootProject);
});
}
import { RenameIcon, RemoveIcon } from "~/components/icon/icon";
import { DownloadCollectionFileAction } from "../actions/download-collection-file-action";
import { openFileRemoveDialog, openRenameFileDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
+import { FileViewerActions } from '~/views-components/context-menu/actions/file-viewer-actions';
export const collectionFilesItemActionSet: ContextMenuActionSet = [[{
execute: (dispatch, resource) => {
dispatch<any>(openFileRemoveDialog(resource.uuid));
}
+}], [{
+ component: FileViewerActions,
+ execute: () => { return; },
}]];
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
+import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
+import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
+import { openGroupAttributes, openRemoveGroupDialog } from "~/store/groups-panel/groups-panel-actions";
+
+export const groupActionSet: ContextMenuActionSet = [[{
+ name: "Attributes",
+ icon: AttributesIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openGroupAttributes(uuid));
+ }
+}, {
+ name: "Advanced",
+ icon: AdvancedIcon,
+ execute: (dispatch, resource) => {
+ dispatch<any>(openAdvancedTabDialog(resource.uuid));
+ }
+}, {
+ name: "Remove",
+ icon: RemoveIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openRemoveGroupDialog(uuid));
+ }
+}]];
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
+import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
+import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
+import { openGroupMemberAttributes, openRemoveGroupMemberDialog } from '~/store/group-details-panel/group-details-panel-actions';
+
+export const groupMemberActionSet: ContextMenuActionSet = [[{
+ name: "Attributes",
+ icon: AttributesIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openGroupMemberAttributes(uuid));
+ }
+}, {
+ name: "Advanced",
+ icon: AdvancedIcon,
+ execute: (dispatch, resource) => {
+ dispatch<any>(openAdvancedTabDialog(resource.uuid));
+ }
+}, {
+ name: "Remove",
+ icon: RemoveIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openRemoveGroupMemberDialog(uuid));
+ }
+}]];
\ No newline at end of file
import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
-import { openSshKeyRemoveDialog, openSshKeyAttributesDialog } from '~/store/auth/auth-action';
+import { openSshKeyRemoveDialog, openSshKeyAttributesDialog } from '~/store/auth/auth-action-ssh';
import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab';
export const sshKeyActionSet: ContextMenuActionSet = [[{
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { ListItemText, ListItem, ListItemIcon, Icon } from "@material-ui/core";
+import { RootState } from '~/store/store';
+import { getNodeValue } from '~/models/tree';
+import { CollectionDirectory, CollectionFile, CollectionFileType } from '~/models/collection-file';
+import { FileViewerList, FileViewer } from '~/models/file-viewers-config';
+import { getFileViewers } from '~/store/file-viewers/file-viewers-selectors';
+import { connect } from 'react-redux';
+import { OpenIcon } from '~/components/icon/icon';
+
+interface FileViewerActionProps {
+ fileUrl: string;
+ viewers: FileViewerList;
+}
+
+const mapStateToProps = (state: RootState): FileViewerActionProps => {
+ const { resource } = state.contextMenu;
+ if (resource) {
+ const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
+ if (file) {
+ const fileViewers = getFileViewers(state.properties);
+ return {
+ fileUrl: file.url,
+ viewers: fileViewers.filter(enabledViewers(file)),
+ };
+ }
+ }
+ return {
+ fileUrl: '',
+ viewers: [],
+ };
+};
+
+const enabledViewers = (file: CollectionFile | CollectionDirectory) =>
+ ({ extensions, collections }: FileViewer) => {
+ if (collections && file.type === CollectionFileType.DIRECTORY) {
+ return true;
+ } else if (extensions) {
+ return extensions.some(extension => file.name.endsWith(extension));
+ } else {
+ return true;
+ }
+ };
+
+const fillViewerUrl = (fileUrl: string, { url, filePathParam }: FileViewer) => {
+ const viewerUrl = new URL(url);
+ viewerUrl.searchParams.append(filePathParam, fileUrl);
+ return viewerUrl.href;
+};
+
+export const FileViewerActions = connect(mapStateToProps)(
+ ({ fileUrl, viewers, onClick }: FileViewerActionProps & { onClick: () => void }) =>
+ <>
+ {viewers.map(viewer =>
+ <ListItem
+ button
+ component='a'
+ key={viewer.name}
+ style={{ textDecoration: 'none' }}
+ href={fillViewerUrl(fileUrl, viewer)}
+ onClick={onClick}
+ target='_blank'>
+ <ListItemIcon>
+ {
+ viewer.iconUrl
+ ? <Icon>
+ <img src={viewer.iconUrl} />
+ </Icon>
+ : <OpenIcon />
+ }
+ </ListItemIcon>
+ <ListItemText>
+ {viewer.name}
+ </ListItemText>
+ </ListItem>
+ )}
+ </>);
VIRTUAL_MACHINE = "VirtualMachine",
KEEP_SERVICE = "KeepService",
USER = "User",
+ NODE = "Node",
+ GROUPS = "Group",
+ GROUP_MEMBER = "GroupMember",
LINK = "Link",
- NODE = "Node"
}
const mapStateToProps = (state: RootState, { id }: Props) => {
const progress = state.progressIndicator.find(p => p.id === id);
const working = progress && progress.working;
- return { ...getDataExplorer(state.dataExplorer, id), working };
+ const currentRoute = state.router.location ? state.router.location.pathname : '';
+ return { ...getDataExplorer(state.dataExplorer, id), working, paperKey: currentRoute };
};
const mapDispatchToProps = () => {
import { WithDialogProps } from '~/store/dialog/with-dialog';
import { FormDialog } from '~/components/form-dialog/form-dialog';
import { SshKeyPublicField, SshKeyNameField } from '~/views-components/form-fields/ssh-key-form-fields';
-import { SshKeyCreateFormDialogData } from '~/store/auth/auth-action';
+import { SshKeyCreateFormDialogData } from '~/store/auth/auth-action-ssh';
type DialogSshKeyProps = WithDialogProps<{}> & InjectedFormProps<SshKeyCreateFormDialogData>;
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { compose } from "redux";
+import { reduxForm, InjectedFormProps, WrappedFieldArrayProps, FieldArray } from 'redux-form';
+import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
+import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { PeopleSelect, Person } from '~/views-components/sharing-dialog/people-select';
+import { ADD_GROUP_MEMBERS_DIALOG, ADD_GROUP_MEMBERS_FORM, AddGroupMembersFormData, ADD_GROUP_MEMBERS_USERS_FIELD_NAME, addGroupMembers } from '~/store/group-details-panel/group-details-panel-actions';
+import { minLength } from '~/validators/min-length';
+
+export const AddGroupMembersDialog = compose(
+ withDialog(ADD_GROUP_MEMBERS_DIALOG),
+ reduxForm<AddGroupMembersFormData>({
+ form: ADD_GROUP_MEMBERS_FORM,
+ onSubmit: (data, dispatch) => {
+ dispatch(addGroupMembers(data));
+ },
+ })
+)(
+ (props: AddGroupMembersDialogProps) =>
+ <FormDialog
+ dialogTitle='Add users'
+ formFields={UsersField}
+ submitLabel='Add'
+ {...props}
+ />
+);
+
+type AddGroupMembersDialogProps = WithDialogProps<{}> & InjectedFormProps<AddGroupMembersFormData>;
+
+const UsersField = () =>
+ <FieldArray
+ name={ADD_GROUP_MEMBERS_USERS_FIELD_NAME}
+ component={UsersSelect}
+ validate={UsersFieldValidation} />;
+
+const UsersFieldValidation = [minLength(1, () => 'Select at least one user')];
+
+const UsersSelect = ({ fields }: WrappedFieldArrayProps<Person>) =>
+ <PeopleSelect
+ autofocus
+ label='Enter email adresses '
+ items={fields.getAll() || []}
+ onSelect={fields.push}
+ onDelete={fields.remove} />;
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { compose } from "redux";
+import { reduxForm, InjectedFormProps, Field, WrappedFieldArrayProps, FieldArray } from 'redux-form';
+import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
+import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { CREATE_GROUP_DIALOG, CREATE_GROUP_FORM, createGroup, CreateGroupFormData, CREATE_GROUP_NAME_FIELD_NAME, CREATE_GROUP_USERS_FIELD_NAME } from '~/store/groups-panel/groups-panel-actions';
+import { TextField } from '~/components/text-field/text-field';
+import { maxLength } from '~/validators/max-length';
+import { require } from '~/validators/require';
+import { PeopleSelect, Person } from '~/views-components/sharing-dialog/people-select';
+
+export const CreateGroupDialog = compose(
+ withDialog(CREATE_GROUP_DIALOG),
+ reduxForm<CreateGroupFormData>({
+ form: CREATE_GROUP_FORM,
+ onSubmit: (data, dispatch) => {
+ dispatch(createGroup(data));
+ }
+ })
+)(
+ (props: CreateGroupDialogComponentProps) =>
+ <FormDialog
+ dialogTitle='Create a group'
+ formFields={CreateGroupFormFields}
+ submitLabel='Create'
+ {...props}
+ />
+);
+
+type CreateGroupDialogComponentProps = WithDialogProps<{}> & InjectedFormProps<CreateGroupFormData>;
+
+const CreateGroupFormFields = () =>
+ <>
+ <GroupNameField />
+ <UsersField />
+ </>;
+
+const GroupNameField = () =>
+ <Field
+ name={CREATE_GROUP_NAME_FIELD_NAME}
+ component={TextField}
+ validate={GROUP_NAME_VALIDATION}
+ label="Name"
+ autoFocus={true} />;
+
+const GROUP_NAME_VALIDATION = [require, maxLength(255)];
+
+const UsersField = () =>
+ <FieldArray
+ name={CREATE_GROUP_USERS_FIELD_NAME}
+ component={UsersSelect} />;
+
+const UsersSelect = ({ fields }: WrappedFieldArrayProps<Person>) =>
+ <PeopleSelect
+ label='Enter email adresses '
+ items={fields.getAll() || []}
+ onSelect={fields.push}
+ onDelete={fields.remove} />;
import { compose } from "redux";
import { reduxForm } from 'redux-form';
import { withDialog } from "~/store/dialog/with-dialog";
-import { SSH_KEY_CREATE_FORM_NAME, createSshKey, SshKeyCreateFormDialogData } from '~/store/auth/auth-action';
+import {
+ SSH_KEY_CREATE_FORM_NAME,
+ createSshKey,
+ SshKeyCreateFormDialogData
+} from '~/store/auth/auth-action-ssh';
import { DialogSshKeyCreate } from '~/views-components/dialog-create/dialog-ssh-key-create';
export const CreateSshKeyDialog = compose(
dispatch(createSshKey(data));
}
})
-)(DialogSshKeyCreate);
\ No newline at end of file
+)(DialogSshKeyCreate);
// SPDX-License-Identifier: AGPL-3.0
import * as React from "react";
-import { Field, WrappedFieldProps, FieldArray } from 'redux-form';
+import { Field, WrappedFieldProps, FieldArray, formValues } from 'redux-form';
import { TextField, DateTextField } from "~/components/text-field/text-field";
import { CheckboxField } from '~/components/checkbox-field/checkbox-field';
import { NativeSelectField } from '~/components/select-field/select-field';
import { SearchBarAdvancedPropertiesView } from '~/views-components/search-bar/search-bar-advanced-properties-view';
import { TreeItem } from "~/components/tree/tree";
import { ProjectsTreePickerItem } from "~/views-components/projects-tree-picker/generic-projects-tree-picker";
+import { PropertyKeyInput } from '~/views-components/resource-properties-form/property-key-field';
+import { PropertyValueInput, PropertyValueFieldProps } from '~/views-components/resource-properties-form/property-value-field';
+import { VocabularyProp, connectVocabulary } from '~/views-components/resource-properties-form/property-field-common';
+import { compose } from 'redux';
export const SearchBarTypeField = () =>
<Field
(_: any, { id }: TreeItem<ProjectsTreePickerItem>) => {
props.input.onChange(id);
}
- }/>
+ } />
</div>;
export const SearchBarTrashField = () =>
name="properties"
component={SearchBarAdvancedPropertiesView} />;
-export const SearchBarKeyField = () =>
- <Field
- name='key'
- component={TextField}
- label="Key" />;
+export const SearchBarKeyField = connectVocabulary(
+ ({ vocabulary }: VocabularyProp) =>
+ <Field
+ name='key'
+ component={PropertyKeyInput}
+ vocabulary={vocabulary} />);
-export const SearchBarValueField = () =>
- <Field
- name='value'
- component={TextField}
- label="Value" />;
+export const SearchBarValueField = compose(
+ connectVocabulary,
+ formValues({ propertyKey: 'key' })
+)(
+ (props: PropertyValueFieldProps) =>
+ <Field
+ name='value'
+ component={PropertyValueInput}
+ {...props} />);
export const SearchBarSaveSearchField = () =>
<Field
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography, Grid } from "@material-ui/core";
+import { WithDialogProps } from "~/store/dialog/with-dialog";
+import { withDialog } from '~/store/dialog/with-dialog';
+import { WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { compose } from "redux";
+import { GroupResource } from "~/models/group";
+import { GROUP_ATTRIBUTES_DIALOG } from "~/store/groups-panel/groups-panel-actions";
+
+type CssRules = 'rightContainer' | 'leftContainer' | 'spacing';
+
+const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
+ rightContainer: {
+ textAlign: 'right',
+ paddingRight: theme.spacing.unit * 2,
+ color: theme.palette.grey["500"]
+ },
+ leftContainer: {
+ textAlign: 'left',
+ paddingLeft: theme.spacing.unit * 2
+ },
+ spacing: {
+ paddingTop: theme.spacing.unit * 2
+ },
+}));
+
+interface GroupAttributesDataProps {
+ data: GroupResource;
+}
+
+type GroupAttributesProps = GroupAttributesDataProps & WithStyles<CssRules>;
+
+export const GroupAttributesDialog = compose(
+ withDialog(GROUP_ATTRIBUTES_DIALOG),
+ styles)(
+ (props: WithDialogProps<GroupAttributesProps> & GroupAttributesProps) =>
+ <Dialog open={props.open}
+ onClose={props.closeDialog}
+ fullWidth
+ maxWidth="sm">
+ <DialogTitle>Attributes</DialogTitle>
+ <DialogContent>
+ <Typography variant="body2" className={props.classes.spacing}>
+ {props.data && attributes(props.data, props.classes)}
+ </Typography>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ variant='flat'
+ color='primary'
+ onClick={props.closeDialog}>
+ Close
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+
+const attributes = (group: GroupResource, classes: any) => {
+ const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, name, deleteAt, description, etag, href, isTrashed, trashAt} = group;
+ return (
+ <span>
+ <Grid container direction="row">
+ <Grid item xs={5} className={classes.rightContainer}>
+ {name && <Grid item>Name</Grid>}
+ {ownerUuid && <Grid item>Owner uuid</Grid>}
+ {createdAt && <Grid item>Created at</Grid>}
+ {modifiedAt && <Grid item>Modified at</Grid>}
+ {modifiedByUserUuid && <Grid item>Modified by user uuid</Grid>}
+ {modifiedByClientUuid && <Grid item>Modified by client uuid</Grid>}
+ {uuid && <Grid item>uuid</Grid>}
+ {deleteAt && <Grid item>Delete at</Grid>}
+ {description && <Grid item>Description</Grid>}
+ {etag && <Grid item>Etag</Grid>}
+ {href && <Grid item>Href</Grid>}
+ {isTrashed && <Grid item>Is trashed</Grid>}
+ {trashAt && <Grid item>Trashed at</Grid>}
+ </Grid>
+ <Grid item xs={7} className={classes.leftContainer}>
+ <Grid item>{name}</Grid>
+ <Grid item>{ownerUuid}</Grid>
+ <Grid item>{createdAt}</Grid>
+ <Grid item>{modifiedAt}</Grid>
+ <Grid item>{modifiedByUserUuid}</Grid>
+ <Grid item>{modifiedByClientUuid}</Grid>
+ <Grid item>{uuid}</Grid>
+ <Grid item>{deleteAt}</Grid>
+ <Grid item>{description}</Grid>
+ <Grid item>{etag}</Grid>
+ <Grid item>{href}</Grid>
+ <Grid item>{isTrashed}</Grid>
+ <Grid item>{trashAt}</Grid>
+ </Grid>
+ </Grid>
+ </span>
+ );
+};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography, Grid } from "@material-ui/core";
+import { WithDialogProps } from "~/store/dialog/with-dialog";
+import { withDialog } from '~/store/dialog/with-dialog';
+import { WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { compose } from "redux";
+import { PermissionResource } from "~/models/permission";
+import { MEMBER_ATTRIBUTES_DIALOG } from '~/store/group-details-panel/group-details-panel-actions';
+
+type CssRules = 'rightContainer' | 'leftContainer' | 'spacing';
+
+const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
+ rightContainer: {
+ textAlign: 'right',
+ paddingRight: theme.spacing.unit * 2,
+ color: theme.palette.grey["500"]
+ },
+ leftContainer: {
+ textAlign: 'left',
+ paddingLeft: theme.spacing.unit * 2
+ },
+ spacing: {
+ paddingTop: theme.spacing.unit * 2
+ },
+}));
+
+interface GroupAttributesDataProps {
+ data: PermissionResource;
+}
+
+type GroupAttributesProps = GroupAttributesDataProps & WithStyles<CssRules>;
+
+export const GroupMemberAttributesDialog = compose(
+ withDialog(MEMBER_ATTRIBUTES_DIALOG),
+ styles)(
+ (props: WithDialogProps<GroupAttributesProps> & GroupAttributesProps) =>
+ <Dialog open={props.open}
+ onClose={props.closeDialog}
+ fullWidth
+ maxWidth="sm">
+ <DialogTitle>Attributes</DialogTitle>
+ <DialogContent>
+ <Typography variant="body2" className={props.classes.spacing}>
+ {props.data && attributes(props.data, props.classes)}
+ </Typography>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ variant='flat'
+ color='primary'
+ onClick={props.closeDialog}>
+ Close
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+
+const attributes = (memberGroup: PermissionResource, classes: any) => {
+ const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, name, etag, href, linkClass } = memberGroup;
+ return (
+ <span>
+ <Grid container direction="row">
+ <Grid item xs={5} className={classes.rightContainer}>
+ {name && <Grid item>Name</Grid>}
+ {ownerUuid && <Grid item>Owner uuid</Grid>}
+ {createdAt && <Grid item>Created at</Grid>}
+ {modifiedAt && <Grid item>Modified at</Grid>}
+ {modifiedByUserUuid && <Grid item>Modified by user uuid</Grid>}
+ {modifiedByClientUuid && <Grid item>Modified by client uuid</Grid>}
+ {uuid && <Grid item>uuid</Grid>}
+ {linkClass && <Grid item>Link Class</Grid>}
+ {etag && <Grid item>Etag</Grid>}
+ {href && <Grid item>Href</Grid>}
+ </Grid>
+ <Grid item xs={7} className={classes.leftContainer}>
+ <Grid item>{name}</Grid>
+ <Grid item>{ownerUuid}</Grid>
+ <Grid item>{createdAt}</Grid>
+ <Grid item>{modifiedAt}</Grid>
+ <Grid item>{modifiedByUserUuid}</Grid>
+ <Grid item>{modifiedByClientUuid}</Grid>
+ <Grid item>{uuid}</Grid>
+ <Grid item>{linkClass}</Grid>
+ <Grid item>{etag}</Grid>
+ <Grid item>{href}</Grid>
+ </Grid>
+ </Grid>
+ </span>
+ );
+};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, compose } from 'redux';
+import { connect } from "react-redux";
+import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
+import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
+import { removeGroupMember, MEMBER_REMOVE_DIALOG } from '~/store/group-details-panel/group-details-panel-actions';
+
+const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
+ onConfirm: () => {
+ props.closeDialog();
+ dispatch<any>(removeGroupMember(props.data.uuid));
+ }
+});
+
+export const RemoveGroupMemberDialog = compose(
+ withDialog(MEMBER_REMOVE_DIALOG),
+ connect(null, mapDispatchToProps)
+)(ConfirmationDialog);
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, compose } from 'redux';
+import { connect } from "react-redux";
+import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
+import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
+import { removeGroup, GROUP_REMOVE_DIALOG } from '~/store/groups-panel/groups-panel-actions';
+
+const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
+ onConfirm: () => {
+ props.closeDialog();
+ dispatch<any>(removeGroup(props.data.uuid));
+ }
+});
+
+export const RemoveGroupDialog = compose(
+ withDialog(GROUP_REMOVE_DIALOG),
+ connect(null, mapDispatchToProps)
+)(ConfirmationDialog);
\ No newline at end of file
import { RootState } from "~/store/store";
import { openCurrentTokenDialog } from '~/store/current-token-dialog/current-token-dialog-actions';
import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
-import { navigateToSshKeysUser, navigateToMyAccount } from '~/store/navigation/navigation-action';
+import {
+ navigateToSiteManager,
+ navigateToSshKeysUser,
+ navigateToMyAccount
+} from '~/store/navigation/navigation-action';
import { openUserVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
interface AccountMenuProps {
user?: User;
+ currentRoute: string;
}
const mapStateToProps = (state: RootState): AccountMenuProps => ({
- user: state.auth.user
+ user: state.auth.user,
+ currentRoute: state.router.location ? state.router.location.pathname : ''
});
export const AccountMenu = connect(mapStateToProps)(
- ({ user, dispatch }: AccountMenuProps & DispatchProp<any>) =>
+ ({ user, dispatch, currentRoute }: AccountMenuProps & DispatchProp<any>) =>
user
? <DropdownMenu
icon={<UserPanelIcon />}
id="account-menu"
- title="Account Management">
+ title="Account Management"
+ key={currentRoute}>
<MenuItem>
{getUserFullname(user)}
</MenuItem>
{!user.isAdmin && <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>}
<MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
<MenuItem onClick={() => dispatch(navigateToSshKeysUser)}>Ssh Keys</MenuItem>
+ <MenuItem onClick={() => dispatch(navigateToSiteManager)}>Site Manager</MenuItem>
<MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
<MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
</DropdownMenu>
interface AdminMenuProps {
user?: User;
+ currentRoute: string;
}
const mapStateToProps = (state: RootState): AdminMenuProps => ({
- user: state.auth.user
+ user: state.auth.user,
+ currentRoute: state.router.location ? state.router.location.pathname : ''
});
export const AdminMenu = connect(mapStateToProps)(
- ({ user, dispatch }: AdminMenuProps & DispatchProp<any>) =>
+ ({ user, dispatch, currentRoute }: AdminMenuProps & DispatchProp<any>) =>
user
? <DropdownMenu
icon={<AdminMenuIcon />}
id="admin-menu"
- title="Admin Panel">
+ title="Admin Panel"
+ key={currentRoute}>
<MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
<MenuItem onClick={() => dispatch(openAdminVirtualMachines())}>Virtual Machines</MenuItem>
<MenuItem onClick={() => dispatch(NavigationAction.navigateToSshKeysAdmin)}>Ssh Keys</MenuItem>
<MenuItem onClick={() => dispatch(NavigationAction.navigateToApiClientAuthorizations)}>Api Tokens</MenuItem>
<MenuItem onClick={() => dispatch(openUserPanel())}>Users</MenuItem>
+ <MenuItem onClick={() => dispatch(NavigationAction.navigateToGroups)}>Groups</MenuItem>}
<MenuItem onClick={() => dispatch(NavigationAction.navigateToComputeNodes)}>Compute Nodes</MenuItem>
<MenuItem onClick={() => dispatch(NavigationAction.navigateToKeepServices)}>Keep Services</MenuItem>
<MenuItem onClick={() => dispatch(NavigationAction.navigateToLinks)}>Links</MenuItem>
- <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
</DropdownMenu>
: null);
// SPDX-License-Identifier: AGPL-3.0
import * as React from "react";
-import { MenuItem, Typography, ListSubheader } from "@material-ui/core";
+import { MenuItem, Typography } from "@material-ui/core";
import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu";
import { ImportContactsIcon, HelpIcon } from "~/components/icon/icon";
import { ArvadosTheme } from '~/common/custom-theme';
import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { RootState } from "~/store/store";
+import { compose } from "redux";
+import { connect } from "react-redux";
type CssRules = 'link' | 'icon' | 'title' | 'linkTitle';
},
];
-export const HelpMenu = withStyles(styles)(
- ({ classes }: WithStyles<CssRules>) =>
- <DropdownMenu
- icon={<HelpIcon />}
- id="help-menu"
- title="Help">
- <MenuItem disabled>Help</MenuItem>
- {
- links.map(link =>
- <MenuItem key={link.title}>
- <a href={link.link} target="_blank" className={classes.link}>
- <ImportContactsIcon className={classes.icon} />
- <Typography variant="body1" className={classes.linkTitle}>{link.title}</Typography>
- </a>
- </MenuItem>
- )
- }
- </DropdownMenu>
-);
+interface HelpMenuProps {
+ currentRoute: string;
+}
+
+const mapStateToProps = ({ router }: RootState) => ({
+ currentRoute: router.location ? router.location.pathname : '',
+});
+
+export const HelpMenu = compose(
+ connect(mapStateToProps),
+ withStyles(styles))(
+ ({ classes, currentRoute }: HelpMenuProps & WithStyles<CssRules>) =>
+ <DropdownMenu
+ icon={<HelpIcon />}
+ id="help-menu"
+ title="Help"
+ key={currentRoute}>
+ <MenuItem disabled>Help</MenuItem>
+ {
+ links.map(link =>
+ <MenuItem key={link.title}>
+ <a href={link.link} target="_blank" className={classes.link}>
+ <ImportContactsIcon className={classes.icon} />
+ <Typography variant="body1" className={classes.linkTitle}>{link.title}</Typography>
+ </a>
+ </MenuItem>
+ )
+ }
+ </DropdownMenu>
+ );
return !Routes.matchWorkflowRoute(pathname) && !Routes.matchUserVirtualMachineRoute(pathname) &&
!Routes.matchAdminVirtualMachineRoute(pathname) && !Routes.matchRepositoriesRoute(pathname) &&
!Routes.matchSshKeysAdminRoute(pathname) && !Routes.matchSshKeysUserRoute(pathname) &&
+ !Routes.matchSiteManagerRoute(pathname) &&
!Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
!Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) &&
!Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname);
component={TextField}
autoFocus={true}
/>
- <WarningCollection text="Renaming a file will change content adress." />
+ <WarningCollection text="Renaming a file will change content address." />
</>;
vocabulary={vocabulary}
validate={getValidation(vocabulary)} />);
-const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) =>
+export const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) =>
<Autocomplete
label='Key'
suggestions={getSuggestions(props.input.value, vocabulary)}
propertyKey: string;
}
-type PropertyValueFieldProps = VocabularyProp & PropertyKeyProp;
+export type PropertyValueFieldProps = VocabularyProp & PropertyKeyProp;
export const PROPERTY_VALUE_FIELD_NAME = 'value';
validate={getValidation(props)}
{...props} />);
-const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: WrappedFieldProps & PropertyValueFieldProps) =>
+export const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: WrappedFieldProps & PropertyValueFieldProps) =>
<Autocomplete
label='Value'
suggestions={getSuggestions(props.input.value, propertyKey, vocabulary)}
WithStyles,
Tooltip,
InputAdornment, Input,
- ClickAwayListener
+ Popover,
} from '@material-ui/core';
import SearchIcon from '@material-ui/icons/Search';
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
};
export const SearchBarView = withStyles(styles)(
- (props : SearchBarViewProps) => {
- const { classes, isPopoverOpen } = props;
- return (
- <ClickAwayListener onClickAway={props.closeView}>
- <Paper className={isPopoverOpen ? classes.containerSearchViewOpened : classes.container} >
- <form onSubmit={props.onSubmit}>
- <Input
- className={classes.input}
- onChange={props.onChange}
- placeholder="Search"
- value={props.searchValue}
- fullWidth={true}
- disableUnderline={true}
- onClick={e => handleInputClick(e, props)}
- onKeyDown={e => handleKeyDown(e, props)}
- startAdornment={
- <InputAdornment position="start">
- <Tooltip title='Search'>
- <IconButton type="submit">
- <SearchIcon />
- </IconButton>
- </Tooltip>
- </InputAdornment>
- }
- endAdornment={
- <InputAdornment position="end">
- <Tooltip title='Advanced search'>
- <IconButton onClick={e => handleDropdownClick(e, props)}>
- <ArrowDropDownIcon />
- </IconButton>
- </Tooltip>
- </InputAdornment>
- } />
- </form>
- <div className={classes.view}>
- {isPopoverOpen && getView({...props})}
+ class SearchBarView extends React.Component<SearchBarViewProps> {
+
+ viewAnchorRef = React.createRef<HTMLDivElement>();
+
+ render() {
+ const { children, ...props } = this.props;
+ const { classes, isPopoverOpen } = props;
+ return (
+ <Paper
+ className={isPopoverOpen ? classes.containerSearchViewOpened : classes.container}>
+ <div ref={this.viewAnchorRef}>
+ <form onSubmit={props.onSubmit}>
+ <SearchInput {...props} />
+ </form>
</div>
+ <SearchViewContainer
+ {...props}
+ width={this.getViewWidth()}
+ anchorEl={this.viewAnchorRef.current}>
+ {
+ getView({ ...props })
+ }
+ </SearchViewContainer>
</Paper >
- </ClickAwayListener>
- );
+ );
+ }
+
+ getViewWidth() {
+ const { current } = this.viewAnchorRef;
+ return current ? current.offsetWidth : 0;
+ }
}
+
);
+const SearchInput = (props: SearchBarViewProps) => {
+ const { classes } = props;
+ return <Input
+ className={classes.input}
+ onChange={props.onChange}
+ placeholder="Search"
+ value={props.searchValue}
+ fullWidth={true}
+ disableUnderline={true}
+ onClick={e => handleInputClick(e, props)}
+ onKeyDown={e => handleKeyDown(e, props)}
+ startAdornment={
+ <InputAdornment position="start">
+ <Tooltip title='Search'>
+ <IconButton type="submit">
+ <SearchIcon />
+ </IconButton>
+ </Tooltip>
+ </InputAdornment>
+ }
+ endAdornment={
+ <InputAdornment position="end">
+ <Tooltip title='Advanced search'>
+ <IconButton onClick={e => handleDropdownClick(e, props)}>
+ <ArrowDropDownIcon />
+ </IconButton>
+ </Tooltip>
+ </InputAdornment>
+ } />;
+};
+
+const SearchViewContainer = (props: SearchBarViewProps & { width: number, anchorEl: HTMLElement | null, children: React.ReactNode }) =>
+ <Popover
+ PaperProps={{
+ style: {
+ width: props.width,
+ borderRadius: '0 0 4px 4px',
+ }
+ }}
+ anchorEl={props.anchorEl}
+ anchorOrigin={{
+ vertical: 'bottom',
+ horizontal: 'center',
+ }}
+ transformOrigin={{
+ vertical: 'top',
+ horizontal: 'center',
+ }}
+ disableAutoFocus
+ open={props.isPopoverOpen}
+ onClose={props.closeView}>
+ {
+ props.children
+ }
+ </Popover>;
+
+
const getView = (props: SearchBarViewProps) => {
switch (props.currentView) {
case SearchView.AUTOCOMPLETE:
email: string;
uuid: string;
}
+
export interface PeopleSelectProps {
items: Person[];
+ label?: string;
+ autofocus?: boolean;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
};
render() {
+
+ const { label = 'Invite people' } = this.props;
+
return (
<Autocomplete
- label='Invite people'
+ label={label}
value={this.state.value}
items={this.props.items}
suggestions={this.state.suggestions}
+ autofocus={this.props.autofocus}
onChange={this.handleChange}
onCreate={this.handleCreate}
onSelect={this.handleSelect}
import { SidePanelTree, SidePanelTreeProps } from '~/views-components/side-panel-tree/side-panel-tree';
import { compose, Dispatch } from 'redux';
import { connect } from 'react-redux';
-import { navigateFromSidePanel } from '../../store/side-panel/side-panel-action';
+import { navigateFromSidePanel } from '~/store/side-panel/side-panel-action';
import { Grid } from '@material-ui/core';
import { SidePanelButton } from '~/views-components/side-panel-button/side-panel-button';
import { RootState } from '~/store/store';
}
});
-const mapStateToProps = (state: RootState) => ({
+const mapStateToProps = ({ router }: RootState) => ({
+ currentRoute: router.location ? router.location.pathname : '',
});
export const SidePanel = withStyles(styles)(
connect(mapStateToProps, mapDispatchToProps)(
- ({ classes, ...props }: WithStyles<CssRules> & SidePanelTreeProps) =>
- <Grid item xs>
- <SidePanelButton />
- <SidePanelTree {...props} />
- </Grid>
-));
+ ({ classes, ...props }: WithStyles<CssRules> & SidePanelTreeProps & { currentRoute: string }) =>
+ <Grid item xs>
+ <SidePanelButton key={props.currentRoute} />
+ <SidePanelTree {...props} />
+ </Grid>
+ ));
import * as React from "react";
import { compose } from 'redux';
-import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles, Typography, Grid } from '@material-ui/core';
+import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles, Grid } from '@material-ui/core';
import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
-import { SSH_KEY_ATTRIBUTES_DIALOG } from '~/store/auth/auth-action';
+import { SSH_KEY_ATTRIBUTES_DIALOG } from '~/store/auth/auth-action-ssh';
import { ArvadosTheme } from '~/common/custom-theme';
import { SshKeyResource } from "~/models/ssh-key";
</Button>
</DialogActions>
</Dialog>
- );
\ No newline at end of file
+ );
import { compose } from 'redux';
import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles } from '@material-ui/core';
import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
-import { SSH_KEY_PUBLIC_KEY_DIALOG } from '~/store/auth/auth-action';
+import { SSH_KEY_PUBLIC_KEY_DIALOG } from '~/store/auth/auth-action-ssh';
import { ArvadosTheme } from '~/common/custom-theme';
import { DefaultCodeSnippet } from '~/components/default-code-snippet/default-code-snippet';
</Button>
</DialogActions>
</Dialog>
- );
\ No newline at end of file
+ );
import { connect } from "react-redux";
import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
-import { SSH_KEY_REMOVE_DIALOG, removeSshKey } from '~/store/auth/auth-action';
+import { SSH_KEY_REMOVE_DIALOG, removeSshKey } from '~/store/auth/auth-action-ssh';
const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
onConfirm: () => {
export const RemoveSshKeyDialog = compose(
withDialog(SSH_KEY_REMOVE_DIALOG),
connect(null, mapDispatchToProps)
-)(ConfirmationDialog);
\ No newline at end of file
+)(ConfirmationDialog);
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { connect } from 'react-redux';
+
+import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
+import { DataColumns } from '~/components/data-table/data-table';
+import { ResourceUuid, ResourceFirstName, ResourceLastName, ResourceEmail, ResourceUsername } from '~/views-components/data-explorer/renderers';
+import { createTree } from '~/models/tree';
+import { noop } from 'lodash/fp';
+import { RootState } from '~/store/store';
+import { GROUP_DETAILS_PANEL_ID, openAddGroupMembersDialog } from '~/store/group-details-panel/group-details-panel-actions';
+import { openContextMenu } from '~/store/context-menu/context-menu-actions';
+import { ResourcesState, getResource } from '~/store/resources/resources';
+import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
+import { PermissionResource } from '~/models/permission';
+import { Grid, Button } from '@material-ui/core';
+import { AddIcon } from '~/components/icon/icon';
+
+export enum GroupDetailsPanelColumnNames {
+ FIRST_NAME = "First name",
+ LAST_NAME = "Last name",
+ UUID = "UUID",
+ EMAIL = "Email",
+ USERNAME = "Username",
+}
+
+export const groupDetailsPanelColumns: DataColumns<string> = [
+ {
+ name: GroupDetailsPanelColumnNames.FIRST_NAME,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <ResourceFirstName uuid={uuid} />
+ },
+ {
+ name: GroupDetailsPanelColumnNames.LAST_NAME,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <ResourceLastName uuid={uuid} />
+ },
+ {
+ name: GroupDetailsPanelColumnNames.UUID,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <ResourceUuid uuid={uuid} />
+ },
+ {
+ name: GroupDetailsPanelColumnNames.EMAIL,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <ResourceEmail uuid={uuid} />
+ },
+ {
+ name: GroupDetailsPanelColumnNames.USERNAME,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <ResourceUsername uuid={uuid} />
+ },
+];
+
+const mapStateToProps = (state: RootState) => {
+ return {
+ resources: state.resources
+ };
+};
+
+const mapDispatchToProps = {
+ onContextMenu: openContextMenu,
+ onAddUser: openAddGroupMembersDialog,
+};
+
+export interface GroupDetailsPanelProps {
+ onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any) => void;
+ onAddUser: () => void;
+ resources: ResourcesState;
+}
+
+export const GroupDetailsPanel = connect(
+ mapStateToProps, mapDispatchToProps
+)(
+ class GroupDetailsPanel extends React.Component<GroupDetailsPanelProps> {
+
+ render() {
+ return (
+ <DataExplorer
+ id={GROUP_DETAILS_PANEL_ID}
+ onRowClick={noop}
+ onRowDoubleClick={noop}
+ onContextMenu={this.handleContextMenu}
+ contextMenuColumn={true}
+ hideColumnSelector
+ hideSearchInput
+ actions={
+ <Grid container justify='flex-end'>
+ <Button
+ variant="contained"
+ color="primary"
+ onClick={this.props.onAddUser}>
+ <AddIcon /> Add user
+ </Button>
+ </Grid>
+ } />
+ );
+ }
+
+ handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+ const resource = getResource<PermissionResource>(resourceUuid)(this.props.resources);
+ if (resource) {
+ this.props.onContextMenu(event, {
+ name: '',
+ uuid: resource.uuid,
+ ownerUuid: resource.ownerUuid,
+ kind: resource.kind,
+ menuKind: ContextMenuKind.GROUP_MEMBER
+ });
+ }
+ }
+ });
+
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { Grid, Button, Typography } from "@material-ui/core";
+import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
+import { DataColumns } from '~/components/data-table/data-table';
+import { SortDirection } from '~/components/data-table/data-column';
+import { ResourceOwner } from '~/views-components/data-explorer/renderers';
+import { AddIcon } from '~/components/icon/icon';
+import { ResourceName } from '~/views-components/data-explorer/renderers';
+import { createTree } from '~/models/tree';
+import { GROUPS_PANEL_ID, openCreateGroupDialog } from '~/store/groups-panel/groups-panel-actions';
+import { noop } from 'lodash/fp';
+import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
+import { getResource, ResourcesState, filterResources } from '~/store/resources/resources';
+import { GroupResource } from '~/models/group';
+import { RootState } from '~/store/store';
+import { openContextMenu } from '~/store/context-menu/context-menu-actions';
+import { ResourceKind } from '~/models/resource';
+import { LinkClass, LinkResource } from '~/models/link';
+import { navigateToGroupDetails } from '~/store/navigation/navigation-action';
+
+export enum GroupsPanelColumnNames {
+ GROUP = "Name",
+ OWNER = "Owner",
+ MEMBERS = "Members",
+}
+
+export const groupsPanelColumns: DataColumns<string> = [
+ {
+ name: GroupsPanelColumnNames.GROUP,
+ selected: true,
+ configurable: true,
+ sortDirection: SortDirection.ASC,
+ filters: createTree(),
+ render: uuid => <ResourceName uuid={uuid} />
+ },
+ {
+ name: GroupsPanelColumnNames.OWNER,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <ResourceOwner uuid={uuid} />,
+ },
+ {
+ name: GroupsPanelColumnNames.MEMBERS,
+ selected: true,
+ configurable: true,
+ filters: createTree(),
+ render: uuid => <GroupMembersCount uuid={uuid} />,
+ },
+];
+
+const mapStateToProps = (state: RootState) => {
+ return {
+ resources: state.resources
+ };
+};
+
+const mapDispatchToProps = {
+ onContextMenu: openContextMenu,
+ onRowDoubleClick: (uuid: string) =>
+ navigateToGroupDetails(uuid),
+ onNewGroup: openCreateGroupDialog,
+};
+
+export interface GroupsPanelProps {
+ onNewGroup: () => void;
+ onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any) => void;
+ onRowDoubleClick: (item: string) => void;
+ resources: ResourcesState;
+}
+
+export const GroupsPanel = connect(
+ mapStateToProps, mapDispatchToProps
+)(
+ class GroupsPanel extends React.Component<GroupsPanelProps> {
+
+ render() {
+ return (
+ <DataExplorer
+ id={GROUPS_PANEL_ID}
+ onRowClick={noop}
+ onRowDoubleClick={this.props.onRowDoubleClick}
+ onContextMenu={this.handleContextMenu}
+ contextMenuColumn={true}
+ hideColumnSelector
+ actions={
+ <Grid container justify='flex-end'>
+ <Button
+ variant="contained"
+ color="primary"
+ onClick={this.props.onNewGroup}>
+ <AddIcon /> New group
+ </Button>
+ </Grid>
+ } />
+ );
+ }
+
+ handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+ const resource = getResource<GroupResource>(resourceUuid)(this.props.resources);
+ if (resource) {
+ this.props.onContextMenu(event, {
+ name: '',
+ uuid: resource.uuid,
+ ownerUuid: resource.ownerUuid,
+ kind: resource.kind,
+ menuKind: ContextMenuKind.GROUPS
+ });
+ }
+ }
+ });
+
+
+const GroupMembersCount = connect(
+ (state: RootState, props: { uuid: string }) => {
+
+ const permissions = filterResources((resource: LinkResource) =>
+ resource.kind === ResourceKind.LINK &&
+ resource.linkClass === LinkClass.PERMISSION &&
+ resource.tailUuid === props.uuid
+ )(state.resources);
+
+ return {
+ children: permissions.length,
+ };
+
+ }
+)(Typography);
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import {
+ Card,
+ CardContent,
+ CircularProgress,
+ Grid,
+ StyleRulesCallback,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableRow,
+ Typography,
+ WithStyles,
+ withStyles
+} from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { Session, SessionStatus } from "~/models/session";
+import Button from "@material-ui/core/Button";
+import { compose, Dispatch } from "redux";
+import { Field, FormErrors, InjectedFormProps, reduxForm, reset, stopSubmit } from "redux-form";
+import { TextField } from "~/components/text-field/text-field";
+import { addSession } from "~/store/auth/auth-action-session";
+import { SITE_MANAGER_REMOTE_HOST_VALIDATION } from "~/validators/validators";
+
+type CssRules = 'root' | 'link' | 'buttonContainer' | 'table' | 'tableRow' |
+ 'remoteSiteInfo' | 'buttonAdd' | 'buttonLoggedIn' | 'buttonLoggedOut' |
+ 'statusCell';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ width: '100%',
+ overflow: 'auto'
+ },
+ link: {
+ color: theme.palette.primary.main,
+ textDecoration: 'none',
+ margin: '0px 4px'
+ },
+ buttonContainer: {
+ textAlign: 'right'
+ },
+ table: {
+ marginTop: theme.spacing.unit
+ },
+ tableRow: {
+ '& td, th': {
+ whiteSpace: 'nowrap'
+ }
+ },
+ statusCell: {
+ minWidth: 160
+ },
+ remoteSiteInfo: {
+ marginTop: 20
+ },
+ buttonAdd: {
+ marginLeft: 10,
+ marginTop: theme.spacing.unit * 3
+ },
+ buttonLoggedIn: {
+ minHeight: theme.spacing.unit,
+ padding: 5,
+ color: '#fff',
+ backgroundColor: '#009966',
+ '&:hover': {
+ backgroundColor: '#008450',
+ }
+ },
+ buttonLoggedOut: {
+ minHeight: theme.spacing.unit,
+ padding: 5,
+ color: '#000',
+ backgroundColor: '#FFC414',
+ '&:hover': {
+ backgroundColor: '#eaaf14',
+ }
+ }
+});
+
+export interface SiteManagerPanelRootActionProps {
+ toggleSession: (session: Session) => void;
+}
+
+export interface SiteManagerPanelRootDataProps {
+ sessions: Session[];
+}
+
+type SiteManagerPanelRootProps = SiteManagerPanelRootDataProps & SiteManagerPanelRootActionProps & WithStyles<CssRules> & InjectedFormProps;
+const SITE_MANAGER_FORM_NAME = 'siteManagerForm';
+
+const submitSession = (remoteHost: string) =>
+ (dispatch: Dispatch) => {
+ dispatch<any>(addSession(remoteHost)).then(() => {
+ dispatch(reset(SITE_MANAGER_FORM_NAME));
+ }).catch((e: any) => {
+ const errors = {
+ remoteHost: e
+ } as FormErrors;
+ dispatch(stopSubmit(SITE_MANAGER_FORM_NAME, errors));
+ });
+ };
+
+export const SiteManagerPanelRoot = compose(
+ reduxForm<{remoteHost: string}>({
+ form: SITE_MANAGER_FORM_NAME,
+ touchOnBlur: false,
+ onSubmit: (data, dispatch) => {
+ dispatch(submitSession(data.remoteHost));
+ }
+ }),
+ withStyles(styles))
+ (({ classes, sessions, handleSubmit, toggleSession }: SiteManagerPanelRootProps) =>
+ <Card className={classes.root}>
+ <CardContent>
+ <Grid container direction="row">
+ <Grid item xs={12}>
+ <Typography variant='body1' paragraph={true} >
+ You can log in to multiple Arvados sites here, then use the multi-site search page to search collections and projects on all sites at once.
+ </Typography>
+ </Grid>
+ </Grid>
+ <Grid item xs={12}>
+ {sessions.length > 0 && <Table className={classes.table}>
+ <TableHead>
+ <TableRow className={classes.tableRow}>
+ <TableCell>Cluster ID</TableCell>
+ <TableCell>Username</TableCell>
+ <TableCell>Email</TableCell>
+ <TableCell>Status</TableCell>
+ </TableRow>
+ </TableHead>
+ <TableBody>
+ {sessions.map((session, index) => {
+ const validating = session.status === SessionStatus.BEING_VALIDATED;
+ return <TableRow key={index} className={classes.tableRow}>
+ <TableCell>{session.clusterId}</TableCell>
+ <TableCell>{validating ? <CircularProgress size={20}/> : session.username}</TableCell>
+ <TableCell>{validating ? <CircularProgress size={20}/> : session.email}</TableCell>
+ <TableCell className={classes.statusCell}>
+ <Button fullWidth
+ disabled={validating || session.status === SessionStatus.INVALIDATED || session.active}
+ className={session.loggedIn ? classes.buttonLoggedIn : classes.buttonLoggedOut}
+ onClick={() => toggleSession(session)}>
+ {validating ? "Validating" : (session.loggedIn ? "Logged in" : "Logged out")}
+ </Button>
+ </TableCell>
+ </TableRow>;
+ })}
+ </TableBody>
+ </Table>}
+ </Grid>
+ <form onSubmit={handleSubmit}>
+ <Grid container direction="row">
+ <Grid item xs={12}>
+ <Typography variant='body1' paragraph={true} className={classes.remoteSiteInfo}>
+ To add a remote Arvados site, paste the remote site's host here (see "ARVADOS_API_HOST" on the "current token" page).
+ </Typography>
+ </Grid>
+ <Grid item xs={8}>
+ <Field
+ name='remoteHost'
+ validate={SITE_MANAGER_REMOTE_HOST_VALIDATION}
+ component={TextField}
+ placeholder="zzzz.arvadosapi.com"
+ margin="normal"
+ label="New cluster"
+ autoFocus/>
+ </Grid>
+ <Grid item xs={3}>
+ <Button type="submit" variant="contained" color="primary"
+ className={classes.buttonAdd}>
+ {"ADD"}</Button>
+ </Grid>
+ </Grid>
+ </form>
+ </CardContent>
+ </Card>
+ );
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { RootState } from '~/store/store';
+import { Dispatch } from 'redux';
+import { connect } from 'react-redux';
+import {
+ SiteManagerPanelRoot, SiteManagerPanelRootActionProps,
+ SiteManagerPanelRootDataProps
+} from "~/views/site-manager-panel/site-manager-panel-root";
+import { Session } from "~/models/session";
+import { toggleSession } from "~/store/auth/auth-action-session";
+
+const mapStateToProps = (state: RootState): SiteManagerPanelRootDataProps => {
+ return {
+ sessions: state.auth.sessions
+ };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): SiteManagerPanelRootActionProps => ({
+ toggleSession: (session: Session) => {
+ dispatch<any>(toggleSession(session));
+ }
+});
+
+export const SiteManagerPanel = connect(mapStateToProps, mapDispatchToProps)(SiteManagerPanelRoot);
import { RootState } from '~/store/store';
import { Dispatch } from 'redux';
import { connect } from 'react-redux';
-import { openSshKeyCreateDialog, openPublicKeyDialog } from '~/store/auth/auth-action';
+import { openSshKeyCreateDialog, openPublicKeyDialog } from '~/store/auth/auth-action-ssh';
import { openSshKeyContextMenu } from '~/store/context-menu/context-menu-actions';
import { SshKeyPanelRoot, SshKeyPanelRootDataProps, SshKeyPanelRootActionProps } from '~/views/ssh-key-panel/ssh-key-panel-root';
}
});
-export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);
\ No newline at end of file
+export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);
import { WorkflowPanel } from '~/views/workflow-panel/workflow-panel';
import { SearchResultsPanel } from '~/views/search-results-panel/search-results-panel';
import { SshKeyPanel } from '~/views/ssh-key-panel/ssh-key-panel';
+import { SiteManagerPanel } from "~/views/site-manager-panel/site-manager-panel";
import { MyAccountPanel } from '~/views/my-account-panel/my-account-panel';
import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
import { UserAttributesDialog } from '~/views-components/user-dialog/attributes-dialog';
import { CreateUserDialog } from '~/views-components/dialog-forms/create-user-dialog';
import { HelpApiClientAuthorizationDialog } from '~/views-components/api-client-authorizations-dialog/help-dialog';
+import { GroupsPanel } from '~/views/groups-panel/groups-panel';
+import { CreateGroupDialog } from '~/views-components/dialog-forms/create-group-dialog';
+import { RemoveGroupDialog } from '~/views-components/groups-dialog/remove-dialog';
+import { GroupAttributesDialog } from '~/views-components/groups-dialog/attributes-dialog';
+import { GroupDetailsPanel } from '~/views/group-details-panel/group-details-panel';
+import { RemoveGroupMemberDialog } from '~/views-components/groups-dialog/member-remove-dialog';
+import { GroupMemberAttributesDialog } from '~/views-components/groups-dialog/member-attributes-dialog';
+import { AddGroupMembersDialog } from '~/views-components/dialog-forms/add-group-member-dialog';
type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
<Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
<Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
<Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
+ <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
<Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
<Route path={Routes.USERS} component={UserPanel} />
<Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
<Route path={Routes.API_CLIENT_AUTHORIZATIONS} component={ApiClientAuthorizationPanel} />
<Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
+ <Route path={Routes.GROUPS} component={GroupsPanel} />
+ <Route path={Routes.GROUP_DETAILS} component={GroupDetailsPanel} />
<Route path={Routes.LINKS} component={LinkPanel} />
</Switch>
</Grid>
<Grid item>
<DetailsPanel />
</Grid>
+ <AddGroupMembersDialog />
<AdvancedTabDialog />
<AttributesApiClientAuthorizationDialog />
<AttributesComputeNodeDialog />
<CopyCollectionDialog />
<CopyProcessDialog />
<CreateCollectionDialog />
+ <CreateGroupDialog />
<CreateProjectDialog />
<CreateRepositoryDialog />
<CreateSshKeyDialog />
<CurrentTokenDialog />
<FileRemoveDialog />
<FilesUploadCollectionDialog />
+ <GroupAttributesDialog />
+ <GroupMemberAttributesDialog />
<HelpApiClientAuthorizationDialog />
<MoveCollectionDialog />
<MoveProcessDialog />
<ProjectPropertiesDialog />
<RemoveApiClientAuthorizationDialog />
<RemoveComputeNodeDialog />
+ <RemoveGroupDialog />
+ <RemoveGroupMemberDialog />
<RemoveKeepServiceDialog />
<RemoveLinkDialog />
<RemoveProcessDialog />
<UserAttributesDialog />
<VirtualMachineAttributesDialog />
</Grid>
- );
\ No newline at end of file
+ );
csstype "^2.0.0"
indefinite-observable "^1.0.1"
+"@types/jssha@0.0.29":
+ version "0.0.29"
+ resolved "https://registry.yarnpkg.com/@types/jssha/-/jssha-0.0.29.tgz#95e83dba98787ff796d2d5f37a1925abf41bc9cb"
+ integrity sha1-leg9uph4f/eW0tXzehklq/Qbycs=
+
"@types/lodash@4.14.116":
version "4.14.116"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.116.tgz#5ccf215653e3e8c786a58390751033a9adca0eb9"
symbol-observable "^1.1.0"
warning "^3.0.0"
+jssha@2.3.1:
+ version "2.3.1"
+ resolved "https://registry.yarnpkg.com/jssha/-/jssha-2.3.1.tgz#147b2125369035ca4b2f7d210dc539f009b3de9a"
+ integrity sha1-FHshJTaQNcpLL30hDcU58Amz3po=
+
keycode@^2.1.9:
version "2.2.0"
resolved "https://registry.yarnpkg.com/keycode/-/keycode-2.2.0.tgz#3d0af56dc7b8b8e5cba8d0a97f107204eec22b04"