Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@
class="DeploySharedBlueprint__textarea"
:class="{
'DeploySharedBlueprint__textarea--error':
errors.description,
errors.description || isDescriptionOverLimit,
}"
/>
<div
class="DeploySharedBlueprint__charCounter"
:class="{
'DeploySharedBlueprint__charCounter--error':
isDescriptionOverLimit,
}"
>
{{ descriptionLength }}/{{ DESCRIPTION_MAX_LENGTH }}
</div>
</WdsFieldWrapper>

<div
Expand Down Expand Up @@ -67,6 +76,8 @@ const props = defineProps<{
blueprintId: string;
}>();

const DESCRIPTION_MAX_LENGTH = 8192;

const isOpen = defineModel({ type: Boolean });

const wf = inject(injectionKeys.core);
Expand Down Expand Up @@ -105,6 +116,11 @@ const errors = shallowRef<Record<string, string>>({});
const isDeploying = ref(false);
const prUrl = ref<string | null>(null);

const descriptionLength = computed(() => form.value.description.length);
const isDescriptionOverLimit = computed(
() => descriptionLength.value > DESCRIPTION_MAX_LENGTH,
);

function validateForm(): boolean {
const newErrors: Record<string, string> = {};

Expand All @@ -113,6 +129,8 @@ function validateForm(): boolean {
}
if (!form.value.description.trim()) {
newErrors.description = "Description is required";
} else if (isDescriptionOverLimit.value) {
newErrors.description = `Description must be ${DESCRIPTION_MAX_LENGTH} characters or less`;
}

errors.value = newErrors;
Expand Down Expand Up @@ -257,7 +275,7 @@ const modalActions = computed<ModalAction[]>(() => {
{
desc: isDeploying.value ? publishingText : publishText,
fn: handleDeploy,
disabled: isDeploying.value,
disabled: isDeploying.value || isDescriptionOverLimit.value,
},
];
});
Expand Down Expand Up @@ -298,6 +316,17 @@ watch(isOpen, (newValue) => {
border-color: var(--builderErrorColor);
}

.DeploySharedBlueprint__charCounter {
font-size: 12px;
color: var(--builderSecondaryTextColor);
text-align: right;
margin-top: 4px;
}

.DeploySharedBlueprint__charCounter--error {
color: var(--builderErrorColor);
}

.DeploySharedBlueprint__globalOption {
display: flex;
flex-direction: column;
Expand Down