-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update database and add feature flag page under entities
- Loading branch information
Showing
14 changed files
with
360 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/webapp/app/entities/feature-flag/feature-flag-delete-dialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useEffect } from 'react'; | ||
import { connect } from 'app/shared/util/typed-inject'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { IRootStore } from 'app/stores'; | ||
|
||
export interface IFeatureFlagDeleteDialogProps extends StoreProps, RouteComponentProps<{ id: string }> {} | ||
|
||
export const FeatureFlagDeleteDialog = (props: IFeatureFlagDeleteDialogProps) => { | ||
useEffect(() => { | ||
props.getEntity(props.match.params.id); | ||
}, []); | ||
|
||
const featureFlagEntity = props.featureFlagEntity; | ||
const updateSuccess = props.updateSuccess; | ||
|
||
const handleClose = () => { | ||
props.history.push('/feature-flag' + props.location.search); | ||
}; | ||
|
||
useEffect(() => { | ||
if (updateSuccess) { | ||
handleClose(); | ||
} | ||
}, [updateSuccess]); | ||
|
||
const confirmDelete = () => { | ||
props.deleteEntity(featureFlagEntity.id); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen toggle={handleClose}> | ||
<ModalHeader toggle={handleClose} data-cy="featureFlagDeleteDialogHeading"> | ||
Confirm delete operation | ||
</ModalHeader> | ||
<ModalBody id="oncokbCurationApp.featureFlag.delete.question">Are you sure you want to delete this FeatureFlag?</ModalBody> | ||
<ModalFooter> | ||
<Button color="secondary" onClick={handleClose}> | ||
<FontAwesomeIcon icon="ban" /> | ||
Cancel | ||
</Button> | ||
<Button id="jhi-confirm-delete-featureFlag" data-cy="entityConfirmDeleteButton" color="danger" onClick={confirmDelete}> | ||
<FontAwesomeIcon icon="trash" /> | ||
Delete | ||
</Button> | ||
</ModalFooter> | ||
</Modal> | ||
); | ||
}; | ||
|
||
const mapStoreToProps = ({ featureFlagStore }: IRootStore) => ({ | ||
featureFlagEntity: featureFlagStore.entity, | ||
updateSuccess: featureFlagStore.updateSuccess, | ||
getEntity: featureFlagStore.getEntity, | ||
deleteEntity: featureFlagStore.deleteEntity, | ||
}); | ||
|
||
type StoreProps = ReturnType<typeof mapStoreToProps>; | ||
|
||
export default connect(mapStoreToProps)(FeatureFlagDeleteDialog); |
55 changes: 55 additions & 0 deletions
55
src/main/webapp/app/entities/feature-flag/feature-flag-detail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useEffect } from 'react'; | ||
import { connect } from 'app/shared/util/typed-inject'; | ||
import { Link, RouteComponentProps } from 'react-router-dom'; | ||
import { Button, Row, Col } from 'reactstrap'; | ||
import {} from 'react-jhipster'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { IRootStore } from 'app/stores'; | ||
|
||
export interface IFeatureFlagProps extends StoreProps, RouteComponentProps<{ id: string }> {} | ||
|
||
export const FeatureFlagDetail = (props: IFeatureFlagProps) => { | ||
useEffect(() => { | ||
props.getEntity(props.match.params.id); | ||
}, []); | ||
|
||
const featureFlagEntity = props.featureFlagEntity; | ||
|
||
return ( | ||
<Row> | ||
<Col md="8"> | ||
<h2 data-cy="featureFlagDetailsHeading">FeatureFlag</h2> | ||
<dl className="jh-entity-details"> | ||
<dt> | ||
<span id="id">ID</span> | ||
</dt> | ||
<dd>{featureFlagEntity.id}</dd> | ||
<dt> | ||
<span id="code">Name</span> | ||
</dt> | ||
<dd>{featureFlagEntity.name}</dd> | ||
<dt> | ||
<span id="color">Description</span> | ||
</dt> | ||
<dd>{featureFlagEntity.description}</dd> | ||
<dt> | ||
<span id="level">Enabled</span> | ||
</dt> | ||
<dd>{featureFlagEntity.enabled ? 'true' : 'false'}</dd> | ||
</dl> | ||
<Button tag={Link} to={`/feature-flag/${featureFlagEntity.id}/edit`} replace color="primary"> | ||
<FontAwesomeIcon icon="pencil-alt" /> <span className="d-none d-md-inline">Edit</span> | ||
</Button> | ||
</Col> | ||
</Row> | ||
); | ||
}; | ||
|
||
const mapStoreToProps = ({ featureFlagStore }: IRootStore) => ({ | ||
featureFlagEntity: featureFlagStore.entity, | ||
getEntity: featureFlagStore.getEntity, | ||
}); | ||
|
||
type StoreProps = ReturnType<typeof mapStoreToProps>; | ||
|
||
export default connect(mapStoreToProps)(FeatureFlagDetail); |
103 changes: 103 additions & 0 deletions
103
src/main/webapp/app/entities/feature-flag/feature-flag-update.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { connect } from 'app/shared/util/typed-inject'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
import { Row, Col } from 'reactstrap'; | ||
import { ValidatedField, ValidatedForm } from 'react-jhipster'; | ||
import { IRootStore } from 'app/stores'; | ||
import { SaveButton } from 'app/shared/button/SaveButton'; | ||
|
||
export interface IFeatureFlagUpdateProps extends StoreProps, RouteComponentProps<{ id: string }> {} | ||
|
||
export const FeatureFlagUpdate = (props: IFeatureFlagUpdateProps) => { | ||
const [isNew] = useState(!props.match.params || !props.match.params.id); | ||
|
||
const featureFlagEntity = props.featureFlagEntity; | ||
const loading = props.loading; | ||
const updating = props.updating; | ||
const updateSuccess = props.updateSuccess; | ||
|
||
const handleClose = () => { | ||
props.history.push('/feature-flag' + props.location.search); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isNew) { | ||
props.reset(); | ||
} else { | ||
props.getEntity(props.match.params.id); | ||
} | ||
|
||
props.getFeatureFlags({}); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (updateSuccess) { | ||
handleClose(); | ||
} | ||
}, [updateSuccess]); | ||
|
||
const saveEntity = values => { | ||
const entity = { | ||
...featureFlagEntity, | ||
...values, | ||
}; | ||
|
||
if (isNew) { | ||
props.createEntity(entity); | ||
} else { | ||
props.updateEntity(entity); | ||
} | ||
}; | ||
|
||
const defaultValues = () => | ||
isNew | ||
? {} | ||
: { | ||
...featureFlagEntity, | ||
enabled: featureFlagEntity.enabled ?? false, | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Row className="justify-content-center"> | ||
<Col md="8"> | ||
<h2 id="oncokbCurationApp.featureFlag.home.createOrEditLabel" data-cy="FeatureFlagCreateUpdateHeading"> | ||
Add or edit a FeatureFlag | ||
</h2> | ||
</Col> | ||
</Row> | ||
<Row className="justify-content-center"> | ||
<Col md="8"> | ||
{loading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<ValidatedForm defaultValues={defaultValues()} onSubmit={saveEntity}> | ||
{!isNew ? <ValidatedField name="id" required readOnly id="feature-flag-id" label="ID" validate={{ required: true }} /> : null} | ||
<ValidatedField label="Name" id="feature-flag-name" name="name" data-cy="name" type="text" /> | ||
<ValidatedField label="Description" id="feature-flag-description" name="description" data-cy="description" type="textarea" /> | ||
<ValidatedField label="Enabled" id="feature-flag-enabled" name="enabled" data-cy="enabled" check type="checkbox" /> | ||
<SaveButton disabled={updating} /> | ||
</ValidatedForm> | ||
)} | ||
</Col> | ||
</Row> | ||
</div> | ||
); | ||
}; | ||
|
||
const mapStoreToProps = (storeState: IRootStore) => ({ | ||
featureFlags: storeState.featureFlagStore.entities, | ||
featureFlagEntity: storeState.featureFlagStore.entity, | ||
loading: storeState.featureFlagStore.loading, | ||
updating: storeState.featureFlagStore.updating, | ||
updateSuccess: storeState.featureFlagStore.updateSuccess, | ||
getFeatureFlags: storeState.featureFlagStore.getEntities, | ||
getEntity: storeState.featureFlagStore.getEntity, | ||
updateEntity: storeState.featureFlagStore.updateEntity, | ||
createEntity: storeState.featureFlagStore.createEntity, | ||
reset: storeState.featureFlagStore.reset, | ||
}); | ||
|
||
type StoreProps = ReturnType<typeof mapStoreToProps>; | ||
|
||
export default connect(mapStoreToProps)(FeatureFlagUpdate); |
13 changes: 13 additions & 0 deletions
13
src/main/webapp/app/entities/feature-flag/feature-flag.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { IFeatureFlag } from 'app/shared/model/feature-flag.model'; | ||
import { IRootStore } from 'app/stores'; | ||
import CrudStore from 'app/shared/util/crud-store'; | ||
import { ENTITY_TYPE } from 'app/config/constants/constants'; | ||
import { getEntityResourcePath } from 'app/shared/util/RouteUtils'; | ||
|
||
export class FeatureFlagStore extends CrudStore<IFeatureFlag> { | ||
constructor(protected rootStore: IRootStore) { | ||
super(rootStore, getEntityResourcePath(ENTITY_TYPE.FEATURE_FLAG)); | ||
} | ||
} | ||
|
||
export default FeatureFlagStore; |
Oops, something went wrong.