 # Internal & React Libraries
 {React, rclass, rtypes} = require('./app-framework')
 {Icon} = require('./r_misc')
+misc = require('smc-util/misc')
 
-alert_style =
+# alert style, and derived oom alert style. we want to make sure we do not change one of them accidentally...
+alert_style = Object.freeze(
     marginBottom : 0
     fontSize     : '13pt'
+)
+
+oom_alert_style = Object.freeze(Object.assign({}, alert_style, {fontSize : '11pt', padding : '5px'}))
+
 
 exports.DiskSpaceWarning = rclass ({name}) ->
     displayName : 'DiskSpaceWarning'

        if not project_status?
            return <span />
        oom_kills = project_status.get('oom_kills') ? 0
        oom_dismissed = @props.oom_dismissed ? 0

        if oom_kills <= oom_dismissed
            return <span />

        <Alert bsStyle='danger' style={alert_style}>
            <Icon name='exclamation-triangle' /> WARNING: So far there are #{oom_kills} OOM Kills in your project, because your processes are too memory intensive.{' '}
            You either have to kill some processes, close runnin Jupyter Notebooks via "Halt", or restart your project.{' '}
            Upgrading "Shared RAM" memory in <a onClick={=>@actions(project_id: @props.project_id).set_active_tab('settings')} style={cursor:'pointer'}>settings</a> could help.{' '}
            <a href={'https://github.com/sagemathinc/cocalc/wiki/My-Project-Is-Running-Out-of-Memory'} target={'_blank'} style={cursor:'pointer'}>More information...</a>.
            <Button onClick={=>@click(oom_kills)}>Dismiss</Button>
        </Alert>

        </Alert>


# to test this, set the oom_kills value for your dev project directly in the DB:
# 1. reset:         UPDATE projects SET status = jsonb_set(status, '{oom_kills}', '0'::JSONB) WHERE project_id='  ... UUID of your cc-in-cc project ... ';
# 2. single event:  UPDATE projects SET status = jsonb_set(status, '{oom_kills}', '1'::JSONB) WHERE project_id='  ... UUID of your cc-in-cc project ... ';
# 3. several more:  UPDATE projects SET status = jsonb_set(status, '{oom_kills}', '5'::JSONB) WHERE project_id='  ... UUID of your cc-in-cc project ... ';
# 4. reset:         UPDATE projects SET status = jsonb_set(status, '{oom_kills}', '0'::JSONB) WHERE project_id='  ... UUID of your cc-in-cc project ... ';
exports.OOMWarning = rclass ({name}) ->
    displayName : 'OOMWarning'

