mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-04-25 01:07:55 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-js authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { AddressMini, InputAddress, Labelled, styled, TxButton } from '@pezkuwi/react-components';
|
||||
import { useApi } from '@pezkuwi/react-hooks';
|
||||
|
||||
import { useTranslation } from './translate.js';
|
||||
|
||||
interface Props {
|
||||
allAccounts: string[];
|
||||
className?: string;
|
||||
isMine?: boolean;
|
||||
sudoKey?: string;
|
||||
}
|
||||
|
||||
function SetKey ({ allAccounts, className = '', isMine, sudoKey }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const [selected, setSelected] = useState<string | null>(null);
|
||||
|
||||
useEffect((): void => {
|
||||
sudoKey && !selected && setSelected(sudoKey);
|
||||
}, [selected, sudoKey]);
|
||||
|
||||
const willLose = isMine &&
|
||||
!!selected &&
|
||||
selected !== sudoKey &&
|
||||
allAccounts.some((s): boolean => s === selected);
|
||||
|
||||
return (
|
||||
<section>
|
||||
<StyledSection className={`${className} ui--row`}>
|
||||
{isMine
|
||||
? (
|
||||
<>
|
||||
<InputAddress
|
||||
className='sudoInputAddress'
|
||||
isInput={true}
|
||||
label={t('sudo key')}
|
||||
onChange={setSelected}
|
||||
type='all'
|
||||
value={selected}
|
||||
/>
|
||||
<TxButton
|
||||
accountId={sudoKey}
|
||||
icon='sign-in-alt'
|
||||
isDisabled={!isMine || sudoKey === selected}
|
||||
label={t('Reassign')}
|
||||
params={[selected]}
|
||||
tx={api.tx.sudo.setKey}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
: (
|
||||
<Labelled
|
||||
className='ui--Dropdown sudoLabelled'
|
||||
label={t('sudo key')}
|
||||
withLabel
|
||||
>
|
||||
<AddressMini value={sudoKey} />
|
||||
</Labelled>
|
||||
)
|
||||
}
|
||||
</StyledSection>
|
||||
{willLose && (
|
||||
<article className='warning padded'>
|
||||
<div>{t('You will no longer have sudo access')}</div>
|
||||
</article>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const StyledSection = styled.section`
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
|
||||
.summary {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sudoInputAddress {
|
||||
margin: -0.25rem 0.5rem -0.25rem 0;
|
||||
}
|
||||
|
||||
.sudoLabelled {
|
||||
align-items: center;
|
||||
}
|
||||
`;
|
||||
|
||||
export default React.memo(SetKey);
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-js authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SubmittableExtrinsic } from '@pezkuwi/api/types';
|
||||
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { Button, Icon, styled, Toggle, TxButton } from '@pezkuwi/react-components';
|
||||
import { useApi, useToggle } from '@pezkuwi/react-hooks';
|
||||
import { Extrinsic } from '@pezkuwi/react-params';
|
||||
import { isFunction } from '@pezkuwi/util';
|
||||
|
||||
import { useTranslation } from './translate.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
isMine: boolean;
|
||||
sudoKey?: string;
|
||||
}
|
||||
|
||||
function Sudo ({ className, isMine, sudoKey }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const [withWeight, toggleWithWeight] = useToggle();
|
||||
const [extrinsic, setExtrinsic] = useState<SubmittableExtrinsic<'promise'> | null>(null);
|
||||
|
||||
const _onChangeExtrinsic = useCallback(
|
||||
(method?: SubmittableExtrinsic<'promise'>) => {
|
||||
setExtrinsic(() => method || null);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return isMine
|
||||
? (
|
||||
<StyledSection className={className}>
|
||||
<Extrinsic
|
||||
defaultValue={withWeight ? api.tx.sudo.sudoUncheckedWeight : api.tx.sudo.sudo}
|
||||
isDisabled
|
||||
key={String(withWeight)}
|
||||
label={t('submit the following change')}
|
||||
onChange={_onChangeExtrinsic}
|
||||
/>
|
||||
{isFunction(api.tx.sudo.sudoUncheckedWeight) && (
|
||||
<Toggle
|
||||
className='sudoToggle'
|
||||
label={t('with weight override')}
|
||||
onChange={toggleWithWeight}
|
||||
value={withWeight}
|
||||
/>
|
||||
)}
|
||||
<Button.Group>
|
||||
<TxButton
|
||||
accountId={sudoKey}
|
||||
extrinsic={extrinsic}
|
||||
icon='sign-in-alt'
|
||||
isDisabled={!extrinsic}
|
||||
label={
|
||||
withWeight
|
||||
? t('Submit Sudo Unchecked')
|
||||
: t('Submit Sudo')
|
||||
}
|
||||
/>
|
||||
</Button.Group>
|
||||
</StyledSection>
|
||||
)
|
||||
: (
|
||||
<article className='error padded'>
|
||||
<div>
|
||||
<Icon icon='ban' />
|
||||
{t('You do not have access to the current sudo key')}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
const StyledSection = styled.section`
|
||||
.sudoToggle {
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
padding-top: 1rem;
|
||||
}
|
||||
`;
|
||||
|
||||
export default React.memo(Sudo);
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-js authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AppProps as Props } from '@pezkuwi/react-components/types';
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Routes } from 'react-router';
|
||||
|
||||
import { Icon, Tabs } from '@pezkuwi/react-components';
|
||||
import { useSudo } from '@pezkuwi/react-hooks';
|
||||
|
||||
import SetKey from './SetKey.js';
|
||||
import Sudo from './Sudo.js';
|
||||
import { useTranslation } from './translate.js';
|
||||
|
||||
function SudoApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { allAccounts, hasSudoKey, sudoKey } = useSudo();
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'index',
|
||||
text: t('Sudo access')
|
||||
},
|
||||
{
|
||||
name: 'key',
|
||||
text: t('Set sudo key')
|
||||
}
|
||||
]);
|
||||
|
||||
return (
|
||||
<main>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
{hasSudoKey
|
||||
? (
|
||||
<Routes>
|
||||
<Route path={basePath}>
|
||||
<Route
|
||||
element={
|
||||
<SetKey
|
||||
allAccounts={allAccounts}
|
||||
isMine={hasSudoKey}
|
||||
sudoKey={sudoKey}
|
||||
/>
|
||||
}
|
||||
path='key'
|
||||
/>
|
||||
<Route
|
||||
element={
|
||||
<Sudo
|
||||
isMine={hasSudoKey}
|
||||
sudoKey={sudoKey}
|
||||
/>
|
||||
}
|
||||
index
|
||||
/>
|
||||
</Route>
|
||||
</Routes>
|
||||
)
|
||||
: (
|
||||
<article className='error padded'>
|
||||
<div>
|
||||
<Icon icon='ban' />
|
||||
{t('You do not have access to the current sudo key')}
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(SudoApp);
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-sudo authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { useTranslation as useTranslationBase } from 'react-i18next';
|
||||
|
||||
export function useTranslation (): { t: (key: string, options?: { replace: Record<string, unknown> }) => string } {
|
||||
return useTranslationBase('app-sudo');
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-staking authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export interface ComponentProps {
|
||||
allAccounts: string[];
|
||||
className?: string;
|
||||
isMine: boolean;
|
||||
sudoKey?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user