Skip to content

Commit f9ae6b3

Browse files
committed
fix(admin-ui): creator date and type added
1 parent e04e99c commit f9ae6b3

File tree

2 files changed

+61
-26
lines changed

2 files changed

+61
-26
lines changed

admin-ui/app/locales/en/translation.json

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@
171171
"scope_type": "Scope type",
172172
"umaAuthorizationPolicies": "Authorization Policies",
173173
"associatedClients": "Associated Clients",
174+
"creationDate": "Creation Time",
175+
"creatorType": "Creator",
174176
"iconUrl": "Icon URL",
175177
"scopes:": "Scopes",
176178
"scripts": "Scripts",

admin-ui/plugins/auth-server/components/Scopes/ScopeForm.js

+59-26
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,20 @@ import { SCOPE } from 'Utils/ApiResources'
3131
import { useTranslation } from 'react-i18next'
3232
import { ThemeContext } from 'Context/theme/themeContext'
3333
import { LIMIT, PATTERN } from 'Plugins/auth-server/common/Constants'
34-
34+
import moment from 'moment'
3535
function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
3636
const { t } = useTranslation()
3737
let dynamicScopeScripts = []
3838
let associatedClients = []
3939
let umaAuthorizationPolicies = []
40-
40+
let associatedClientsSelectedValues = []
4141
const theme = useContext(ThemeContext)
4242
const selectedTheme = theme.state.theme
4343
const history = useHistory()
44-
const spontaneousClientScopes = scope.attributes.spontaneousClientScopes || []
4544
const dispatch = useDispatch()
4645
const client = scope.clients || []
4746

48-
// const scripts = useSelector((state) => state.customScriptReducer.items)
47+
const authReducer = useSelector((state) => state.authReducer)
4948
let claims = []
5049
scripts = scripts || []
5150
attributes = attributes || []
@@ -59,7 +58,8 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
5958
.map((item) => ({ dn: item.dn, name: item.name }))
6059

6160
associatedClients = client.map((item) => ({ dn: item.dn, name: item.inum }))
62-
61+
associatedClientsSelectedValues = client.map((item) => item.dn)
62+
console.log(associatedClients, associatedClientsSelectedValues)
6363
claims = attributes.map((item) => ({ dn: item.dn, name: item.displayName }))
6464

6565
const [init, setInit] = useState(false)
@@ -162,6 +162,8 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
162162
onSubmit={(values) => {
163163
const result = Object.assign(scope, values)
164164
result['id'] = result.id
165+
result['creatorType'] = 'USER'
166+
result['creatorId'] = authReducer.userinfo.inum
165167
result['attributes'].showInConfigurationEndpoint =
166168
scope.attributes.showInConfigurationEndpoint
167169
result['attributes'].spontaneousClientId =
@@ -366,26 +368,54 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
366368
/>
367369
</Accordion.Body>
368370
</Accordion>
369-
<Accordion className="mb-2 b-primary" initialOpen>
370-
<Accordion.Header className="text-primary">
371-
{t('fields.associatedClients').toUpperCase()}
372-
</Accordion.Header>
373-
<Accordion.Body>
374-
<FormGroup row> </FormGroup>
375-
<GluuTypeAheadForDn
376-
name="associatedClients"
377-
label="fields.associatedClients"
378-
formik={formik}
379-
value={getMapping(
380-
scope.associatedClients,
381-
associatedClients,
382-
)}
383-
disabled={scope.inum ? true : false}
384-
options={associatedClients}
385-
doc_category={SCOPE}
386-
/>
387-
</Accordion.Body>
388-
</Accordion>
371+
{scope.inum && (
372+
<>
373+
<Accordion className="mb-2 b-primary" initialOpen>
374+
<Accordion.Header className="text-primary">
375+
{t('fields.associatedClients').toUpperCase()}
376+
</Accordion.Header>
377+
<Accordion.Body>
378+
<FormGroup row> </FormGroup>
379+
<GluuTypeAheadForDn
380+
name="associatedClients"
381+
label="fields.associatedClients"
382+
formik={formik}
383+
value={getMapping(
384+
associatedClientsSelectedValues,
385+
associatedClients,
386+
)}
387+
disabled={scope.inum ? true : false}
388+
options={associatedClients}
389+
doc_category={SCOPE}
390+
/>
391+
</Accordion.Body>
392+
</Accordion>
393+
<FormGroup row>
394+
<GluuLabel label="fields.creationDate" size={4} />
395+
<Col sm={8}>
396+
<Input
397+
defaultValue={moment(scope.creationDate).format(
398+
'YYYY-MM-DD HH:mm:ss',
399+
)}
400+
disabled={true}
401+
/>
402+
</Col>
403+
</FormGroup>
404+
<FormGroup row>
405+
<GluuLabel label="fields.creatorType" size={4} />
406+
<Col sm={8}>
407+
<Input
408+
defaultValue={
409+
['CLIENT', 'USER'].includes(scope.creatorType)
410+
? scope.creatorId || ''
411+
: scope.creatorType
412+
}
413+
disabled={true}
414+
/>
415+
</Col>
416+
</FormGroup>
417+
</>
418+
)}
389419
</>
390420
)}
391421
{showSpontaneousPanel && (
@@ -450,7 +480,10 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
450480
</Accordion>
451481
)}
452482
<FormGroup row></FormGroup>
453-
{!showSpontaneousPanel && !showUmaPanel && (
483+
{scope.inum ? (
484+
!showSpontaneousPanel &&
485+
!showUmaPanel && <GluuCommitFooter saveHandler={toggle} />
486+
) : (
454487
<GluuCommitFooter saveHandler={toggle} />
455488
)}
456489

0 commit comments

Comments
 (0)