Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dd62cfa
OpenConceptLab/ocl_online#701 | Limit dialogs ask /billing/plan/ abou…
paynejd Nov 24, 2026
d572aa5
OpenConceptLab/ocl_online#702 | LimitNotice: a refusal's or a resourc…
paynejd Nov 24, 2026
5489eda
OpenConceptLab/ocl_online#424 | A read-only project shows its notice …
paynejd Nov 24, 2026
932fbb4
OpenConceptLab/ocl_online#424 | A save that goes through ends read-on…
paynejd Nov 24, 2026
8b7f7f4
OpenConceptLab/ocl_online#424 | A save queued behind one refused as r…
paynejd Nov 24, 2026
807ef8f
OpenConceptLab/ocl_online#424 | Leaving a read-only project warns whi…
paynejd Nov 24, 2026
50c96a8
OpenConceptLab/ocl_online#424 | A read-only refusal with no notice sh…
paynejd Nov 24, 2026
eb7b5b9
OpenConceptLab/ocl_online#702 | An empty answer from the notices rout…
paynejd Nov 24, 2026
c4b1592
OpenConceptLab/ocl_online#424 | A read-only refusal is recorded befor…
paynejd Nov 24, 2026
95fc6b4
OpenConceptLab/ocl_online#424 | Leaving a read-only project in the ap…
paynejd Nov 24, 2026
12a62a6
OpenConceptLab/ocl_online#424 | A comment counts as an unsaved edit u…
paynejd Nov 24, 2026
3b1ee5b
OpenConceptLab/ocl_online#424 | A read-only refusal that lands after …
paynejd Nov 24, 2026
e82698c
OpenConceptLab/ocl_online#424 | Leaving a read-only project counts Co…
paynejd Nov 24, 2026
00c83df
OpenConceptLab/ocl_online#424 | Edits kept back while read-only are a…
paynejd Nov 24, 2026
69271cd
OpenConceptLab/ocl_online#424 | The redirect after a confirmed delete…
paynejd Nov 24, 2026
c4ff038
OpenConceptLab/ocl_online#424 | Leaving a run on a read-only project …
paynejd Nov 24, 2026
33fe219
OpenConceptLab/ocl_online#424 | A read-only project locks every contr…
paynejd Nov 24, 2026
1f1c470
OpenConceptLab/ocl_online#424 | Drop the read-only leave prompts the …
paynejd Nov 24, 2026
157d63c
OpenConceptLab/ocl_online#424 | The decision and review locks sit wit…
paynejd Nov 24, 2026
eab419a
OpenConceptLab/ocl_online#424 | Edits made before a project turned re…
paynejd Nov 24, 2026
fe3dc81
OpenConceptLab/ocl_online#424 | Leaving a run on a read-only project …
paynejd Nov 24, 2026
25b86ee
OpenConceptLab/ocl_online#424 | A newer answer from the notices route…
paynejd Nov 24, 2026
d79d353
OpenConceptLab/ocl_online#424 | A read-only project's proposal fields…
paynejd Nov 24, 2026
93b5af7
OpenConceptLab/ocl_online#424 | Configure shows a read-only project's…
paynejd Nov 24, 2026
2f35ea8
OpenConceptLab/ocl_online#424 | A project turning read-only closes th…
paynejd Nov 24, 2026
0a51311
OpenConceptLab/ocl_online#424 | Configure's and Propose's locked fiel…
paynejd Nov 24, 2026
880d9d3
OpenConceptLab/ocl_online#424 | An algorithm picked as the project tu…
paynejd Nov 24, 2026
a29ee6f
OpenConceptLab/ocl_online#424 | Opening Configure leaves a read-only …
paynejd Nov 24, 2026
261cd8e
OpenConceptLab/ocl_online#424 | The prompt to discard a read-only pro…
paynejd Nov 24, 2026
fe2fe2d
OpenConceptLab/ocl_online#424 | A field mapping's likely source is pi…
paynejd Nov 24, 2026
30141f4
OpenConceptLab/ocl_online#424 | Revert picking a field mapping's like…
paynejd Nov 24, 2026
b2b20a3
OpenConceptLab/ocl_online#424 | Locked field groups keep their state …
paynejd Nov 24, 2026
877a05b
OpenConceptLab/ocl_online#424 | The lock tooltip skips the buttons in…
paynejd Nov 24, 2026
7237e61
OpenConceptLab/ocl_online#424 | A bridge algorithm's looked-up canoni…
paynejd Nov 24, 2026
bbded91
OpenConceptLab/ocl_online#424 | Revert the controlled field-group too…
paynejd Nov 24, 2026
db8d085
OpenConceptLab/ocl_online#424 | Without a lock, a field group's toolt…
paynejd Nov 25, 2026
6cf4cc4
OpenConceptLab/ocl_online#702 | Simplify S1-S4: no inline notice vari…
paynejd Nov 25, 2026
04ba704
OpenConceptLab/ocl_online#702 | Merge main: proposal edits autosave a…
paynejd Nov 25, 2026
095a2d8
OpenConceptLab/ocl_online#702 | A bridge lookup that settles after Co…
paynejd Nov 25, 2026
7c67c2c
OpenConceptLab/ocl_online#702 | A mounted selector applies a bridge l…
paynejd Nov 25, 2026
6116c22
OpenConceptLab/ocl_online#702 | A locked project asks again when the …
paynejd Nov 26, 2026
7a8f808
OpenConceptLab/ocl_online#702 | A save that leaves a newer lock in pl…
paynejd Nov 26, 2026
4324845
OpenConceptLab/ocl_online#702 | Refusals and lookups are ordered by o…
paynejd Nov 26, 2026
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
4 changes: 2 additions & 2 deletions src/components/common/LimitDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import useLimitAction from './useLimitAction'
// The frame every limit dialog shares: what was refused, then any next step
// the connected service sends (OpenConceptLab/ocl_online#367), which opens
// in a new tab.
const LimitDialog = ({open, onClose, errorCode, capability, title, children}) => {
const LimitDialog = ({open, onClose, errorCode, capability, owner, title, children}) => {
const { t } = useTranslation()
const { action, onActionClick } = useLimitAction(open, errorCode, capability)
const { action, onActionClick } = useLimitAction(open, errorCode, capability, owner)

return (
<Dialog open={open} onClose={onClose} maxWidth='sm' fullWidth>
Expand Down
280 changes: 280 additions & 0 deletions src/components/common/LimitNotice.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import Box from '@mui/material/Box'
import Button from '@mui/material/Button'
import DialogActions from '@mui/material/DialogActions'
import DialogContent from '@mui/material/DialogContent'
import IconButton from '@mui/material/IconButton'
import LinearProgress from '@mui/material/LinearProgress'
import Link from '@mui/material/Link'
import Typography from '@mui/material/Typography'
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutlined'
import CloseIcon from '@mui/icons-material/Close'
import CorporateFareIcon from '@mui/icons-material/CorporateFare'
import DoNotDisturbOnOutlinedIcon from '@mui/icons-material/DoNotDisturbOnOutlined'
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutlined'
import EventRepeatIcon from '@mui/icons-material/EventRepeat'
import GroupOutlinedIcon from '@mui/icons-material/GroupOutlined'
import HelpOutlineIcon from '@mui/icons-material/HelpOutlined'
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'
import LockOutlinedIcon from '@mui/icons-material/LockOutlined'
import OpenInNewIcon from '@mui/icons-material/OpenInNew'
import PersonOutlineIcon from '@mui/icons-material/PersonOutlined'
import WarningAmberIcon from '@mui/icons-material/WarningAmber'

import GAService from '../../services/GAService'
import Dialog from './Dialog'
import DialogTitle from './DialogTitle'
import CloseIconButton from './CloseIconButton'
import { getLimitSubject } from './limitAction'
import { getNoticeIcon, getNoticeTone, orderActions } from './limitNotice.js'

// The one slot for a limit notice (OpenConceptLab/ocl_online#702): a dialog or
// a strip, as in TBv3. It takes a notice from
// normalizeNotice and renders each field it has, in the colour its tone names.
// Without a notice it shows the API's `detail` and nothing else.
//
// Not yet in the OCL design system (it has no strip or inline alert besides the
// announcement banner): built from its foundations, the 28px dialog, pill
// buttons and LinearProgress.

const TONES = {
info: {main: 'primary.main', bg: 'primary.95', border: 'primary.80', track: 'primary.90'},
warning: {main: 'warning.main', bg: '#fff4e5', border: '#f6c28b', track: '#fde3c8'},
error: {main: 'error.main', bg: 'error.95', border: '#f2b8b5', track: '#ffdad6'},
}
const toneOf = tone => TONES[tone] || TONES.info

const ICONS = {lock: LockOutlinedIcon, info: InfoOutlinedIcon, warning: WarningAmberIcon, error: ErrorOutlineIcon}
const NoticeIcon = ({notice, ...rest}) => {
const Icon = ICONS[getNoticeIcon(notice)] || InfoOutlinedIcon
return <Icon {...rest} />
}

const Bar = ({meter, tone, height = 8, sx}) => {
if(typeof meter?.fraction !== 'number')
return null
const colours = toneOf(meter.tone || tone)
return (
<LinearProgress
variant='determinate'
value={meter.fraction * 100}
aria-label={meter.label}
sx={{height, borderRadius: height / 2, backgroundColor: colours.track, '& .MuiLinearProgress-bar': {backgroundColor: colours.main, borderRadius: height / 2}, ...sx}}
/>
)
}

const BUTTON_VARIANTS = {primary: 'contained', secondary: 'outlined', text: 'text'}

// Every link opens in a new tab, so the project stays as it is; the way out
// says so.
const ActionButton = ({action, size, onClick}) => {
const variant = BUTTON_VARIANTS[action.kind]
const contained = variant === 'contained'
return (
<Button
href={action.url}
target='_blank'
rel='noopener noreferrer'
variant={variant}
size={size}
onClick={() => onClick?.(action)}
endIcon={contained ? <OpenInNewIcon /> : undefined}
sx={{
textTransform: 'none',
borderRadius: '100px',
flexShrink: 0,
...(variant === 'outlined' ? {backgroundColor: 'rgba(255,255,255,.6)'} : {}),
'&, &:hover, &:focus, &:active': {color: contained ? 'primary.contrastText' : 'primary.main', textDecoration: 'none'},
'&:focus:not(:focus-visible)': {outline: 'none'},
}}
>
{action.label}
</Button>
)
}

const HelpLink = ({help, sx}) => (
<Link href={help.url} target='_blank' rel='noopener noreferrer' underline='hover' sx={{display: 'inline-flex', alignItems: 'center', gap: 0.5, fontSize: '13.5px', fontWeight: 500, '&:hover, &:focus': {color: 'primary.main'}, ...sx}}>
<HelpOutlineIcon sx={{fontSize: '17px'}} />
{help.label}
</Link>
)

const Scope = ({notice, sx}) => {
if(!notice.scope)
return null
const Icon = notice.scope_type === 'organization' ? CorporateFareIcon : PersonOutlineIcon
return (
<Box sx={{display: 'flex', alignItems: 'center', gap: 0.75, fontSize: '13px', color: 'secondary.main', ...sx}}>
<Icon sx={{fontSize: '17px'}} />
<span>{notice.scope}</span>
</Box>
)
}

const Reset = ({notice}) => notice.reset ? (
<Box sx={{display: 'flex', alignItems: 'flex-start', gap: 0.75, fontSize: '13px', color: 'surface.contrastText'}}>
<EventRepeatIcon sx={{fontSize: '17px', color: 'secondary.main', mt: '1px'}} />
<span>{notice.reset}</span>
</Box>
) : null

const Meter = ({notice}) => notice.meter ? (
<Box sx={{display: 'flex', flexDirection: 'column', gap: 1}}>
{
notice.meter.label &&
<Typography component='div' sx={{fontSize: '15px', fontWeight: 500, color: 'surface.dark', fontVariantNumeric: 'tabular-nums'}}>
{notice.meter.label}
</Typography>
}
<Bar meter={notice.meter} tone={getNoticeTone(notice)} />
</Box>
) : null

// Restricted, still works and who manages it, each with its icon.
const Rows = ({notice}) => {
const { t } = useTranslation()
const colours = toneOf(getNoticeTone(notice))
const rows = [
notice.restricted && {key: 'restricted', Icon: notice.kind === 'read_only' ? LockOutlinedIcon : DoNotDisturbOnOutlinedIcon, colour: colours.main, label: t('limit_notice.restricted'), text: notice.restricted},
notice.still_works && {key: 'still_works', Icon: CheckCircleOutlineIcon, colour: '#2e7d32', label: t('limit_notice.still_works'), text: notice.still_works},
notice.managed_by && {key: 'managed_by', Icon: GroupOutlinedIcon, colour: 'secondary.main', text: notice.managed_by},
].filter(Boolean)
return rows.map(({key, Icon, colour, label, text}) => (
<Box key={key} sx={{display: 'flex', gap: 1.25, alignItems: 'flex-start'}}>
<Icon sx={{fontSize: '20px', mt: '1px', color: colour}} />
<div>
{label && <Typography component='span' sx={{display: 'block', fontSize: '12px', fontWeight: 700, color: 'secondary.main', mb: '1px'}}>{label}</Typography>}
{text}
</div>
</Box>
))
}

// Records the notice once it shows, and each action followed, as the limit
// dialogs do (useLimitAction).
const useNoticeEvents = (open, errorCode, capability) => {
const subject = getLimitSubject(errorCode, capability)
React.useEffect(() => {
if(open)
GAService.recordActionEvent('Limit', 'limit_hit', errorCode, subject)
}, [open, errorCode, capability])
return action => GAService.recordActionEvent('Limit', 'limit_action_click', errorCode, {...subject, action_kind: action.kind})
}

const NoticeDialog = ({open, onClose, notice, errorCode, capability}) => {
const { t } = useTranslation()
const onActionClick = useNoticeEvents(open, errorCode, capability)
const actions = orderActions(notice.actions, 'dialog')
return (
<Dialog open={open} onClose={onClose} maxWidth='sm' fullWidth>
<DialogTitle sx={{display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 1.5}}>
{notice.title}
<CloseIconButton onClick={onClose} aria-label={t('common.close')} sx={{mt: -0.5, mr: -1, ml: 'auto'}} />
</DialogTitle>
<DialogContent sx={{px: 0, pb: 0}}>
<Scope notice={notice} sx={{mt: 1}} />
{
(notice.meter || notice.reset) &&
<Box sx={{mt: 2, backgroundColor: 'white', borderRadius: '16px', px: 2, py: 1.75, display: 'flex', flexDirection: 'column', gap: 1}}>
<Meter notice={notice} />
<Reset notice={notice} />
</Box>
}
<Box sx={{mt: 2, display: 'flex', flexDirection: 'column', gap: 1.5, fontSize: '14.5px', lineHeight: 1.5, color: 'surface.contrastText'}}>
<Rows notice={notice} />
</Box>
</DialogContent>
<DialogActions disableSpacing sx={{p: 0, pt: 3, gap: 1, flexWrap: 'wrap', justifyContent: 'flex-end', flexDirection: {xs: 'column-reverse', sm: 'row'}, alignItems: {xs: 'stretch', sm: 'center'}}}>
{notice.help && <HelpLink help={notice.help} sx={{mr: {sm: 'auto'}, alignSelf: {xs: 'center', sm: 'auto'}, mt: {xs: 1, sm: 0}}} />}
{
actions.length ?
actions.map((action, i) => <ActionButton key={i} action={action} onClick={onActionClick} />) :
<Button onClick={onClose} sx={{textTransform: 'none'}}>{t('common.close')}</Button>
}
</DialogActions>
</Dialog>
)
}

// No notice: a neutral title, the API's detail and Close, and nothing asked of
// a connected service.
const FallbackDialog = ({open, onClose, detail, errorCode, capability}) => {
const { t } = useTranslation()
useNoticeEvents(open, errorCode, capability)
return (
<Dialog open={open} onClose={onClose} maxWidth='sm' fullWidth>
<DialogTitle sx={{display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 1.5}}>
{t('limit_notice.fallback_title')}
<CloseIconButton onClick={onClose} aria-label={t('common.close')} sx={{mt: -0.5, mr: -1, ml: 'auto'}} />
</DialogTitle>
<DialogContent sx={{px: 0, pb: 0}}>
<Typography variant='body1' sx={{my: 2}}>{detail || t('unknown_error')}</Typography>
</DialogContent>
<DialogActions disableSpacing sx={{p: 0, pt: 3, justifyContent: 'flex-end'}}>
<Button onClick={onClose} sx={{textTransform: 'none'}}>{t('common.close')}</Button>
</DialogActions>
</Dialog>
)
}

const Strip = ({notice, detail, onDismiss, sx}) => {
const { t } = useTranslation()
const colours = toneOf(getNoticeTone(notice))
const frame = {display: 'flex', gap: 1.5, alignItems: 'flex-start', backgroundColor: colours.bg, borderBottom: '1px solid', borderColor: colours.border, px: 2, py: 1, ...sx}
if(!notice)
return detail ? (
<Box role='status' sx={{...frame, alignItems: 'center', py: 0.75}}>
<InfoOutlinedIcon sx={{color: colours.main, fontSize: '21px'}} />
<Typography sx={{fontSize: '13.5px', color: 'surface.contrastText'}}>{detail}</Typography>
</Box>
) : null
const text = [notice.restricted, notice.still_works, notice.managed_by].filter(Boolean).join(' ')
const actions = orderActions(notice.actions, 'strip')
return (
<Box role='status' sx={frame}>
<NoticeIcon notice={notice} sx={{color: colours.main, fontSize: '21px', mt: '1px'}} />
<Box sx={{flex: '1 1 auto', minWidth: 0, display: 'flex', flexDirection: 'column', gap: '3px'}}>
<Box sx={{display: 'flex', alignItems: 'center', columnGap: 1.5, rowGap: 0.75, flexWrap: 'wrap'}}>
{notice.title && <Typography component='span' sx={{fontWeight: 600, fontSize: '14px', color: 'surface.dark'}}>{notice.title}</Typography>}
{notice.scope && <Typography component='span' sx={{fontSize: '12.5px', color: 'secondary.main'}}>{notice.scope}</Typography>}
{
notice.meter &&
<Box component='span' sx={{display: 'inline-flex', alignItems: 'center', gap: 1}}>
<Bar meter={notice.meter} tone={getNoticeTone(notice)} height={6} sx={{width: 120}} />
{notice.meter.label && <Typography component='span' sx={{fontSize: '12.5px', fontWeight: 500, color: 'surface.dark'}}>{notice.meter.label}</Typography>}
</Box>
}
{notice.reset && <Typography component='span' sx={{fontSize: '12.5px', color: 'surface.contrastText'}}>{notice.reset}</Typography>}
</Box>
{text && <Typography sx={{fontSize: '13.5px', lineHeight: 1.45, color: 'surface.contrastText'}}>{text}</Typography>}
{
(actions.length > 0 || notice.help) &&
<Box sx={{display: 'flex', alignItems: 'center', gap: 0.75, flexWrap: 'wrap', mt: '3px'}}>
{actions.map((action, i) => <ActionButton key={i} action={action} size='small' />)}
{notice.help && <HelpLink help={notice.help} sx={{ml: 0.5}} />}
</Box>
}
</Box>
{
notice.dismissible && onDismiss &&
<IconButton size='small' aria-label={t('common.close')} onClick={onDismiss} sx={{mt: -0.5, mr: -1}}>
<CloseIcon fontSize='small' />
</IconButton>
}
</Box>
)
}

// size: 'dialog' (with open and onClose) or 'strip'.
const LimitNotice = ({size = 'dialog', notice, detail, open, onClose, onDismiss, errorCode, capability, sx}) => {
if(size === 'strip')
return <Strip notice={notice} detail={detail} onDismiss={onDismiss} sx={sx} />
if(notice)
return <NoticeDialog open={Boolean(open)} onClose={onClose} notice={notice} errorCode={errorCode} capability={capability} />
return <FallbackDialog open={Boolean(open)} onClose={onClose} detail={detail} errorCode={errorCode} capability={capability} />
}

export default LimitNotice
45 changes: 45 additions & 0 deletions src/components/common/NoticeLock.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react'
import Box from '@mui/material/Box'
import Tooltip from '@mui/material/Tooltip'
import LockIcon from '@mui/icons-material/LockOutlined'

// Why the open map project's writes are locked: its read-only notice's tooltip,
// or null while nothing is locked (OpenConceptLab/ocl_online#424). Each control
// that writes the project reads it, as TBv3's NoticeLocks does for a
// repository's controls.
export const EditLockContext = React.createContext(null)

export const useEditLock = () => React.useContext(EditLockContext)

// A locked control is disabled and says why on hover. A disabled control emits
// no pointer events, so the tooltip goes on a wrapping span.
export const LockTooltip = ({ title, children, placement = 'bottom', display = 'inline-flex', style }) => title ?
<Tooltip title={title} placement={placement}>
<span style={{display, ...style}}>{children}</span>
</Tooltip> :
children

// A group of locked fields says why on hover anywhere over it. Its wrapper has
// no box and is there whether or not the project is locked, so the fields lay
// out as without it and keep their state as a lock lands or ends.
export const LockedFields = ({ children }) => {
const lock = useEditLock()
// Unlocked, the tooltip listens to nothing, so the fields behave as without it (MUI's touch
// handler would otherwise also run beside a field's own tooltip).
const off = !lock
return (
<Tooltip title={lock || ''} followCursor disableHoverListener={off} disableFocusListener={off} disableTouchListener={off}>
<span style={{display: 'contents'}}>{children}</span>
</Tooltip>
)
}

export const LockMark = ({ sx }) => <LockIcon fontSize='inherit' sx={{color: 'secondary.main', ...sx}} />

// An icon button's own icon, with the lock on its corner.
export const LockedIcon = ({ icon }) => (
<Box component='span' sx={{position: 'relative', display: 'inline-flex'}}>
{icon}
<LockIcon sx={{position: 'absolute', right: -5, bottom: -4, fontSize: '13px', color: 'secondary.main', backgroundColor: 'white', borderRadius: '50%'}} />
</Box>
)
4 changes: 2 additions & 2 deletions src/components/common/QuotaDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useTranslation } from 'react-i18next'
import LimitDialog from './LimitDialog'
import { isCapMeter } from './quotaErrors'

const QuotaDialog = ({open, onClose, errorCode, capability, meter, surface}) => {
const QuotaDialog = ({open, onClose, errorCode, capability, owner, meter, surface}) => {
const { t } = useTranslation()

return (
<LimitDialog open={open} onClose={onClose} errorCode={errorCode} capability={capability} title={t(isCapMeter(meter) ? 'quota.title_cap' : 'quota.title_quota')}>
<LimitDialog open={open} onClose={onClose} errorCode={errorCode} capability={capability} owner={owner} title={t(isCapMeter(meter) ? 'quota.title_cap' : 'quota.title_quota')}>
{t([`quota.consequence.${meter}.${surface}`, `quota.consequence.${meter}.default`, 'quota.consequence.generic'])}
</LimitDialog>
)
Expand Down
20 changes: 19 additions & 1 deletion src/components/common/__tests__/limitAction.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'node:test'
import assert from 'node:assert/strict'

const { getLimitActionRequest, getLimitSubject, toLimitAction } = await import('../limitAction.js')
const { getLimitActionRequest, getLimitSubject, getRefusalOwner, toLimitAction } = await import('../limitAction.js')
const { PREVIEW_LIMIT_ERROR_CODES } = await import('../../map-projects/previewLimits.js')

const ACTION = {kind: 'example', url: 'https://online.example.org/next', label: 'Next step', message: 'A message from the service.'}
Expand Down Expand Up @@ -68,3 +68,21 @@ test('no action, or one that is not a usable link, shows nothing', () => {
assert.equal(toLimitAction({action: {...ACTION, url: 'data:text/html,hi'}}), null)
assert.equal(toLimitAction({action: {...ACTION, url: 42}}), null)
})

// OpenConceptLab/ocl_online#701
test('the next step is asked for whose limit it was, when the refusal says', () => {
assert.deepEqual(
getLimitActionRequest({baseURL: 'https://online.example.org', token: 'personal-token', errorCode: 'example_limit_reached', capability: 'example.capability', owner: '/orgs/Example/', lang: 'en'}).params,
{context: 'limit', capability: 'example.capability', owner: '/orgs/Example/', lang: 'en'}
)
assert.equal('owner' in getLimitActionRequest({baseURL: 'https://online.example.org', token: 'personal-token', errorCode: 'mapper_access_denied', owner: null, lang: 'en'}).params, false)
})

test('a refusal\'s owner is a user\'s or an organization\'s relative URL', () => {
assert.equal(getRefusalOwner({quota: {owner: '/users/someone/'}}), '/users/someone/')
assert.equal(getRefusalOwner({quota: {owner: '/orgs/Example/'}}), '/orgs/Example/')
for(const owner of [undefined, null, '', 'someone', '/users/someone', '/sources/x/', 'https://example.org/orgs/Example/', '/orgs/Example/sources/', 7])
assert.equal(getRefusalOwner({quota: {owner}}), null, String(owner))
assert.equal(getRefusalOwner({}), null)
assert.equal(getRefusalOwner(null), null)
})
Loading
Loading