feat(v4): Update the help center portal design (#10296)

Co-authored-by: Pranav <pranavrajs@gmail.com>
This commit is contained in:
Sivin Varghese
2024-10-24 10:39:36 +05:30
committed by GitHub
parent 6d3ecfe3c1
commit a3855a8d1d
144 changed files with 6376 additions and 6604 deletions

View File

@@ -117,3 +117,11 @@ export const timeStampAppendedURL = dataUrl => {
return url.toString();
};
export const getHostNameFromURL = url => {
try {
return new URL(url).hostname;
} catch (error) {
return null;
}
};

View File

@@ -13,3 +13,140 @@ export const buildPortalArticleURL = (
const portalURL = buildPortalURL(portalSlug);
return `${portalURL}/articles/${articleSlug}`;
};
export const getArticleStatus = status => {
switch (status) {
case 'draft':
return 0;
case 'published':
return 1;
case 'archived':
return 2;
default:
return undefined;
}
};
// Constants
export const HELP_CENTER_MENU_ITEMS = [
{
label: 'Articles',
icon: 'book',
action: 'portals_articles_index',
value: [
'portals_articles_index',
'portals_articles_new',
'portals_articles_edit',
],
},
{
label: 'Categories',
icon: 'folder',
action: 'portals_categories_index',
value: [
'portals_categories_index',
'portals_categories_articles_index',
'portals_categories_articles_edit',
],
},
{
label: 'Locales',
icon: 'translate',
action: 'portals_locales_index',
value: ['portals_locales_index'],
},
{
label: 'Settings',
icon: 'settings',
action: 'portals_settings_index',
value: ['portals_settings_index'],
},
];
export const ARTICLE_STATUSES = {
DRAFT: 'draft',
PUBLISHED: 'published',
ARCHIVED: 'archived',
};
export const ARTICLE_MENU_ITEMS = {
publish: {
label: 'HELP_CENTER.ARTICLES_PAGE.ARTICLE_CARD.CARD.DROPDOWN_MENU.PUBLISH',
value: ARTICLE_STATUSES.PUBLISHED,
action: 'publish',
icon: 'checkmark',
},
draft: {
label: 'HELP_CENTER.ARTICLES_PAGE.ARTICLE_CARD.CARD.DROPDOWN_MENU.DRAFT',
value: ARTICLE_STATUSES.DRAFT,
action: 'draft',
icon: 'draft',
},
archive: {
label: 'HELP_CENTER.ARTICLES_PAGE.ARTICLE_CARD.CARD.DROPDOWN_MENU.ARCHIVE',
value: ARTICLE_STATUSES.ARCHIVED,
action: 'archive',
icon: 'archive',
},
delete: {
label: 'HELP_CENTER.ARTICLES_PAGE.ARTICLE_CARD.CARD.DROPDOWN_MENU.DELETE',
value: 'delete',
action: 'delete',
icon: 'delete',
},
};
export const ARTICLE_MENU_OPTIONS = {
[ARTICLE_STATUSES.ARCHIVED]: ['publish', 'draft'],
[ARTICLE_STATUSES.DRAFT]: ['publish', 'archive'],
[ARTICLE_STATUSES.PUBLISHED]: ['draft', 'archive'],
};
export const ARTICLE_TABS = {
ALL: 'all',
MINE: 'mine',
DRAFT: 'draft',
ARCHIVED: 'archived',
};
export const CATEGORY_ALL = 'all';
export const ARTICLE_TABS_OPTIONS = [
{
key: 'ALL',
value: 'all',
},
{
key: 'MINE',
value: 'mine',
},
{
key: 'DRAFT',
value: 'draft',
},
{
key: 'ARCHIVED',
value: 'archived',
},
];
export const LOCALE_MENU_ITEMS = [
{
label: 'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DROPDOWN_MENU.MAKE_DEFAULT',
action: 'change-default',
value: 'default',
icon: 'star-emphasis',
},
{
label: 'HELP_CENTER.LOCALES_PAGE.LOCALE_CARD.DROPDOWN_MENU.DELETE',
action: 'delete',
value: 'delete',
icon: 'delete',
},
];
export const ARTICLE_EDITOR_STATUS_OPTIONS = {
published: ['archive', 'draft'],
archived: ['draft'],
draft: ['archive'],
};

View File

@@ -6,6 +6,7 @@ import {
getArticleSearchURL,
hasValidAvatarUrl,
timeStampAppendedURL,
getHostNameFromURL,
} from '../URLHelper';
describe('#URL Helpers', () => {
@@ -238,4 +239,28 @@ describe('#URL Helpers', () => {
expect(() => timeStampAppendedURL(input)).toThrow();
});
});
describe('getHostNameFromURL', () => {
it('should return the hostname from a valid URL', () => {
expect(getHostNameFromURL('https://example.com/path')).toBe(
'example.com'
);
});
it('should return null for an invalid URL', () => {
expect(getHostNameFromURL('not a valid url')).toBe(null);
});
it('should return null for an empty string', () => {
expect(getHostNameFromURL('')).toBe(null);
});
it('should return null for undefined input', () => {
expect(getHostNameFromURL(undefined)).toBe(null);
});
it('should correctly handle URLs with non-standard TLDs', () => {
expect(getHostNameFromURL('https://chatwoot.help')).toBe('chatwoot.help');
});
});
});