Skip to content

Commit

Permalink
LinkedHubs visual update after review
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikMatiasko committed Apr 30, 2024
1 parent bd23aed commit ebdba8a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/common/hooks/useWellKnownConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type WellKnownConfigType = {
defaultDiscoveryTimeout?: string
}
id?: string
jwtOwnerClaim?: string
} & BuildInformationType

type useWellKnownConfigurationReturnType = [
Expand Down
11 changes: 11 additions & 0 deletions src/common/services/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ export const isYourId = (uuid: string, hubsData: any) => {
}

export const isOwnerId = (uuid: string, owner: string) => (checkIfValidUUID(uuid) && uuid === owner) || uuidv5(owner, uuidv5.URL) === uuid

export const getOwnerId = (jwtOwnerClaim: string) => {
const accessToken = security.getAccessToken()

if (accessToken) {
const parsedData: any = jwtDecode(accessToken)
return get(parsedData, jwtOwnerClaim as string, '')
}

return ''
}
21 changes: 16 additions & 5 deletions src/components/Templates/FullPageWizard/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import IconQuestion from '../../Atomic/Icon/components/IconQuestion'
import { convertSize } from '../../Atomic/Icon'
import ShowAnimate from '../../Atomic/ShowAnimate'
import IconSettings from '../../Atomic/Icon/components/IconSettings'
import isFunction from 'lodash/isFunction'

export type DescriptionProps = {
children: string
Expand All @@ -31,11 +32,13 @@ export type GroupHeadlineProps = {
export type ToggleConfigurationProps = {
defaultShow?: boolean
children: React.ReactNode | React.ReactNode[]
hideToggleLink?: boolean
i18n: {
hide: string
show: string
}
margin?: boolean
onShowChange?: (show: boolean) => void
}

export const Description: FC<DescriptionProps> = (props) => <p css={[styles.description, props.large && styles.descriptionLarge]}>{props.children}</p>
Expand All @@ -61,17 +64,25 @@ export const GroupHeadline: FC<GroupHeadlineProps> = (props) => (
)

export const ToggleConfiguration: FC<ToggleConfigurationProps> = (props) => {
const { i18n, children, margin = true } = props
const [show, setShow] = useState(false)
const { defaultShow, i18n, children, hideToggleLink, margin = true, onShowChange } = props
const [show, setShow] = useState(defaultShow ?? false)

return (
<>
<ShowAnimate show={show}>
<>{children}</>
</ShowAnimate>
<div css={[styles.expander, margin && styles.expanderMargin]} onClick={() => setShow(!show)}>
<IconSettings /> {show ? i18n.hide : i18n.show}
</div>
{hideToggleLink === undefined && (
<div
css={[styles.expander, margin && styles.expanderMargin]}
onClick={() => {
setShow(!show)
isFunction(onShowChange) && onShowChange(!show)
}}
>
<IconSettings /> {show ? i18n.hide : i18n.show}
</div>
)}
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ import isFunction from 'lodash/isFunction'

import * as commonStyles from '../FullPageWizardCommon.styles'
import * as styles from '../FullPageWizard.styles'
import { Props } from './StepButtons.types'
import { Props, defaultProps } from './StepButtons.types'
import Spacer from '../../../Atomic/Spacer'
import Button from '../../../Atomic/Button'
import Tooltip from '../../../Atomic/Tooltip'

const StepButtons: FC<Props> = (props) => {
const { disableNext, i18n, onClickBack, onClickNext } = props
const { disableNext, i18n, onClickBack, onClickNext, showRequiredMessage } = { ...defaultProps, ...props }
const requiredMessageSplit = i18n.requiredMessage.split('(*)')

return (
<>
<Spacer css={commonStyles.description} type='mt-10'>
{requiredMessageSplit[0]}(<span css={styles.requiredStar}>*</span>){requiredMessageSplit[1]}
{showRequiredMessage && (
<span>
{requiredMessageSplit[0]}(<span css={styles.requiredStar}>*</span>){requiredMessageSplit[1]}
</span>
)}
</Spacer>
<Spacer css={commonStyles.buttons} type='mt-4'>
{isFunction(onClickBack) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export type Props = {
}
onClickBack?: () => void
onClickNext: () => void
showRequiredMessage?: boolean
}

export const defaultProps: Partial<Props> = {
showRequiredMessage: true,
}

0 comments on commit ebdba8a

Please sign in to comment.