mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-04-22 15:57:59 +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);
|
||||
Reference in New Issue
Block a user