Skip to content

Commit

Permalink
[api/frontend] Fix peromissions in user context
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Hassine committed Nov 29, 2021
1 parent 45d6578 commit 8f827c3
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Button from '@material-ui/core/Button';
import Slide from '@material-ui/core/Slide';
import graphql from 'babel-plugin-relay/macro';
import { QueryRenderer } from '../../relay/environment';
import Security, { EXPLORE } from '../../utils/Security';
import inject18n from '../../components/i18n';

const Transition = React.forwardRef((props, ref) => (
Expand Down Expand Up @@ -89,63 +90,92 @@ class DashboardSettings extends Component {
>
<DialogTitle>{t('Dashboard settings')}</DialogTitle>
<DialogContent>
<QueryRenderer
query={dashboardSettingsDashboardsQuery}
variables={{
count: 50,
orderBy: 'name',
orderMode: 'asc',
filters: [{ key: 'type', values: ['dashboard'] }],
}}
render={({ props }) => {
if (props) {
return (
<div>
<FormControl style={{ width: '100%' }}>
<InputLabel id="timeField">
{t('Date reference')}
</InputLabel>
<Select
labelId="timeField"
value={timeField === null ? '' : timeField}
onChange={handleChangeTimeField.bind(this)}
fullWidth={true}
>
<MenuItem value="technical">
{t('Technical date')}
</MenuItem>
<MenuItem value="functional">
{t('Functional date')}
</MenuItem>
</Select>
</FormControl>
<FormControl style={{ width: '100%', marginTop: 20 }}>
<InputLabel id="timeField">
{t('Custom dashboard')}
</InputLabel>
<Select
labelId="dashboard"
value={dashboard === null ? '' : dashboard}
onChange={handleChangeDashboard.bind(this)}
fullWidth={true}
>
<MenuItem value="default">{t('Default')}</MenuItem>
{props.workspaces.edges.map((workspaceEdge) => {
const workspace = workspaceEdge.node;
return (
<MenuItem key={workspace.id} value={workspace.id}>
{workspace.name}
</MenuItem>
);
})}
</Select>
</FormControl>
</div>
);
}
return <div />;
}}
/>
<Security
needs={[EXPLORE]}
placeholder={
<div>
<FormControl style={{ width: '100%' }}>
<InputLabel id="timeField">
{t('Date reference')}
</InputLabel>
<Select
labelId="timeField"
value={timeField === null ? '' : timeField}
onChange={handleChangeTimeField.bind(this)}
fullWidth={true}
>
<MenuItem value="technical">
{t('Technical date')}
</MenuItem>
<MenuItem value="functional">
{t('Functional date')}
</MenuItem>
</Select>
</FormControl>
</div>
}
>
<QueryRenderer
query={dashboardSettingsDashboardsQuery}
variables={{
count: 50,
orderBy: 'name',
orderMode: 'asc',
filters: [{ key: 'type', values: ['dashboard'] }],
}}
render={({ props }) => {
if (props) {
return (
<div>
<FormControl style={{ width: '100%' }}>
<InputLabel id="timeField">
{t('Date reference')}
</InputLabel>
<Select
labelId="timeField"
value={timeField === null ? '' : timeField}
onChange={handleChangeTimeField.bind(this)}
fullWidth={true}
>
<MenuItem value="technical">
{t('Technical date')}
</MenuItem>
<MenuItem value="functional">
{t('Functional date')}
</MenuItem>
</Select>
</FormControl>
<FormControl style={{ width: '100%', marginTop: 20 }}>
<InputLabel id="timeField">
{t('Custom dashboard')}
</InputLabel>
<Select
labelId="dashboard"
value={dashboard === null ? '' : dashboard}
onChange={handleChangeDashboard.bind(this)}
fullWidth={true}
>
<MenuItem value="default">{t('Default')}</MenuItem>
{props.workspaces.edges.map((workspaceEdge) => {
const workspace = workspaceEdge.node;
return (
<MenuItem
key={workspace.id}
value={workspace.id}
>
{workspace.name}
</MenuItem>
);
})}
</Select>
</FormControl>
</div>
);
}
return <div />;
}}
/>
</Security>
</DialogContent>
<DialogActions>
<Button onClick={this.handleClose.bind(this)}>{t('Close')}</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ type AppInfo {
"""
The OpenCTI api current memory usage
"""
memory: AppMemory
memory: AppMemory @auth(for: [SETTINGS])
"""
The list of OpenCTI software dependencies
"""
dependencies: [DependencyVersion!]!
dependencies: [DependencyVersion!]! @auth(for: [SETTINGS])
"""
The objects statistics
"""
debugStats: AppDebugStatistics
debugStats: AppDebugStatistics @auth(for: [SETTINGS])
}

### STATS
Expand Down Expand Up @@ -8491,7 +8491,7 @@ type Query {
###### INTERNAL

platform_theme: String
about: AppInfo @auth(for: [SETTINGS])
about: AppInfo
logsWorkerConfig: LogsWorkerConfig @auth(for: [MODULES])
rabbitMQMetrics(prefix: String): RabbitMQMetrics @auth(for: [MODULES])
elasticSearchMetrics: ElasticSearchMetrics @auth(for: [MODULES])
Expand Down

0 comments on commit 8f827c3

Please sign in to comment.