1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { PermissionLevel } from '~/models/permission';
6 import { getFormValues, isDirty } from 'redux-form';
7 import { RootState } from '~/store/store';
9 export const SHARING_DIALOG_NAME = 'SHARING_DIALOG_NAME';
10 export const SHARING_PUBLIC_ACCESS_FORM_NAME = 'SHARING_PUBLIC_ACCESS_FORM_NAME';
11 export const SHARING_MANAGEMENT_FORM_NAME = 'SHARING_MANAGEMENT_FORM_NAME';
12 export const SHARING_INVITATION_FORM_NAME = 'SHARING_INVITATION_FORM_NAME';
14 export enum VisibilityLevel {
20 export interface SharingPublicAccessFormData {
21 visibility: VisibilityLevel;
22 permissionUuid: string;
25 export interface SharingManagementFormData {
26 permissions: SharingManagementFormDataRow[];
27 initialPermissions: SharingManagementFormDataRow[];
30 export interface SharingManagementFormDataRow {
32 permissions: PermissionLevel;
33 permissionUuid: string;
36 export interface SharingInvitationFormData {
37 permissions: PermissionLevel;
38 invitedPeople: SharingInvitationFormPersonData[];
41 export interface SharingInvitationFormPersonData {
47 export const getSharingMangementFormData = (state: any) =>
48 getFormValues(SHARING_MANAGEMENT_FORM_NAME)(state) as SharingManagementFormData;
50 export const getSharingPublicAccessFormData = (state: any) =>
51 getFormValues(SHARING_PUBLIC_ACCESS_FORM_NAME)(state) as SharingPublicAccessFormData;
53 export const hasChanges = (state: RootState) =>
54 isDirty(SHARING_PUBLIC_ACCESS_FORM_NAME)(state) ||
55 isDirty(SHARING_MANAGEMENT_FORM_NAME)(state) ||
56 isDirty(SHARING_INVITATION_FORM_NAME)(state);