Skip to content

Made a start on adding "New User" attributes in "User Settings" #2187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 0 deletions src/store/features/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const appSlice = createSlice({
setOffboardingDefaults: (state, action) => {
state.offboardingDefaults = action.payload?.offboardingDefaults
},
setNewUserDefaults: (state, action) => {
state.setNewUserDefaults = action.payload?.setNewUserDefaults
},
setUserSettings: (state, action) => {
//foreach key in the userSettings, set the state key to the value of that setting
Object.keys(action.payload?.userSettings).forEach((key) => {
Expand All @@ -67,6 +70,7 @@ export const {
setDefaultusageLocation,
setReportImage,
setOffboardingDefaults,
setNewUserDefaults,
setUserSettings,
} = appSlice.actions

Expand Down
122 changes: 121 additions & 1 deletion src/views/cipp/UserSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import {
import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'
import ReportImage from 'src/components/utilities/ReportImage'
import { useLoadClientPrincipalQuery } from 'src/store/api/auth'
import { setOffboardingDefaults } from 'src/store/features/app'
import { setOffboardingDefaults, setNewUserDefaults } from 'src/store/features/app'

const Offcanvas = (row, rowIndex, formatExtraData) => {
const [ExecuteGetRequest, getResults] = useLazyGenericGetRequestQuery()
Expand Down Expand Up @@ -122,13 +122,88 @@ const Offcanvas = (row, rowIndex, formatExtraData) => {
}

const UserSettings = () => {
const tenant = useSelector((state) => state.app.currentTenant)
const [addedAttributes, setAddedAttribute] = React.useState(0)
const [random3, setRandom3] = useState('')
const availableProperties = useGenericGetRequestQuery({
path: '/api/ListGraphRequest',
params: {
Endpoint: 'users',
ListProperties: true,
TenantFilter: tenant.defaultDomainName,
IgnoreErrors: true,
},
})
const exclusionList = [
'id',
'accountEnabled',
'deletedDateTime',
'ageGroup',
'businessPhones',
'city',
'createdDateTime',
'creationType',
'companyName',
'country',
'department',
'displayName',
'givenName',
'imAddresses',
'infoCatalogs',
'isLicenseReconciliationNeeded',
'isManagementRestricted',
'isResourceAccount',
'jobTitle',
'mail',
'mailNickname',
'mobilePhone',
'onPremisesDistinguishedName',
'onPremisesDomainName',
'onPremisesImmutableId',
'onPremisesLastSyncDateTime',
'onPremisesObjectIdentifier',
'onPremisesSecurityIdentifier',
'onPremisesSamAccountName',
'onPremisesSyncEnabled',
'onPremisesUserPrincipalName',
'passwordPolicies',
'postalCode',
'preferredDataLocation',
'preferredLanguage',
'proxyAddresses',
'refreshTokensValidFromDateTime',
'securityIdentifier',
'signInSessionsValidFromDateTime',
'streetAddress',
'surname',
'usageLocation',
'userPrincipalName',
'externalUserConvertedOn',
'externalUserState',
'externalUserStateChangeDateTime',
'userType',
'employeeOrgData',
'assignedLicenses',
'assignedPlans',
'authorizationInfo',
'cloudRealtimeCommunicationInfo',
'deviceKeys',
'identities',
'onPremisesExtensionAttributes',
'onPremisesProvisioningErrors',
'onPremisesSipInfo',
'passwordProfile',
'provisionedPlans',
'serviceProvisioningErrors',
]
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()
const { data: profile, isFetching, isLoading } = useLoadClientPrincipalQuery()
const dispatch = useDispatch()
const currentSettings = useSelector((state) => state.app)

const onSubmit = (values) => {
dispatch(setOffboardingDefaults({ offboardingDefaults: values }))
dispatch(setNewUserDefaults({ NewUserDefaults: values.name }))
const shippedvalues = {
user: values.user,
currentSettings: currentSettings,
Expand Down Expand Up @@ -201,6 +276,51 @@ const UserSettings = () => {
/>
</CCol>
</CRow>
<CRow className="mb-3">
<h3 className="underline mb-5">New User Attribute Defaults</h3>
<div className="mb-3">
<RFFSelectSearch
name="Attribute Name"
label="Select the attributes you want to use"
placeholder="Select the attributes you want to use"
retainInput={true}
multi={true}
values={
availableProperties?.data?.Results?.filter(
(prop) => !exclusionList.includes(prop),
)?.map((prop) => ({
name: prop,
value: prop,
})) ?? []
}
allowCreate={true}
refreshFunction={() =>
setRandom3((Math.random() + 1).toString(36).substring(7))
}
isLoading={availableProperties.isFetching}
/>
</div>
<CRow>
<CCol className="mb-3" md={12}>
{addedAttributes > 0 && (
<CButton
onClick={() => setAddedAttribute(addedAttributes - 1)}
className={`circular-button`}
title={'-'}
>
<FontAwesomeIcon icon={'minus'} />
</CButton>
)}
<CButton
onClick={() => setAddedAttribute(addedAttributes + 1)}
className={`circular-button`}
title={'+'}
>
<FontAwesomeIcon icon={'plus'} />
</CButton>
</CCol>
</CRow>
</CRow>
<CRow className="mb-3">
<CCol className="mb-3" md={6}>
<CButton
Expand Down