Skip to content

Commit

Permalink
Merge branch 'main' into feat-pink-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzNotABug authored Jan 3, 2025
2 parents 8e2f133 + 52a4bd2 commit 0dae2b9
Show file tree
Hide file tree
Showing 100 changed files with 1,111 additions and 621 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"plausible-tracker": "^0.3.9",
"pretty-bytes": "^6.1.1",
"prismjs": "^1.29.0",
"remarkable": "^2.0.1",
"svelte-confetti": "^1.4.0",
"tippy.js": "^6.3.7"
},
Expand All @@ -56,6 +57,7 @@
"@testing-library/user-event": "^14.5.2",
"@types/deep-equal": "^1.0.4",
"@types/prismjs": "^1.26.5",
"@types/remarkable": "^2.0.8",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitest/ui": "^1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const config: PlaywrightTestConfig = {
webServer: {
timeout: 120000,
env: {
PUBLIC_APPWRITE_ENDPOINT: 'https://console-testing.appwrite.org/v1',
PUBLIC_APPWRITE_ENDPOINT: 'https://console-testing-2.appwrite.org/v1',
PUBLIC_CONSOLE_MODE: 'cloud',
PUBLIC_STRIPE_KEY:
'pk_test_51LT5nsGYD1ySxNCyd7b304wPD8Y1XKKWR6hqo6cu3GIRwgvcVNzoZv4vKt5DfYXL1gRGw4JOqE19afwkJYJq1g3K004eVfpdWn'
Expand Down
28 changes: 28 additions & 0 deletions pnpm-lock.yaml

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

59 changes: 53 additions & 6 deletions src/lib/commandCenter/panels/ai.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script lang="ts">
import { Remarkable } from 'remarkable';
import Template from './template.svelte';
const markdownInstance = new Remarkable();
import { Alert, AvatarInitials, Code, LoadingDots, SvgIcon } from '$lib/components';
import { user } from '$lib/stores/user';
import { useCompletion } from 'ai/svelte';
Expand All @@ -19,8 +22,6 @@
credentials: 'include'
});
let question = $input;
const examples = [
'How to add platform in the console?',
'How can I manage users, permissions, and access control in Appwrite?',
Expand Down Expand Up @@ -87,10 +88,47 @@
$: answer = parseCompletion($completion);
function renderMarkdown(answer: string): string {
const trimmedAnswer = answer
.trim()
.replace(/[ \t]+/g, ' ')
.replace(/\n[ \t]+/g, '\n')
.replace(/\n+/g, '\n');
// targeting links in plain text.
const processedAnswer = trimmedAnswer
.replace(/(\[(.*?)]\((.*?)\))|https?:\/\/\S+/g, (match, fullMarkdownLink, _, __) =>
fullMarkdownLink ? match : `[${match}](${match})`
)
.replace(/https?:\/\/\S+##/g, (url) => url.replace(/##/, '#'));
const formattedAnswer = processedAnswer.replace(
/(^|\n)Sources:/g,
(_, prefix) => `${prefix}\nSources:`
);
let renderedHTML = markdownInstance.render(formattedAnswer);
// add target blank to open links in a new tab.
renderedHTML = renderedHTML.replace(/<a\s+href="([^"]+)"/g, '<a href="$1" target="_blank"');
return renderedHTML;
}
function getInitials(name: string) {
const [first, last] = name.split(' ');
return `${first?.[0] ?? ''}${last?.[0] ?? ''}`;
}
let previousQuestion = '';
$: if ($input) {
previousQuestion = $input;
}
$: if (!$isLoading && answer) {
// reset input if answer received.
$input = '';
}
</script>

<Template
Expand Down Expand Up @@ -142,7 +180,7 @@
<div class="content">
<div class="u-flex u-gap-8 u-cross-center">
<div class="avatar is-size-x-small">{getInitials($user.name)}</div>
<p class="u-opacity-75">{question}</p>
<p class="u-opacity-75">{previousQuestion}</p>
</div>
<div class="u-flex u-gap-8 u-margin-block-start-24">
<div class="logo">
Expand All @@ -154,7 +192,7 @@
{:else}
{#each answer as part}
{#if part.type === 'text'}
<p>{part.value.trimStart()}</p>
<p>{@html renderMarkdown(part.value.trim())}</p>
{:else if part.type === 'code'}
{#key part.value}
<div
Expand Down Expand Up @@ -196,7 +234,6 @@
class="input-text-wrapper u-width-full-line"
style="--amount-of-buttons: 1;"
on:submit|preventDefault={(e) => {
question = $input;
handleSubmit(e);
}}>
<!-- svelte-ignore a11y-autofocus -->
Expand Down Expand Up @@ -269,10 +306,20 @@
.answer {
overflow: hidden;
p {
p:first-of-type {
white-space: pre-wrap;
}
}
:global(.answer ul),
:global(.answer ol) {
gap: 1rem;
display: grid;
}
:global(.answer a) {
text-decoration: underline;
}
}
.footer {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/components/avatarGroup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
export let bordered = false;
export let color = '';
let classes = '';
export { classes as class };
enum Sizes {
xsmall = 'is-size-x-small',
small = 'is-size-small',
Expand All @@ -18,7 +21,7 @@
}
</script>

<ul class="avatars-group" class:is-with-border={bordered}>
<ul class="avatars-group {classes}" class:is-with-border={bordered}>
{#each avatars as name, index}
{#if index < 2}
<li class="avatars-group-item">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/billing/estimatedTotalBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</span>

<p class="text u-margin-block-start-16">
You'll pay <span class="u-bold">{formatCurrency(estimatedTotal)}</span> now, with our first
You'll pay <span class="u-bold">{formatCurrency(estimatedTotal)}</span> now, with your first
billing cycle starting on
<span class="u-bold"
>{!currentPlan.trialDays
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/billing/selectPaymentMethod.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<InputText
id="taxId"
label="Tax ID"
autofocus
placeholder="Tax ID"
bind:value={taxId} />
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/lib/components/code.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@
export let noBoxPadding = false;
export let allowScroll = false;
let classes = '';
export { classes as class };
Prism.plugins.customClass.prefix('prism-');
afterUpdate(async () => {
Prism.highlightAll();
});
</script>

<section class="box u-overflow-hidden" class:common-section={!noMargin} class:noBoxPadding>
<section
class="box u-overflow-hidden {classes}"
class:common-section={!noMargin}
class:noBoxPadding>
<div
class="controls u-position-absolute u-inset-inline-end-8 u-inset-block-start-8 u-flex u-gap-8">
{#if label}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/collapsibleItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@

<style lang="scss">
// TODO: remove once pink is updated
.collapsible-item {
.collapsible-item:not(.is-info) {
.collapsible-wrapper {
padding-left: 0;
padding-left: 0.5rem;
}
.collapsible-wrapper.is-disabled {
cursor: not-allowed;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/dropListLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export let disabled = false;
export let external = false;
export let event: string = null;
export let iconStyle: string = '';
function track() {
if (!event) {
Expand All @@ -29,7 +30,7 @@
rel={external ? 'noopener noreferrer' : ''}>
<span class="text"><slot /></span>
{#if icon}
<span class={`icon-${icon}`} aria-hidden="true" />
<span class={`icon-${icon}`} style={iconStyle} aria-hidden="true" />
{/if}
</a>
</li>
2 changes: 1 addition & 1 deletion src/lib/components/migrationBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</button>
</header>
<div class="upload-box-content is-open">
<section class="progress-bar">
<section class="progress-bar u-padding-inline-16 u-padding-block-16">
<div class="progress-bar-top-line u-flex u-gap-8 u-main-space-between">
<span>{percentage}%</span>
</div>
Expand Down
11 changes: 4 additions & 7 deletions src/lib/components/support.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
import SupportWizard from '$routes/(console)/supportWizard.svelte';
import { showSupportModal } from '$routes/(console)/wizard/support/store';
import { isCloud } from '$lib/system';
import { organization } from '$lib/stores/organization';
import { BillingPlan } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { localeTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date';
import { upgradeURL } from '$lib/stores/billing';
import { currentPlan } from '$lib/stores/organization';
export let show = false;
$: isPaid =
$organization?.billingPlan === BillingPlan.PRO ||
$organization?.billingPlan === BillingPlan.SCALE;
$: hasPremiumSupport = $currentPlan?.premiumSupport ?? false;
$: supportTimings = `${utcHourToLocaleHour('16:00')} - ${utcHourToLocaleHour('00:00')} ${localeTimezoneName()}`;
</script>
Expand All @@ -24,13 +21,13 @@
<section class="drop-section u-grid u-gap-24 u-padding-24">
<div>
<h4 class="eyebrow-heading-3">Premium support</h4>
{#if isPaid}
{#if hasPremiumSupport}
<p class="u-line-height-1-5 u-margin-block-start-8">
Get personalized support from the Appwrite team from <b>{supportTimings}</b>
</p>
{/if}
</div>
{#if $organization?.billingPlan === BillingPlan.FREE}
{#if !hasPremiumSupport}
<Button
fullWidth
href={$upgradeURL}
Expand Down
12 changes: 12 additions & 0 deletions src/lib/elements/forms/inputNumber.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
let error: string;
onMount(() => {
if (autofocus) {
addInputFocus();
}
});
export function addInputFocus() {
if (element) {
element.focus();
}
}
const handleInvalid = (event: Event & { currentTarget: EventTarget & HTMLInputElement }) => {
event.preventDefault();
Expand Down
Loading

0 comments on commit 0dae2b9

Please sign in to comment.