-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: keypair info/setting modal in credential page (#2940)
<!-- Please precisely, concisely, and concretely describe what this PR changes, the rationale behind codes, and how it affects the users and other developers. --> ### This PR resolves [#2937](#2937) issue **Changes:** - Since `UserSettingPage` is using the KeypairInfoModal, I renamed the component to MyKeypairInfoModal. - Added `KeypairInfoModal` and `KeypairSettingModal` for `Credential Page`. - The `KeypairSettingModal` is used to create or modify a key pair. - ordering/filtering keypair_list query by user_id is out of scope for this PR because it does not yet provide ordering, filtering on user_id. **How to test:** - Access the user credentials & policy page with an account with admin or higher permissions. - Verify that the `KeypairInfoModal` shows the correct information for the selected keypair. - Verify that the `KeypairSettingModal` allows you to create and modify keypair information. **Checklist:** (if applicable) - [ ] Mention to the original issue - [ ] Documentation - [ ] Minium required manager version - [ ] Specific setting for review (eg., KB link, endpoint or how to setup) - [ ] Minimum requirements to check during review - [ ] Test case(s) to demonstrate the difference of before/after
- Loading branch information
1 parent
e07e4bc
commit ec8d643
Showing
28 changed files
with
615 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { localeCompare } from '../helper'; | ||
import useControllableState from '../hooks/useControllableState'; | ||
import { KeypairResourcePolicySelectorQuery } from './__generated__/KeypairResourcePolicySelectorQuery.graphql'; | ||
import { Select, SelectProps } from 'antd'; | ||
import graphql from 'babel-plugin-relay/macro'; | ||
import _ from 'lodash'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useLazyLoadQuery } from 'react-relay'; | ||
|
||
interface KeypairResourcePolicySelectorProps extends SelectProps {} | ||
|
||
const KeypairResourcePolicySelector: React.FC< | ||
KeypairResourcePolicySelectorProps | ||
> = ({ ...selectProps }) => { | ||
const { t } = useTranslation(); | ||
const [value, setValue] = useControllableState<string>({ | ||
value: selectProps.value, | ||
onChange: selectProps.onChange, | ||
}); | ||
|
||
const { keypair_resource_policies } = | ||
useLazyLoadQuery<KeypairResourcePolicySelectorQuery>( | ||
graphql` | ||
query KeypairResourcePolicySelectorQuery { | ||
keypair_resource_policies { | ||
name | ||
} | ||
} | ||
`, | ||
{}, | ||
{ fetchPolicy: 'store-and-network' }, | ||
); | ||
|
||
return ( | ||
<Select | ||
showSearch | ||
placeholder={t('credential.SelectPolicy')} | ||
options={_.map(keypair_resource_policies, (policy) => { | ||
return { | ||
value: policy?.name, | ||
label: policy?.name, | ||
}; | ||
}).sort((a, b) => localeCompare(a?.label, b?.label))} | ||
{...selectProps} | ||
value={value} | ||
onChange={(value, option) => { | ||
setValue(value, option); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default KeypairResourcePolicySelector; |
Oops, something went wrong.