Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: permission in code select #401

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#401](https://github.com/alleslabs/celatone-frontend/pull/401) Add permission chip to code selection box
- [#386](https://github.com/alleslabs/celatone-frontend/pull/386) Handle uppercase address
- [#382](https://github.com/alleslabs/celatone-frontend/pull/382) Add pool manager v15 msgs to tx details
- [#371](https://github.com/alleslabs/celatone-frontend/pull/371) Refactor assign me component and fix color in redelegation page
Expand Down
28 changes: 21 additions & 7 deletions src/lib/components/select-code/CodeSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { FlexProps } from "@chakra-ui/react";
import { Flex, Text } from "@chakra-ui/react";

import { DotSeparator } from "../DotSeparator";
import { PermissionChip } from "../PermissionChip";
import type { FormStatus } from "lib/components/forms";
import { UploadIcon } from "lib/components/icon";
import { useUserKey } from "lib/hooks";
import { useCodeStore } from "lib/providers/store";
import { useCodeDataByCodeId } from "lib/services/codeService";
import { AccessConfigPermission } from "lib/types";

import { CodeSelectDrawerButton } from "./CodeSelectDrawerButton";

Expand All @@ -20,9 +23,9 @@ export const CodeSelect = ({
status,
...componentProps
}: CodeSelectProps) => {
const { codeInfo } = useCodeStore();
const userKey = useUserKey();
const name = codeInfo?.[userKey]?.[Number(codeId)]?.name;
const { getCodeLocalInfo } = useCodeStore();
const name = getCodeLocalInfo(Number(codeId))?.name;
const { data: codeInfo } = useCodeDataByCodeId(Number(codeId));

const isError = status.state === "error";
return (
Expand All @@ -49,9 +52,19 @@ export const CodeSelect = ({
>
{name ?? "Untitled Name"}
</Text>
<Text variant="body2" color="text.dark">
Code ID {codeId}
</Text>
<Flex alignItems="center" gap={2}>
<Text variant="body2" color="text.dark">
Code ID {codeId}
</Text>
<DotSeparator />
<PermissionChip
instantiatePermission={
codeInfo?.instantiatePermission ??
AccessConfigPermission.UNKNOWN
}
permissionAddresses={codeInfo?.permissionAddresses ?? []}
/>
</Flex>
</Flex>
) : (
<Text variant="body1" fontWeight={500}>
Expand All @@ -63,6 +76,7 @@ export const CodeSelect = ({
buttonText={codeId ? "Change Code" : "Select Code"}
/>
</Flex>

{isError && (
<Text variant="body3" color="error.main" mt={1} ml={3}>
{status.message}
Expand Down