Skip to content

Commit

Permalink
update schema.graphql and apply @SInCE and @deprecatedSince to Storag…
Browse files Browse the repository at this point in the history
…eStatusPanel.tsx
  • Loading branch information
yomybaby committed Oct 31, 2023
1 parent 033389e commit f87e8f0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 54 deletions.
29 changes: 23 additions & 6 deletions react/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -248,6 +251,8 @@ type CreateProjectResourcePolicy {
}

input CreateProjectResourcePolicyInput {
"since 24.03.0"
max_vfolder_count: Int
max_quota_scope_size: BigInt
}

Expand Down Expand Up @@ -294,6 +299,8 @@ type CreateUserResourcePolicy {
}

input CreateUserResourcePolicyInput {
"since 24.03.0"
max_vfolder_count: Int
max_quota_scope_size: BigInt
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -751,6 +760,8 @@ type ModifyProjectResourcePolicy {
}

input ModifyProjectResourcePolicyInput {
"since 24.03.0"
max_vfolder_count: Int
max_quota_scope_size: BigInt
}

Expand Down Expand Up @@ -811,6 +822,8 @@ type ModifyUserResourcePolicy {
}

input ModifyUserResourcePolicyInput {
"since 24.03.0"
max_vfolder_count: Int
max_quota_scope_size: BigInt
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
104 changes: 56 additions & 48 deletions react/src/components/StorageStatusPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<StorageStatusPanelKeypairQuery>(
const { keypair, user } = useLazyLoadQuery<StorageStatusPanelKeypairQuery>(
graphql`
query StorageStatusPanelKeypairQuery(
Expand All @@ -81,6 +80,8 @@ const StorageStatusPanel: React.FC<{
}
user(domain_name: $domain_name, email: $email) {
id
# TODO: check version and add @since
resource_policy
}
}
`,
Expand All @@ -91,55 +92,62 @@ const StorageStatusPanel: React.FC<{
},
);

Check warning on line 93 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

// const { user_resource_policy, project_quota_scope, user_quota_scope } =
const { keypair_resource_policy, project_quota_scope, user_quota_scope } =
useLazyLoadQuery<StorageStatusPanelQuery>(
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<StorageStatusPanelQuery>(
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 || ''),

Check warning on line 138 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 138 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
storage_host_name: deferredSelectedVolumeInfo?.id || '',

Check warning on line 139 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 139 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
skipQuotaScope:
currentProject?.id === undefined ||

Check warning on line 141 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
user?.id === undefined ||

Check warning on line 142 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
!deferredSelectedVolumeInfo?.id,

Check warning on line 143 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
},
);

Check warning on line 145 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

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 ||

Check warning on line 148 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
keypair_resource_policy?.max_vfolder_count ||

Check warning on line 149 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
0;

Check warning on line 150 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 150 in react/src/components/StorageStatusPanel.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
const numberOfFolderPercent = (
maxVfolderCount > 0
? ((createdCount / maxVfolderCount) * 100)?.toFixed(2)
Expand Down

0 comments on commit f87e8f0

Please sign in to comment.