// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
// with the License. A copy of the License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
// OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
// limitations under the License.
import {ClusterStatus, ClusterDescription} from '../../types/clusters'
import React, {PropsWithChildren, ReactElement} from 'react'
import {Trans, useTranslation} from 'react-i18next'
import {findFirst, clusterDefaultUser} from '../../util'
import {useState, setState, ssmPolicy} from '../../store'
// UI Elements
import {
Box,
Button,
ColumnLayout,
Container,
Header,
Link,
Popover,
SpaceBetween,
StatusIndicator,
} from '@cloudscape-design/components'
// Components
import ConfigDialog from './ConfigDialog'
import DateView from '../../components/date/DateView'
import {
ClusterStatusIndicator,
ComputeFleetStatusIndicator,
} from '../../components/Status'
import TitleDescriptionHelpPanel from '../../components/help-panel/TitleDescriptionHelpPanel'
import InfoLink from '../../components/InfoLink'
import {useClusterPoll} from '../../components/useClusterPoll'
import {ValueWithLabel} from '../../components/ValueWithLabel'
export default function ClusterProperties() {
const {t} = useTranslation()
const clusterName = useState(['app', 'clusters', 'selected'])
const clusterPath = ['clusters', 'index', clusterName]
const cluster: ClusterDescription = useState(clusterPath)
const headNode = useState([...clusterPath, 'headNode'])
const defaultRegion = useState(['aws', 'region'])
const region = useState(['app', 'selectedRegion']) || defaultRegion
function isSsmPolicy(p: any) {
return p.hasOwnProperty('Policy') && p.Policy === ssmPolicy(region)
}
const iamPolicies = useState([
...clusterPath,
'config',
'HeadNode',
'Iam',
'AdditionalIamPolicies',
])
const ssmEnabled = iamPolicies && findFirst(iamPolicies, isSsmPolicy)
const footerLinks = [
{
title: t('global.help.ec2ConnectLink.title'),
href: t('global.help.ec2ConnectLink.href'),
},
]
useClusterPoll(clusterName, true)
return (
<>
Properties}>
{headNode && headNode.publicIpAddress && (
}
/>
}
/>
}
>