Skip to content
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

Bugfix/458-edit-and-delete-button-always-shown #459

Merged
merged 12 commits into from
Apr 28, 2021
Merged
14 changes: 4 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Fixed

- Fixed issue where the edit- & delete project would always be shown - [#458](https://github.com/DigitalExcellence/dex-frontend/issues/458)

### Security


Expand All @@ -33,22 +35,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed
- Added icon for data sources - [#466](https://github.com/DigitalExcellence/dex-frontend/issues/466)


## Release v.1.1.0-beta - 18-03-2021

### Fixed

- Fixed list view animation bug which prevented like animation from playing - [#419](https://github.com/DigitalExcellence/dex-frontend/issues/419)
- Auto dismiss the login warning when liking project if you're not logged in - [#433](https://github.com/DigitalExcellence/dex-frontend/issues/433)
- Hide the active modal when you navigate to another page via browser navigation arrows - [#423](https://github.com/DigitalExcellence/dex-frontend/issues/423)

## Release v.1.1.0-beta - 18-03-2021

### Fixed

- Fixed list view animation bug which prevented like animation from playing - [#419](https://github.com/DigitalExcellence/dex-frontend/issues/419)
- Auto dismiss the login warning when liking project if you're not logged in - [#433](https://github.com/DigitalExcellence/dex-frontend/issues/433)
- Hide the active modal when you navigate to another page via browser navigation arrows - [#423](https://github.com/DigitalExcellence/dex-frontend/issues/423)
- Hide the active modal when you navigate to another page via browser navigation arrows
- [#423](https://github.com/DigitalExcellence/dex-frontend/issues/423)


## Release v.1.0.1-beta - 31-01-2021
Expand Down
23 changes: 13 additions & 10 deletions src/app/models/domain/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
* If not, see https://www.gnu.org/licenses/lgpl-3.0.txt
*/
export enum scopes {
ProjectRead = 'ProjectRead',
ProjectWrite = 'ProjectWrite',
UserRead = 'UserRead',
UserWrite = 'UserWrite',
HighlightRead = 'HighlightRead',
HighlightWrite = 'HighlightWrite',
RoleRead = 'RoleRead',
RoleWrite = 'RoleWrite',
EmbedRead = 'EmbedRead',
EmbedWrite = 'EmbedWrite',
ProjectRead = 'ProjectRead',
ProjectWrite = 'ProjectWrite',
UserRead = 'UserRead',
UserWrite = 'UserWrite',
HighlightRead = 'HighlightRead',
HighlightWrite = 'HighlightWrite',
RoleRead = 'RoleRead',
RoleWrite = 'RoleWrite',
EmbedRead = 'EmbedRead',
EmbedWrite = 'EmbedWrite',
AdminProjectWrite = 'AdminProjectWrite',
InstitutionProjectWrite = 'InstitutionProjectWrite'

}
34 changes: 8 additions & 26 deletions src/app/modules/project/details/details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DetailsComponent implements OnInit {

public displayEditButton = false;
public displayDeleteProjectButton = false;
public displayCallToActionButton = false;
public displayCallToActionButton = true;
public displayHighlightButton = false;
public displayEmbedButton = false;

Expand Down Expand Up @@ -129,11 +129,10 @@ export class DetailsComponent implements OnInit {
(result) => {
this.project = result;
const desc = (this.project.shortDescription) ? this.project.shortDescription : this.project.description;
this.determineDisplayEditProjectButton();
this.determineDisplayDeleteProjectButton();
this.determineDisplayCallToActionButton();
this.determineDisplayEditAndDeleteProjectButton();
this.determineDisplayEmbedButton();
this.determineDisplayHighlightButton();
this.determineDisplayCallToActionButton();

// Updates meta and title tags
this.seoService.updateDescription(desc);
Expand Down Expand Up @@ -313,34 +312,17 @@ export class DetailsComponent implements OnInit {
* Method to display the edit project button based on the current user and the project user.
* If the user either has the ProjectWrite scope or is the creator of the project
*/
private determineDisplayEditProjectButton(): void {
if (this.authService.currentBackendUserHasScope(scopes.ProjectWrite)) {
this.displayEditButton = true;
return;
}

private determineDisplayEditAndDeleteProjectButton(): void {
if (this.currentUser == null || this.project == null || this.project.user == null) {
this.displayEditButton = false;
this.displayDeleteProjectButton = false;
return;
}
this.displayEditButton = this.project.user.id === this.currentUser.id;
}

/**
* Method to display the delete project button based on the current user and the project user.
* If the user either has the ProjectWrite scope or is the creator of the project
*/
private determineDisplayDeleteProjectButton(): void {
if (this.authService.currentBackendUserHasScope(scopes.ProjectWrite)) {
if (this.project.user.id === this.currentUser.id ||
this.authService.currentBackendUserHasScope(scopes.AdminProjectWrite)) {
this.displayEditButton = true;
this.displayDeleteProjectButton = true;
return;
}

if (this.currentUser == null || this.project == null || this.project.user == null) {
this.displayDeleteProjectButton = false;
return;
}
this.displayDeleteProjectButton = this.project.user.id === this.currentUser.id;
}

/**
Expand Down