Restrict work item list to admin only
This commit is contained in:
@@ -366,6 +366,10 @@ class API extends EventEmitter {
|
||||
return this.delete("/workitems/" + _id)
|
||||
}
|
||||
|
||||
listTeams() {
|
||||
return this.get("/teams")
|
||||
}
|
||||
|
||||
getActivity(_id) {
|
||||
return this.get("/activities/" + _id)
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ export class Activity extends React.Component {
|
||||
this.setState({
|
||||
binder: new FormBinder(
|
||||
{
|
||||
...this.state.binder.getOriginalFieldValues(),
|
||||
workItem: workItem._id,
|
||||
team: api.loggedInUser.team,
|
||||
},
|
||||
@@ -143,7 +144,7 @@ export class Activity extends React.Component {
|
||||
binder: new FormBinder(activity, Activity.bindings),
|
||||
})
|
||||
|
||||
getWorkItem(activity.workItemId)
|
||||
return getWorkItem(activity.workItem)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -31,6 +31,7 @@ import KeyboardSpacer from "react-native-keyboard-spacer"
|
||||
import hardhatPinImage from "./images/hardhat-pin.png"
|
||||
import clipboardPinImage from "./images/clipboard-pin.png"
|
||||
import questionPinImage from "./images/question-pin.png"
|
||||
import moment from "moment"
|
||||
|
||||
const neverAskForLocationPermissionKeyName = "NeverAskForLocationPermission"
|
||||
const neverAskForCameraKeyName = "NeverAskForCameraPermission"
|
||||
@@ -92,8 +93,19 @@ export class Home extends React.Component {
|
||||
)
|
||||
|
||||
api
|
||||
.listWorkItemActivities()
|
||||
.listTeams()
|
||||
.then((list) => {
|
||||
this.teams = list.items
|
||||
return api.listWorkItemActivities()
|
||||
})
|
||||
.then((list) => {
|
||||
list.items.forEach((item) => {
|
||||
item.data.forEach((datum) => {
|
||||
const team = this.teams.find((team) => team._id === datum.team)
|
||||
|
||||
datum.teamName = team ? team.name : "???"
|
||||
})
|
||||
})
|
||||
this.setState({
|
||||
sections: list.items,
|
||||
region:
|
||||
@@ -104,7 +116,13 @@ export class Home extends React.Component {
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
this.setState({
|
||||
messageModal: {
|
||||
icon: "hand",
|
||||
message: "Unable to get a list of work items, activities and teams",
|
||||
detail: err.message,
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -440,7 +458,9 @@ export class Home extends React.Component {
|
||||
{activity.resolution}
|
||||
</Text>
|
||||
<Text style={{ fontSize: 14, color: "gray" }}>
|
||||
{activity.when}
|
||||
{activity.teamName +
|
||||
" | " +
|
||||
dotify(moment(activity.createdAt).format())}
|
||||
</Text>
|
||||
</View>
|
||||
<Icon
|
||||
@@ -482,7 +502,11 @@ export class Home extends React.Component {
|
||||
<Icon
|
||||
name="settings"
|
||||
size={24}
|
||||
style={{ marginRight: 15, tintColor: "gray" }}
|
||||
style={{
|
||||
display: api.loggedInUser.administrator ? "flex" : "none",
|
||||
marginRight: 15,
|
||||
tintColor: "gray",
|
||||
}}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
@@ -107,6 +107,8 @@ export class WorkItemRoutes {
|
||||
"data._id": 1,
|
||||
"data.resolution": 1,
|
||||
"data.status": 1,
|
||||
"data.createdAt": 1,
|
||||
"data.team": 1,
|
||||
})
|
||||
|
||||
const items = await aggregate.exec()
|
||||
|
||||
Reference in New Issue
Block a user