diff --git a/react/data/schema.graphql b/react/data/schema.graphql index 41eb9ed0d2..16f6188767 100644 --- a/react/data/schema.graphql +++ b/react/data/schema.graphql @@ -236,9 +236,12 @@ input CreateKeyPairResourcePolicyInput { max_concurrent_sessions: Int! max_containers_per_session: Int! idle_timeout: BigInt! - max_vfolder_count: Int! - max_vfolder_size: BigInt! allowed_vfolder_hosts: JSONString + + max_vfolder_count: Int @deprecated(reason: "Deprecated since 23.09.4") + max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.4") + max_quota_scope_size: BigInt @deprecated(reason: "Deprecated since 23.09.4") + } type CreateProjectResourcePolicy { @@ -248,6 +251,8 @@ type CreateProjectResourcePolicy { } input CreateProjectResourcePolicyInput { + "since 24.03.0" + max_vfolder_count: Int max_quota_scope_size: BigInt } @@ -294,6 +299,8 @@ type CreateUserResourcePolicy { } input CreateUserResourcePolicyInput { + "since 24.03.0" + max_vfolder_count: Int max_quota_scope_size: BigInt } @@ -575,9 +582,10 @@ type KeyPairResourcePolicy { max_concurrent_sessions: Int max_containers_per_session: Int idle_timeout: BigInt - max_vfolder_count: Int - max_vfolder_size: BigInt allowed_vfolder_hosts: JSONString + max_vfolder_count: Int @deprecated(reason: "Deprecated since 23.09.4") + max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.4") + max_quota_scope_size: BigInt @deprecated(reason: "Deprecated since 23.09.4") } type LegacyComputeSession implements Item { @@ -740,9 +748,10 @@ input ModifyKeyPairResourcePolicyInput { max_concurrent_sessions: Int max_containers_per_session: Int idle_timeout: BigInt - max_vfolder_count: Int - max_vfolder_size: BigInt allowed_vfolder_hosts: JSONString + max_vfolder_count: Int @deprecated(reason: "Deprecated since 23.09.4") + max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.4") + max_quota_scope_size: BigInt @deprecated(reason: "Deprecated since 23.09.4") } type ModifyProjectResourcePolicy { @@ -751,6 +760,8 @@ type ModifyProjectResourcePolicy { } input ModifyProjectResourcePolicyInput { + "since 24.03.0" + max_vfolder_count: Int max_quota_scope_size: BigInt } @@ -811,6 +822,8 @@ type ModifyUserResourcePolicy { } input ModifyUserResourcePolicyInput { + "since 24.03.0" + max_vfolder_count: Int max_quota_scope_size: BigInt } @@ -892,6 +905,8 @@ type ProjectResourcePolicy { id: ID! name: String! created_at: DateTime! + "since 24.03.0" + max_vfolder_count: Int max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.1") max_quota_scope_size: BigInt } @@ -1139,6 +1154,8 @@ type UserResourcePolicy { id: ID! name: String! created_at: DateTime! + "since 24.03.0" + max_vfolder_count: Int max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.1") max_quota_scope_size: BigInt } diff --git a/react/src/components/StorageStatusPanel.tsx b/react/src/components/StorageStatusPanel.tsx index bfbca02c0c..68f1df9ab9 100644 --- a/react/src/components/StorageStatusPanel.tsx +++ b/react/src/components/StorageStatusPanel.tsx @@ -68,7 +68,6 @@ const StorageStatusPanel: React.FC<{ ).length; // TODO: Add resolver to enable subquery and modify to call useLazyLoadQuery only once. - // const { user } = useLazyLoadQuery( const { keypair, user } = useLazyLoadQuery( graphql` query StorageStatusPanelKeypairQuery( @@ -81,6 +80,8 @@ const StorageStatusPanel: React.FC<{ } user(domain_name: $domain_name, email: $email) { id + # TODO: check version and add @since + resource_policy } } `, @@ -91,55 +92,62 @@ const StorageStatusPanel: React.FC<{ }, ); - // const { user_resource_policy, project_quota_scope, user_quota_scope } = - const { keypair_resource_policy, project_quota_scope, user_quota_scope } = - useLazyLoadQuery( - graphql` - query StorageStatusPanelQuery( - # $name: String - $keypair_resource_policy_name: String - $project_quota_scope_id: String! - $user_quota_scope_id: String! - $storage_host_name: String! - $skipQuotaScope: Boolean! - ) { - # user_resource_policy(name: $name) { - # max_vfolder_count - # } - keypair_resource_policy(name: $keypair_resource_policy_name) { - max_vfolder_count - } - project_quota_scope: quota_scope( - quota_scope_id: $project_quota_scope_id - storage_host_name: $storage_host_name - ) @skip(if: $skipQuotaScope) { - ...UsageProgressFragment_usageFrgmt - } - user_quota_scope: quota_scope( - quota_scope_id: $user_quota_scope_id - storage_host_name: $storage_host_name - ) @skip(if: $skipQuotaScope) { - ...UsageProgressFragment_usageFrgmt - } + const { + user_resource_policy, + keypair_resource_policy, + project_quota_scope, + user_quota_scope, + } = useLazyLoadQuery( + graphql` + query StorageStatusPanelQuery( + $name: String + $keypair_resource_policy_name: String + $project_quota_scope_id: String! + $user_quota_scope_id: String! + $storage_host_name: String! + $skipQuotaScope: Boolean! + ) { + user_resource_policy(name: $name) @since(version: "24.03.0") { + max_vfolder_count + } + keypair_resource_policy(name: $keypair_resource_policy_name) + @deprecatedSince(version: "24.03.0") { + max_vfolder_count } - `, - { - keypair_resource_policy_name: keypair?.resource_policy, - project_quota_scope_id: addQuotaScopeTypePrefix( - 'project', - currentProject?.id, - ), - user_quota_scope_id: addQuotaScopeTypePrefix('user', user?.id || ''), - storage_host_name: deferredSelectedVolumeInfo?.id || '', - skipQuotaScope: - currentProject?.id === undefined || - user?.id === undefined || - !deferredSelectedVolumeInfo?.id, - }, - ); + project_quota_scope: quota_scope( + quota_scope_id: $project_quota_scope_id + storage_host_name: $storage_host_name + ) @skip(if: $skipQuotaScope) { + ...UsageProgressFragment_usageFrgmt + } + user_quota_scope: quota_scope( + quota_scope_id: $user_quota_scope_id + storage_host_name: $storage_host_name + ) @skip(if: $skipQuotaScope) { + ...UsageProgressFragment_usageFrgmt + } + } + `, + { + name: user?.resource_policy, + keypair_resource_policy_name: keypair?.resource_policy, + project_quota_scope_id: addQuotaScopeTypePrefix( + 'project', + currentProject?.id, + ), + user_quota_scope_id: addQuotaScopeTypePrefix('user', user?.id || ''), + storage_host_name: deferredSelectedVolumeInfo?.id || '', + skipQuotaScope: + currentProject?.id === undefined || + user?.id === undefined || + !deferredSelectedVolumeInfo?.id, + }, + ); - const maxVfolderCount = keypair_resource_policy?.max_vfolder_count || 0; - // const maxVfolderCount = user_resource_policy?.max_vfolder_count || 0; + const maxVfolderCount = + user_resource_policy?.max_vfolder_count || + keypair_resource_policy?.max_vfolder_count || + 0; const numberOfFolderPercent = ( maxVfolderCount > 0 ? ((createdCount / maxVfolderCount) * 100)?.toFixed(2)