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

files: add permissions #555

Merged
merged 1 commit into from
Aug 22, 2023
Merged

Conversation

jma
Copy link
Contributor

@jma jma commented Jun 21, 2023

  • Fixes broken ng command such as ng c.
  • Adds permissions support to the file component to hide action buttons.

Co-Authored-by: Johnny Mariéthoz Johnny.Mariethoz@rero.ch

Why are you opening this PR?

  • Which task/US does it implement?
  • Which issue does it fix?

How to test?

  • What command should I have to run to test your PR?
  • What should I test through the UI?

Code review check list

  • Commit message template compliance.
  • Commit message without typos.
  • File names.
  • Functions names.
  • Functions docstrings.
  • Unnecessary commited files?
  • Extracted translations?

@jma jma force-pushed the maj-add-file-permissions branch 2 times, most recently from b297e93 to f8fc738 Compare June 21, 2023 07:52
@jma jma marked this pull request as ready for review June 21, 2023 09:03
@jma jma requested review from Garfield-fr and zannkukai June 21, 2023 09:04
<div class="card-footer text-center">
<button class="btn btn-sm btn-primary" (click)="manageFile(null)">
<div *ngIf=canAdd.can class="card-footer text-center">
<button class="btn btn-sm btn-primary" *ngIf=canAdd (click)="manageFile(null)">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have *ngIf=canAdd because there's already a div definition on the previous line?

@@ -484,9 +474,12 @@ export class RecordFilesComponent implements OnDestroy, OnInit {
return this._fileService.list(this.type, this.pid);
}),
tap((files) => {
console.log('tap1');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Copy link
Contributor

@zannkukai zannkukai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of my comments are suggestions.

I'm confused about the huge usage of Bootstrap classes into ng-core component : It doesn't allow child projects to override them.
Instead of <div class="ml-2 py-2 font-weight-bold text-primary border-bottom"> we should use <div class="myComponentSpecialClass"> and apply default style on this class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could delete this file

@@ -0,0 +1,64 @@
<<ng-container *ngIf="file">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra < character

@@ -0,0 +1,64 @@
<<ng-container *ngIf="file">
<div class="row">
<div class="col-sm-6" [ngClass]="{ 'pl-5 text-muted': !file.is_head }">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be simply col-6 or maybe better, simply col (because each row seems contain 2 same-sized columns)

</div>
</div>
<div class="row mt-2" *ngIf="file.showInfo">
<div class="col-lg-6" *ngIf="file.is_head">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same than previous comment.

Try to be consitent between "sm", "md" and "lg" usage. Here you have a parent div with "lg" but some children with "sm"

Comment on lines 39 to 63
<dl class="row mt-2 mb-0">
<ng-container *ngFor="let item of file.metadata | keyvalue">
<ng-container *ngIf="!infoExcludedFields.includes(item.key) && item.value">
<dt class="col-sm-4">{{ item.key | translate }}</dt>
<dd class="col-sm-8">{{ item.value | translate }}</dd>
</ng-container>
</ng-container>
</dl>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to specify the size of last column of the row in this case. You could write

<dl class="row">
   <dt class="col-sm-6 col-md-4">key</dt>
   <dd class="col">value</dt>
</dl>

in such case, the width of the col will be adapted regarding free space on the row

Comment on lines 48 to 79
<div class="col-lg-6" [ngClass]="{ 'pl-5 text-muted': !file.is_head }">
<dl class="row mt-2 mb-0">
<dt class="col-sm-4" translate>Size</dt>
<dd class="col-sm-8">{{ file.size | filesize }}</dd>

<dt class="col-sm-4" translate>Mime type</dt>
<dd class="col-sm-8">{{ file.mimetype }}</dd>

<dt class="col-sm-4" translate>Checksum</dt>
<dd class="col-sm-8">{{ file.checksum }}</dd>

<dt class="col-sm-4" translate>Modified at</dt>
<dd class="col-sm-8">{{ file.updated | dateTranslate : 'medium' }}</dd>
</dl>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly the same + mix between "lg" and "sm"

Comment on lines 12 to 13
@Input()
record: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @Output are in single line, all @Input could be too

<i class="fa fa-plus mr-1"></i>{{ 'Add a new file' | translate }}
</button>
</div>
</div>

<ng-template #formModal>
<div class="modal-header">
<h4 class="modal-title pull-left">{{ currentFile ? currentFile.key : 'Add a new file' | translate }}</h4>
<h4 class="modal-title pull-left">{{ currentFile ? currentFile.key : ('Add a new file' | translate) }}</h4>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow 👍 Hawk eye !!!

Comment on lines 510 to 512
canAdd$.subscribe((result: ActionStatus) => {
this.canAdd = result;
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single instruction, could removed {} --> canAdd$.subscribe((result: ActionStatus) => this.canAdd = result)

@jma jma force-pushed the maj-add-file-permissions branch from f8fc738 to 59bd9ad Compare July 4, 2023 14:38
@jma jma requested a review from zannkukai July 12, 2023 14:54
* Fixes broken `ng` command such as `ng c`.
* Adds permissions support to the file component to hide action buttons.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
@jma jma force-pushed the maj-add-file-permissions branch from 59bd9ad to 6651c91 Compare August 21, 2023 08:14
@PascalRepond PascalRepond merged commit c6e3bb3 into rero:staging Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants