Skip to content

Commit

Permalink
Rename Url PropertyFormat to HttpUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Arciiix committed Aug 26, 2024
1 parent 47bb6e6 commit 6149d80
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ private bool TryGetString(string? input, [MaybeNullWhen(true)] out string error,
}

break;
case PropertyFormat.Url:
case PropertyFormat.HttpUrl:
// We only allow http and https to enable the usage of URL field for HttpClient requests.
if (!Uri.TryCreate(input, UriKind.Absolute, out var uri) || !((string[])["http", "https"]).Contains(uri.Scheme, StringComparer.OrdinalIgnoreCase))
{
error = Texts.IntegrationPropertyFormatUrl;
error = Texts.IntegrationPropertyFormatHttpUrl;
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public enum PropertyFormat
{
None,
Email,
Url
HttpUrl
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
<data name="IntegrationPropertyFormatEmail" xml:space="preserve">
<value>Field is not a valid e-mail.</value>
</data>
<data name="IntegrationPropertyFormatUrl" xml:space="preserve">
<value>Field is not a valid URL (remember about the protocol).</value>
<data name="IntegrationPropertyFormatHttpUrl" xml:space="preserve">
<value>Field is not a valid URL (remember about the protocol - http or https).</value>
</data>
<data name="IntegrationPropertyInvalidBoolean" xml:space="preserve">
<value>Not a valid boolean value.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed partial class HttpIntegration : IIntegration
EditorDescription = Texts.Webhook_URLHints,
IsRequired = true,
Summary = true,
Format = PropertyFormat.Url,
Format = PropertyFormat.HttpUrl,
};

private static readonly IntegrationProperty HttpMethodProperty = new IntegrationProperty("Method", PropertyType.Text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void Should_fail_if_url_is_invalid(string? input)

var property = new IntegrationProperty("key", PropertyType.Text)
{
Format = PropertyFormat.Url
Format = PropertyFormat.HttpUrl
};

Assert.Throws<ValidationException>(() => property.GetString(source));
Expand All @@ -191,7 +191,7 @@ public void Should_get_url_if_value_is_valid(string? input)

var property = new IntegrationProperty("key", PropertyType.Text)
{
Format = PropertyFormat.Url
Format = PropertyFormat.HttpUrl
};

Assert.Equal(input, property.GetString(source));
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/pages/app/AppAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const FormSchema = Yup.object().shape({

// Valid URL.
signoutRedirectUrl: Yup.string()
.label(texts.auth.signoutRedirectUrl).urlI18n(),
.label(texts.auth.signoutRedirectUrl).httpUrlI18n(),
});

const AuthForm = ({ appDetails, scheme }: { scheme?: AuthSchemeDto } & AppAuthProps) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/pages/app/AppSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const FormSchema = Yup.object().shape({

// Valid URL
confirmUrl: Yup.string().nullable()
.label(texts.app.confirmUrl).urlI18n(),
.label(texts.app.confirmUrl).httpUrlI18n(),
});

export interface AppSettingsProps {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/pages/integrations/IntegrationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export const IntegrationDialog = (props: IntegrationDialogProps) => {
case "Email":
propertyType = propertyType.emailI18n();
break;
case "Url":
propertyType = propertyType.urlI18n();
case "HttpUrl":
propertyType = propertyType.httpUrlI18n();
break;
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ export const FormField = ({ property }: { property: IntegrationPropertyDto }) =>
<Forms.Email name={name}
label={label} hints={property.editorDescription} />
);
case 'Url':
case 'HttpUrl':
return (
<Forms.Url name={name}
label={label} hints={property.editorDescription} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7437,7 +7437,7 @@ export interface IntegrationPropertyDto {
}

export type PropertyType = "Text" | "Number" | "MultilineText" | "Password" | "Boolean";
export type PropertyFormat = "None" | "Email" | "Url";
export type PropertyFormat = "None" | "Email" | "HttpUrl";

export interface IntegrationCreatedDto {
/** The ID of the integration. */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/shared/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) Sebastian Stehle. All rights reserved.
*/

import { ChannelCondition, ChannelRequired, ChannelSend, ConfirmMode, IsoDayOfWeek, PropertyFormat, SchedulingType, TopicChannel } from '@app/service';
import { ChannelCondition, ChannelRequired, ChannelSend, ConfirmMode, IsoDayOfWeek , SchedulingType, TopicChannel } from '@app/service';
import { texts } from '@app/texts';

export const CHANNELS = [
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/shared/utils/yup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function emailI18n(this: Yup.StringSchema) {
return this.email(texts.validation.emailFn);
}

function urlI18n(this: Yup.StringSchema) {
function httpUrlI18n(this: Yup.StringSchema) {
// This regular expression is built on top of the one
// from Yup, but it also allows localhost.
// See: https://github.com/jquense/yup/issues/224
return this.matches(/^(?:(?:https?):\/\/|www\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*\)|[A-Z0-9+&@#\/%=~_|$[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])$/i , texts.validation.urlFn);
return this.matches(/^(?:(?:https?):\/\/|www\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*\)|[A-Z0-9+&@#\/%=~_|$[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])$/i , texts.validation.httpUrlFn);
}

function requiredI18nNumber(this: Yup.NumberSchema) {
Expand Down Expand Up @@ -64,7 +64,7 @@ export function extendYup() {
Yup.addMethod(Yup.object, 'atLeastOneStringI18n', atLeastOneStringI18n);

Yup.addMethod(Yup.string, 'emailI18n', emailI18n);
Yup.addMethod(Yup.string, 'urlI18n', urlI18n);
Yup.addMethod(Yup.string, 'httpUrlI18n', httpUrlI18n);
Yup.addMethod(Yup.string, 'requiredI18n', requiredI18n);
Yup.addMethod(Yup.string, 'topicI18n', topicI18n);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/texts/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export const EN = {
validation: {
atLeastOnString: (p: { label?: string }) => `${p.label} needs at least one value.`,
emailFn: (p: { label?: string }) => `${p.label} must be a valid email address.`,
httpUrlFn: (p: { label?: string }) => `${p.label} must be a valid HTTP URL (include the protocol - http or https).`,
lessThanFn: (p: { label?: string; less: number }) => `${p.label} must be less than ${p.less || 0}.`,
maxFn: (p: { label?: string; max: number }) => `${p.label} must not greater than ${p.max}.`,
maxItemsFn: (p: { label?: string; max: number }) => `${p.label} must not have more than ${p.max}.`,
Expand All @@ -444,6 +445,5 @@ export const EN = {
patternFn: (p: { label?: string }) => `${p.label} is not in a valid format.`,
requiredFn: (p: { label?: string }) => `${p.label} is required.`,
topicFn: (p: { label?: string }) => `${p.label} must be a valid topic.`,
urlFn: (p: { label?: string }) => `${p.label} must be a valid URL with a protocol (e.g. https).`,
},
};
2 changes: 1 addition & 1 deletion frontend/src/app/texts/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ export const TR = {
validation: {
atLeastOnString: (p: { label?: string }) => `${p.label} en az bir değere sahip olmalıdır.`,
emailFn: (p: { label?: string }) => `${p.label} geçerli bir e-posta adresi olmalıdır.`,
httpUrlFn: (p: { label?: string }) => `${p.label} geçerli bir HTTP URL'si olmalı (protokolü ekleyin - http veya https).`,
lessThanFn: (p: { label?: string; less: number }) => `${p.label} ${p.less || 0}\`dan küçük olmalıdır.`,
maxFn: (p: { label?: string; max: number }) => `${p.label} ${p.max}\`dan büyük olmamalıdır.`,
maxItemsFn: (p: { label?: string; max: number }) => `${p.label} en fazla ${p.max} öğeye sahip olmalıdır.`,
Expand All @@ -428,6 +429,5 @@ export const TR = {
patternFn: (p: { label?: string }) => `${p.label} geçerli bir formatta değil.`,
requiredFn: (p: { label?: string }) => `${p.label} zorunludur.`,
topicFn: (p: { label?: string }) => `${p.label} geçerli bir konu olmalıdır.`,
urlFn: (p: { label?: string }) => `${p.label} geçerli bir URL olmalıdır.`,
},
};
2 changes: 1 addition & 1 deletion frontend/src/app/typings/yup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare module 'yup' {
interface StringSchema {
emailI18n(): StringSchema;

urlI18n(): StringSchema;
httpUrlI18n(): StringSchema;

requiredI18n(): StringSchema;

Expand Down
4 changes: 2 additions & 2 deletions tools/sdk/Notifo.SDK/Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17903,8 +17903,8 @@ public enum PropertyFormat
[System.Runtime.Serialization.EnumMember(Value = @"Email")]
Email = 1,

[System.Runtime.Serialization.EnumMember(Value = @"Url")]
Url = 2,
[System.Runtime.Serialization.EnumMember(Value = @"HttpUrl")]
HttpUrl = 2,

}

Expand Down

0 comments on commit 6149d80

Please sign in to comment.