Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
cathalnoonan committed Apr 29, 2020
0 parents commit 2bca01d
Show file tree
Hide file tree
Showing 30 changed files with 7,525 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2020 Cathal Noonan

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 changes: 14 additions & 0 deletions control/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# generated directory
**/generated

# output directory
/out

# msbuild output directories
/bin
/obj
65 changes: 65 additions & 0 deletions control/SecurityRoleManager/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest>
<control namespace="Cathal" constructor="SecurityRoleManager" display-name-key="SecurityRoleManager" description-key="SecurityRoleManager_description" control-type="standard" preview-image="preview.png"
version="1.0.0">

<property name="sampleProperty" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type-group="any" usage="bound" required="true" />

<type-group name="any">
<type>Currency</type>
<type>DateAndTime.DateAndTime</type>
<type>DateAndTime.DateOnly</type>
<type>Decimal</type>
<type>Enum</type>
<type>FP</type>
<type>Multiple</type>
<type>OptionSet</type>
<type>SingleLine.Email</type>
<type>SingleLine.Phone</type>
<type>SingleLine.Text</type>
<type>SingleLine.TextArea</type>
<type>SingleLine.Ticker</type>
<type>SingleLine.URL</type>
<type>TwoOptions</type>
<type>Whole.None</type>

<!--
<type>Whole.Duration</type>
<type>Whole.Timezone</type>
<type>Whole.Language</type>
<type>Lookup.Simple</type>
<type>Lookup.Customer</type>
<type>Lookup.Owner</type>
<type>Lookup.PartyList</type>
<type>Lookup.Regarding</type>
<type>MultiSelectOptionSet</type>
<type>Status</type>
<type>Status Reason</type>
-->

</type-group>

<resources>
<code path="index.ts" order="1"/>
<resx path="strings/SecurityRoleManager.1033.resx" version="1.0.0" />

<!-- UNCOMMENT TO ADD MORE RESOURCES
<css path="css/SecurityRoleManager.css" order="1" />
-->
</resources>

<!-- UNCOMMENT TO ENABLE THE SPECIFIED API -->
<feature-usage>
<!--
<uses-feature name="Device.captureAudio" required="true" />
<uses-feature name="Device.captureImage" required="true" />
<uses-feature name="Device.captureVideo" required="true" />
<uses-feature name="Device.getBarcodeValue" required="true" />
<uses-feature name="Device.getCurrentPosition" required="true" />
<uses-feature name="Device.pickFile" required="true" />
-->
<uses-feature name="Utility" required="true" />
<uses-feature name="WebAPI" required="true" />
</feature-usage>
</control>
</manifest>
151 changes: 151 additions & 0 deletions control/SecurityRoleManager/components/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import * as React from 'react';
import { Row } from './';
import { SecurityRoleService } from '../services';
import { SecurityRoleMap, getEntityReference } from '../utilities';
import { Spinner, SpinnerSize, ISpinner, ISpinnerProps } from 'office-ui-fabric-react/lib/Spinner';
import { Stack, IStackTokens } from 'office-ui-fabric-react/lib/Stack';
import { ScrollablePane } from 'office-ui-fabric-react/lib/ScrollablePane'

export interface IProps {
headerText: string;
loadingMessage: string;
saveRecordMessage: string;
unsupportedMessage: string;
disable: boolean;
}

interface IState {
loaded: boolean;
isSupportedEntity: boolean;
isCreated: boolean;
roleMap: SecurityRoleMap[];
processingCount: number;
}

export default class App extends React.Component<IProps, IState> {

private securityRoleService: SecurityRoleService;

constructor(props: IProps) {
super(props);
this.state = {
loaded: false,
isSupportedEntity: false,
isCreated: false,
roleMap: [],
processingCount: 0,
};
}

render() {
const { etn, id } = getEntityReference();
this.securityRoleService = new SecurityRoleService(window.location.origin + '/api/data/v9.1', etn, id);

const { loaded, isSupportedEntity, isCreated, roleMap } = this.state;
const { headerText, loadingMessage, unsupportedMessage, saveRecordMessage } = this.props;

const hrStyle: React.CSSProperties = {
backgroundColor: '#eee',
height: '1px',
margin: '5px 0px',
};

// Show spinner while loading
if (!loaded) return (
<div>
<div>{headerText}</div>
<hr style={hrStyle} />
<div>
<Spinner size={SpinnerSize.large} label={loadingMessage} />
</div>
</div>
);

// Show a message if the user puts the control on the wrong entity
else if (!isSupportedEntity) return (
<div>
<div>{headerText}</div>
<hr style={hrStyle} />
<div>
{unsupportedMessage}
</div>
</div>
);

// Show a message if the record needs to be created before roles can be associated
else if (!isCreated) return (
<div>
<div>{headerText}</div>
<hr style={hrStyle} />
<div>
{saveRecordMessage}
</div>
</div>
);

// Load the Security Roles in a list
else {
const stackTokens: IStackTokens = {
childrenGap: 10,
};

const spinnerProps: ISpinnerProps = {
size: SpinnerSize.medium,
};

const spinnerStyle: React.CSSProperties = {
display: this.state.processingCount === 0 ? 'none' : 'inline-block',
};

return (
<div>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<h4 style={{ flexGrow: 1, lineHeight: '1.5rem' }}>
{headerText}
</h4>
<Spinner {...spinnerProps} style={spinnerStyle} />
</div>

<hr style={hrStyle} />

<div style={{ height: '400px', position: 'relative' }}>
<ScrollablePane>
<Stack tokens={stackTokens}>
{roleMap.map(securityRoleMap =>
<Row
securityRoleService={this.securityRoleService}
onProcessStart={() => this.setState({ processingCount: this.state.processingCount + 1 })}
onProcessEnd={() => this.setState({ processingCount: this.state.processingCount - 1 })}
disable={this.props.disable}
key={securityRoleMap.id} securityRoleMap={securityRoleMap} />)}
</Stack>
</ScrollablePane>
</div>
</div>
);
}
}

componentDidMount() {
const { etn, id } = getEntityReference();
const isSupportedEntity = (etn === 'systemuser' || etn === 'team');
const isCreated = (!!id);

let roleMap: SecurityRoleMap[] = [];

const setStateForRefresh = () => this.setState({
loaded: true,
isSupportedEntity,
isCreated,
roleMap,
});

if (isSupportedEntity && isCreated) {
this.securityRoleService.getRoleMap()
.then(response => roleMap = response)
.finally(setStateForRefresh)
} else {
setStateForRefresh();
}
}
}
7 changes: 7 additions & 0 deletions control/SecurityRoleManager/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import App, { IProps as AppProps } from './app';
import Row, { IProps as RowProps } from './row';

export {
App, AppProps,
Row, RowProps,
}
Loading

0 comments on commit 2bca01d

Please sign in to comment.