mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Revert "[EC-73] edit collection modal (#3638)"
This reverts commit 39655ebe29.
This commit is contained in:
@@ -3,9 +3,10 @@ import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { ButtonLikeAbstraction } from "../shared/button-like.abstraction";
|
||||
|
||||
import { BitActionDirective } from "./bit-action.directive";
|
||||
import { BitSubmitDirective } from "./bit-submit.directive";
|
||||
|
||||
import { BitActionDirective } from ".";
|
||||
|
||||
/**
|
||||
* This directive has two purposes:
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, Input, OnChanges } from "@angular/core";
|
||||
|
||||
import { BadgeType } from "../badge";
|
||||
import { BadgeTypes } from "../badge";
|
||||
|
||||
@Component({
|
||||
selector: "bit-badge-list",
|
||||
@@ -12,7 +12,7 @@ export class BadgeListComponent implements OnChanges {
|
||||
protected filteredItems: string[] = [];
|
||||
protected isFiltered = false;
|
||||
|
||||
@Input() badgeType: BadgeType = "primary";
|
||||
@Input() badgeType: BadgeTypes = "primary";
|
||||
@Input() items: string[] = [];
|
||||
|
||||
@Input()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Directive, ElementRef, HostBinding, Input } from "@angular/core";
|
||||
|
||||
export type BadgeType = "primary" | "secondary" | "success" | "danger" | "warning" | "info";
|
||||
export type BadgeTypes = "primary" | "secondary" | "success" | "danger" | "warning" | "info";
|
||||
|
||||
const styles: Record<BadgeType, string[]> = {
|
||||
const styles: Record<BadgeTypes, string[]> = {
|
||||
primary: ["tw-bg-primary-500"],
|
||||
secondary: ["tw-bg-text-muted"],
|
||||
success: ["tw-bg-success-500"],
|
||||
@@ -11,7 +11,7 @@ const styles: Record<BadgeType, string[]> = {
|
||||
info: ["tw-bg-info-500"],
|
||||
};
|
||||
|
||||
const hoverStyles: Record<BadgeType, string[]> = {
|
||||
const hoverStyles: Record<BadgeTypes, string[]> = {
|
||||
primary: ["hover:tw-bg-primary-700"],
|
||||
secondary: ["hover:tw-bg-secondary-700"],
|
||||
success: ["hover:tw-bg-success-700"],
|
||||
@@ -47,7 +47,7 @@ export class BadgeDirective {
|
||||
.concat(this.hasHoverEffects ? hoverStyles[this.badgeType] : []);
|
||||
}
|
||||
|
||||
@Input() badgeType: BadgeType = "primary";
|
||||
@Input() badgeType: BadgeTypes = "primary";
|
||||
|
||||
private hasHoverEffects = false;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
||||
|
||||
import { BadgeDirective, BadgeType } from "./badge.directive";
|
||||
import { BadgeDirective } from "./badge.directive";
|
||||
|
||||
export default {
|
||||
title: "Component Library/Badge",
|
||||
@@ -15,12 +15,6 @@ export default {
|
||||
args: {
|
||||
badgeType: "primary",
|
||||
},
|
||||
argTypes: {
|
||||
badgeType: {
|
||||
options: ["primary", "secondary", "success", "danger", "warning", "info"] as BadgeType[],
|
||||
control: { type: "inline-radio" },
|
||||
},
|
||||
},
|
||||
parameters: {
|
||||
design: {
|
||||
type: "figma",
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { BadgeDirective, BadgeType } from "./badge.directive";
|
||||
export { BadgeDirective, BadgeTypes } from "./badge.directive";
|
||||
export * from "./badge.module";
|
||||
|
||||
@@ -4,7 +4,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
|
||||
import { I18nMockService } from "../utils/i18n-mock.service";
|
||||
|
||||
import { CalloutComponent } from "./callout.component";
|
||||
import { CalloutComponent } from ".";
|
||||
|
||||
describe("Callout", () => {
|
||||
let component: CalloutComponent;
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
import { FormsModule, ReactiveFormsModule, FormBuilder } from "@angular/forms";
|
||||
import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
|
||||
import { ButtonModule } from "../button";
|
||||
import { InputModule } from "../input/input.module";
|
||||
import { I18nMockService } from "../utils/i18n-mock.service";
|
||||
|
||||
import { forbiddenCharacters } from "./bit-validators/forbidden-characters.validator";
|
||||
import { BitFormFieldComponent } from "./form-field.component";
|
||||
import { FormFieldModule } from "./form-field.module";
|
||||
|
||||
export default {
|
||||
title: "Component Library/Form/Custom Validators",
|
||||
component: BitFormFieldComponent,
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
imports: [FormsModule, ReactiveFormsModule, FormFieldModule, InputModule, ButtonModule],
|
||||
providers: [
|
||||
{
|
||||
provide: I18nService,
|
||||
useFactory: () => {
|
||||
return new I18nMockService({
|
||||
inputForbiddenCharacters: (chars) =>
|
||||
`The following characters are not allowed: ${chars}`,
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
parameters: {
|
||||
design: {
|
||||
type: "figma",
|
||||
url: "https://www.figma.com/file/f32LSg3jaegICkMu7rPARm/Tailwind-Component-Library-Update?node-id=1881%3A17689",
|
||||
},
|
||||
},
|
||||
} as Meta;
|
||||
|
||||
const template = `
|
||||
<form [formGroup]="formObj">
|
||||
<bit-form-field>
|
||||
<bit-label>Name</bit-label>
|
||||
<input bitInput formControlName="name" />
|
||||
</bit-form-field>
|
||||
</form>`;
|
||||
|
||||
export const ForbiddenCharacters: Story<BitFormFieldComponent> = (args: BitFormFieldComponent) => ({
|
||||
props: {
|
||||
formObj: new FormBuilder().group({
|
||||
name: ["", forbiddenCharacters(["\\", "/", "@", "#", "$", "%", "^", "&", "*", "(", ")"])],
|
||||
}),
|
||||
},
|
||||
template,
|
||||
});
|
||||
@@ -1,45 +0,0 @@
|
||||
import { FormControl } from "@angular/forms";
|
||||
|
||||
import { forbiddenCharacters } from "./forbidden-characters.validator";
|
||||
|
||||
describe("forbiddenCharacters", () => {
|
||||
it("should return no error when input is null", () => {
|
||||
const input = createControl(null);
|
||||
const validate = forbiddenCharacters(["n", "u", "l", "l"]);
|
||||
|
||||
const errors = validate(input);
|
||||
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it("should return no error when no characters are forbidden", () => {
|
||||
const input = createControl("special characters: \\/@#$%^&*()");
|
||||
const validate = forbiddenCharacters([]);
|
||||
|
||||
const errors = validate(input);
|
||||
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it("should return no error when input does not contain forbidden characters", () => {
|
||||
const input = createControl("contains no special characters");
|
||||
const validate = forbiddenCharacters(["\\", "/", "@", "#", "$", "%", "^", "&", "*", "(", ")"]);
|
||||
|
||||
const errors = validate(input);
|
||||
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it("should return error when input contains forbidden characters", () => {
|
||||
const input = createControl("contains / illegal @ characters");
|
||||
const validate = forbiddenCharacters(["\\", "/", "@", "#", "$", "%", "^", "&", "*", "(", ")"]);
|
||||
|
||||
const errors = validate(input);
|
||||
|
||||
expect(errors).not.toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
function createControl(input: string) {
|
||||
return new FormControl(input);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { AbstractControl, FormControl, ValidationErrors, ValidatorFn } from "@angular/forms";
|
||||
|
||||
export function forbiddenCharacters(characters: string[]): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationErrors | null => {
|
||||
if (!(control instanceof FormControl)) {
|
||||
throw new Error("forbiddenCharacters only supports validating FormControls");
|
||||
}
|
||||
|
||||
if (control.value === null || control.value === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const value = String(control.value);
|
||||
|
||||
for (const char of value) {
|
||||
if (characters.includes(char)) {
|
||||
return { forbiddenCharacters: { value: control.value, characters } };
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export { forbiddenCharacters } from "./forbidden-characters.validator";
|
||||
@@ -30,8 +30,6 @@ export class BitErrorComponent {
|
||||
return this.i18nService.t("inputMinLength", this.error[1]?.requiredLength);
|
||||
case "maxlength":
|
||||
return this.i18nService.t("inputMaxLength", this.error[1]?.requiredLength);
|
||||
case "forbiddenCharacters":
|
||||
return this.i18nService.t("inputForbiddenCharacters", this.error[1]?.characters.join(", "));
|
||||
default:
|
||||
// Attempt to show a custom error message.
|
||||
if (this.error[1]?.message) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from "./form-field.module";
|
||||
export * from "./form-field.component";
|
||||
export * from "./form-field-control";
|
||||
export * as BitValidators from "./bit-validators";
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export * from "./multi-select.module";
|
||||
export * from "./models/select-item-view";
|
||||
|
||||
Reference in New Issue
Block a user