1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 14:53:33 +00:00

WIP - send text details

This commit is contained in:
jaasen-livefront
2024-09-11 09:00:05 -07:00
parent 605269813e
commit 3a0ec5c41b
3 changed files with 43 additions and 69 deletions

View File

@@ -2225,6 +2225,9 @@
"sendTypeText": {
"message": "Text"
},
"sendTypeTextToShare": {
"message": "Text to share"
},
"sendTypeFile": {
"message": "File"
},
@@ -2236,6 +2239,9 @@
"message": "When accessing the Send, hide the text by default",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"hideTextByDefault": {
"message": "Hide text by default"
},
"limitSendViews": {
"message": "Limit views"
},
@@ -2326,6 +2332,10 @@
"message": "The Send will be permanently deleted on the specified date and time.",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"deletionDateDescV2": {
"message": "The Send will be permanently deleted on this date.",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"expirationDate": {
"message": "Expiration date"
},

View File

@@ -11,21 +11,15 @@
</bit-form-field>
<bit-form-field>
<bit-label>{{ "sendTypeText" | i18n }}</bit-label>
<bit-label>{{ "sendTypeTextToShare" | i18n }}</bit-label>
<textarea bitInput id="text" rows="6" formControlName="textToShare"></textarea>
<bit-hint>{{ "sendTextDesc" | i18n }}</bit-hint>
</bit-form-field>
<bit-form-control>
<input bitCheckbox type="checkbox" formControlName="hideTextByDefault" />
<bit-label>{{ "textHiddenByDefault" | i18n }}</bit-label>
<bit-label>{{ "hideTextByDefault" | i18n }}</bit-label>
</bit-form-control>
<bit-form-field *ngIf="config.mode === 'edit'">
<bit-label>{{ "sendLinkLabel" | i18n }}</bit-label>
<input bitInput type="text" readonly formControlName="sendLink" />
<button type="button" bitSuffix bitIconButton="bwi-clone"></button>
</bit-form-field>
<bit-form-field>
<bit-label>{{ "deletionDate" | i18n }}</bit-label>
<bit-select
@@ -39,17 +33,7 @@
[label]="o.name"
></bit-option>
</bit-select>
<ng-container *ngIf="sendTextDetailsForm.controls['selectedDeletionDatePreset'].value === 0">
<input
bitInput
id="deletionDateCustom"
type="datetime-local"
name="DeletionDate"
formControlName="defaultDeletionDateTime"
placeholder="MM/DD/YYYY HH:MM AM/PM"
/>
</ng-container>
<bit-hint>{{ "deletionDateDesc" | i18n }}</bit-hint>
<bit-hint>{{ "deletionDateDescV2" | i18n }}</bit-hint>
</bit-form-field>
</bit-card>
</bit-section>

View File

@@ -27,14 +27,13 @@ enum DatePreset {
TwoDays = 48,
ThreeDays = 72,
SevenDays = 168,
FourteenDays = 336,
ThirtyDays = 720,
Custom = 0,
Never = null,
}
interface DatePresetSelectOption {
name: string;
value: DatePreset;
value: DatePreset | string;
}
@Component({
@@ -67,19 +66,24 @@ export class SendTextDetailsComponent implements OnInit {
textToShare: [""],
hideTextByDefault: [false],
// sendLink: [null as string],
defaultDeletionDateTime: ["", Validators.required],
selectedDeletionDatePreset: [DatePreset.SevenDays, Validators.required],
});
deletionDatePresets: DatePresetSelectOption[] = [
get deletionDatePresets(): DatePresetSelectOption[] {
const defaultSelections = [
{ name: this.i18nService.t("oneHour"), value: DatePreset.OneHour },
{ name: this.i18nService.t("oneDay"), value: DatePreset.OneDay },
{ name: this.i18nService.t("days", "2"), value: DatePreset.TwoDays },
{ name: this.i18nService.t("days", "3"), value: DatePreset.ThreeDays },
{ name: this.i18nService.t("days", "7"), value: DatePreset.SevenDays },
{ name: this.i18nService.t("days", "14"), value: DatePreset.FourteenDays },
{ name: this.i18nService.t("days", "30"), value: DatePreset.ThirtyDays },
{ name: this.i18nService.t("custom"), value: DatePreset.Custom },
];
if (!this.originalSendView.deletionDate) {
return defaultSelections;
}
return [{ name: null, value: this.formattedDeletionDate }, ...defaultSelections];
}
constructor(
private sendFormContainer: SendFormContainer,
@@ -108,34 +112,12 @@ export class SendTextDetailsComponent implements OnInit {
name: this.originalSendView.name,
textToShare: this.originalSendView.text.text,
hideTextByDefault: this.originalSendView.text.hidden,
defaultDeletionDateTime: this.datePipe.transform(
new Date(this.originalSendView.deletionDate),
"yyyy-MM-ddTHH:mm",
),
selectedDeletionDatePreset:
this.config.mode === "edit" ? DatePreset.Custom : DatePreset.SevenDays,
selectedDeletionDatePreset: DatePreset.SevenDays,
});
}
this.sendTextDetailsForm.controls.selectedDeletionDatePreset.valueChanges
.pipe(takeUntilDestroyed())
.subscribe((datePreset) => {
datePreset === DatePreset.Custom
? this.sendTextDetailsForm.controls.defaultDeletionDateTime.enable()
: this.sendTextDetailsForm.controls.defaultDeletionDateTime.disable();
});
}
get formattedDeletionDate(): string {
switch (this.sendTextDetailsForm.controls.selectedDeletionDatePreset.value as DatePreset) {
case DatePreset.Never:
this.sendTextDetailsForm.controls.selectedDeletionDatePreset.patchValue(
DatePreset.SevenDays,
);
return this.formattedDeletionDate;
case DatePreset.Custom:
return this.sendTextDetailsForm.controls.defaultDeletionDateTime.value;
default: {
const now = new Date();
const milliseconds = now.setTime(
now.getTime() +
@@ -147,5 +129,3 @@ export class SendTextDetailsComponent implements OnInit {
return new Date(milliseconds).toString();
}
}
}
}