fixed navigation tooltip bug and various style improvements

This commit is contained in:
Martina 2020-09-12 15:08:36 -07:00
parent 7f6fef1c72
commit aac943503f
60 changed files with 226 additions and 255 deletions

View File

@ -33,10 +33,11 @@ export const system = {
export const zindex = {
navigation: 1,
sidebar: 4,
sidebar: 5,
alert: 4,
header: 3,
modal: 5,
tooltip: 6,
modal: 6,
tooltip: 7,
};
export const font = {

View File

@ -76,7 +76,7 @@ export const username = (text) => {
return false;
}
if (text.length > 48) {
if (text.length > 48 || text.length < 1) {
return false;
}

View File

@ -3,12 +3,11 @@ import * as Strings from "~/common/strings";
import * as Constants from "~/common/constants";
import { error } from "~/common/messages";
import { css } from "@emotion/react";
const STYLES_ALERT = css`
box-sizing: border-box;
z-index: ${Constants.zindex.modal};
z-index: ${Constants.zindex.alert};
position: fixed;
top: 56px;
width: calc(100% - ${Constants.sizes.navigation}px);
@ -19,105 +18,61 @@ const STYLES_ALERT = css`
display: flex;
flex-wrap: wrap;
align-items: center;
@media (max-width: ${Constants.sizes.mobile}px) {
width: calc(100% - 60px);
}
`;
export class Alert extends React.Component {
state = {
alert: null,
message: null,
status: null,
};
componentDidMount = () => {
window.addEventListener("create-alert", this._handleCreate);
window.addEventListener("click", this._handleDelete);
};
componentWillUnmount = () => {
window.removeEventListener("create-alert", this._handleCreate);
window.removeEventListener("click", this._handleDelete);
};
_handleCreate = (e) => {
this.setState({ alert: e.detail.alert });
if (e.detail.alert) {
if (e.detail.alert.decorator && error[e.detail.alert.decorator]) {
this.setState({
message: error[e.detail.alert.decorator],
status: e.detail.alert.status || null,
});
} else {
this.setState({
message:
e.detail.alert.message ||
"Whoops something went wrong! Please try again.",
status: e.detail.alert.status || null,
});
}
window.setTimeout(this._handleDelete, 5000);
}
};
_handleDelete = (e) => {
if (this.state.alert) {
this.setState({ alert: null });
if (this.state.message) {
this.setState({ message: null, status: null });
}
};
render() {
if (!this.state.alert) {
if (!this.state.message) {
return null;
}
return (
<div
css={STYLES_ALERT}
style={
this.state.alert.status === "INFO"
? { backgroundColor: Constants.system.brand }
: null
}
style={{
backgroundColor:
this.state.status === "INFO" ? Constants.system.brand : "auto",
...this.props.style,
}}
>
{this.state.alert.message
? this.state.alert.message
: this.state.alert.decorator
? error[this.state.alert.decorator] ||
"Whoops something went wrong! Please try again."
: "Whoops something went wrong! Please try again."}
</div>
);
}
}
export class Confirm extends React.Component {
state = {
alert: null,
};
componentDidMount = () => {
window.addEventListener("create-alert", this._handleCreate);
window.addEventListener("click", this._handleDelete);
};
componentWillUnmount = () => {
window.removeEventListener("create-alert", this._handleCreate);
window.removeEventListener("click", this._handleDelete);
};
_handleCreate = (e) => {
this.setState({ alert: e.detail.alert });
};
_handleDelete = (e) => {
if (this.state.alert) {
this.setState({ alert: null });
}
};
render() {
if (!this.state.alert) {
return null;
}
return (
<div
css={STYLES_ALERT}
style={
this.state.alert.status === "INFO"
? { backgroundColor: Constants.system.brand }
: null
}
>
{this.state.alert.message
? this.state.alert.message
: this.state.alert.decorator
? error[this.state.alert.decorator] ||
"Whoops something went wrong! Please try again."
: "Whoops something went wrong! Please try again."}
{this.state.message}
</div>
);
}

View File

@ -51,6 +51,7 @@ import WebsitePrototypeWrapper from "~/components/core/WebsitePrototypeWrapper";
import Cookies from "universal-cookie";
import { dispatchCustomEvent } from "~/common/custom-events";
import { Alert } from "~/components/core/Alert";
const cookies = new Cookies();
@ -357,9 +358,8 @@ export default class ApplicationPage extends React.Component {
console.log("CREATE_USER", response);
response = await Actions.signIn(state);
if (response.error) {
console.log("SIGN IN ERROR", response);
return null;
if (!response || response.error) {
return response;
}
if (response.token) {
@ -441,7 +441,7 @@ export default class ApplicationPage extends React.Component {
});
}
return alert(JSON.stringify(options)); //TODO(martina): convert to alert?
return alert(JSON.stringify(options));
};
_handleNavigateTo = (next, data = null) => {
@ -527,6 +527,7 @@ export default class ApplicationPage extends React.Component {
description="Sign in to your Slate account to manage your assets."
url="https://slate.host/_"
>
<Alert style={{ top: 0, width: "100%" }} />
<SceneSignIn
onAuthenticate={this._handleAuthenticate}
onNavigateTo={this._handleNavigateTo}

View File

@ -32,14 +32,10 @@ const STYLES_APPLICATION_HEADER = css`
align-items: flex-start;
justify-content: space-between;
width: 100%;
height: 104px;
height: 56px;
padding: 12px 48px 0 36px;
pointer-events: none;
background: linear-gradient(
to bottom,
rgba(255, 255, 255, 1) 30%,
rgba(255, 255, 255, 0) 100%
);
background: ${Constants.system.white};
@media (max-width: ${Constants.sizes.mobile}px) {
padding: 12px 24px 0 12px;

View File

@ -14,7 +14,8 @@ const STYLES_SCROLL = css`
-ms-overflow-style: -ms-autohiding-scrollbar;
::-webkit-scrollbar {
width: 4px;
${"" /* width: 4px; */}
display: none;
}
::-webkit-scrollbar-track {
background: ${Constants.system.foreground};
@ -106,6 +107,27 @@ const STYLES_NAVIGATION = css`
}
`;
const STYLES_SIDEBAR_MOBILE = css`
z-index: ${Constants.zindex.sidebar};
height: 100vh;
width: 100%;
padding: 0;
flex-shrink: 0;
position: fixed;
background-color: rgba(247, 247, 247, 1);
top: 0;
right: 0;
${STYLES_SCROLL}
@supports (
(-webkit-backdrop-filter: blur(25px)) or (backdrop-filter: blur(25px))
) {
-webkit-backdrop-filter: blur(75px);
backdrop-filter: blur(25px);
background-color: rgba(247, 247, 247, 0.75);
}
`;
const STYLES_SIDEBAR_WEB = css`
z-index: ${Constants.zindex.sidebar};
height: 100vh;
@ -138,7 +160,7 @@ const STYLES_SIDEBAR_HEADER = css`
`;
const STYLES_SIDEBAR_CONTENT = css`
padding: 8px 24px 24px 24px;
padding: 44px 24px 24px 24px;
`;
const STYLES_BLOCK = css`
@ -182,23 +204,21 @@ export default class ApplicationLayout extends React.Component {
}
return (
<React.Fragment>
<GlobalTooltip
elementRef={this._navigation}
allowedTypes={["navigation"]}
/>
<div
css={STYLES_NAVIGATION}
ref={(c) => {
this._navigation = c;
}}
>
<GlobalTooltip
elementRef={this._navigation}
allowedTypes={["navigation"]}
/>
{this.props.navigation}
</div>
<div css={STYLES_CONTENT}>
<GlobalTooltip elementRef={this._body} allowedTypes={["body"]} />
<Alert />
<div css={STYLES_HEADER}>{this.props.header}</div>
<div
css={STYLES_BODY_WEB}
@ -207,10 +227,28 @@ export default class ApplicationLayout extends React.Component {
}}
id="slate-client-body"
>
<Alert
style={{
paddingRight: this.props.sidebar
? `calc(${Constants.sizes.sidebar}px + 48px`
: "auto",
}}
/>
{this.props.children}
</div>
<div css={STYLES_BODY_MOBILE}>
{this.props.sidebar ? sidebarElements : this.props.children}
<Alert
style={{
top: 0,
left: 0,
width: "100%",
zIndex: Constants.zindex.modal,
}}
/>
{this.props.children}
{this.props.sidebar ? (
<div css={STYLES_SIDEBAR_MOBILE}>{sidebarElements}</div>
) : null}
</div>
</div>

View File

@ -18,7 +18,7 @@ const STYLES_HEADER = css`
display: block;
position: relative;
width: 100%;
padding: 64px 24px 40px 42px;
padding: 100px 24px 40px 42px;
@media (max-width: ${Constants.sizes.mobile}px) {
padding: 68px 0 56px 16px;
@ -172,14 +172,14 @@ export default class ApplicationUserControls extends React.Component {
style={{ position: "relative", top: "8px" }}
navigation={[
{
text: "Account settings",
text: "Account Settings",
onClick: () =>
this._handleAction({
type: "NAVIGATE",
value: "V1_NAVIGATION_PROFILE_EDIT",
}),
},
{ text: "Sign out", onClick: this._handleSignOut },
{ text: "Sign Out", onClick: this._handleSignOut },
]}
/>
</Boundary>

View File

@ -6,7 +6,7 @@ import { css } from "@emotion/react";
const STYLES_SCENE = css`
flex-shrink: 0;
width: 100%;
padding: 82px 48px 128px 48px;
padding: 120px 48px 128px 48px;
display: block;
@media (max-width: ${Constants.sizes.mobile}px) {

View File

@ -71,7 +71,7 @@ const STYLES_BUTTON = css`
}
:focus {
box-shadow: inset 0 0 5px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.3) inset;
outline: 0;
border: 0;
}
@ -89,7 +89,8 @@ export const Section = (props) => {
<span
key={b.name}
css={STYLES_BUTTON}
onClick={() => props.onAction(b)}>
onClick={() => props.onAction(b)}
>
{b.name}
</span>
);

View File

@ -108,7 +108,7 @@ export function SlatePreviewRow(props) {
}
const STYLES_BLOCK = css`
box-shadow: inset 0 0 0 1px ${Constants.system.border};
box-shadow: 0 0 0 1px ${Constants.system.border} inset;
border-radius: 8px;
padding: 32px 40px;
font-size: 12px;
@ -258,7 +258,7 @@ export default class SlatePreviewBlock extends React.Component {
),
},
{
text: "Copy slate ID",
text: "Copy Slate ID",
onClick: (e) => this._handleCopy(e, this.props.slate.id),
},
]

View File

@ -10,7 +10,7 @@ const STYLES_CONTAINER = css`
font-size: 12px;
width: 100%;
display: flex;
align-items: flex-start;
align-items: center;
justify-content: center;
padding: 16px 24px 16px 24px;
@ -42,7 +42,7 @@ const STYLES_LEFT = css`
flex-shrink: 0;
padding: 0 8px 0 8px;
display: flex;
align-items: flex-start;
align-items: center;
justify-content: flex-start;
text-align: left;
@ -55,6 +55,7 @@ const STYLES_RIGHT = css`
min-width: 10%;
width: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
text-align: left;
padding: 0 8px 0 8px;

View File

@ -217,7 +217,7 @@ export default class SidebarAddFileToBucket extends React.Component {
htmlFor="file"
style={{ marginTop: 24 }}
>
Add file
Add File
</System.ButtonPrimary>
<br />

View File

@ -31,7 +31,7 @@ export default class SidebarCreateSlate extends React.Component {
dispatchCustomEvent({
name: "create-alert",
detail: {
alert: { message: "Please provide a name under 48 characters." },
alert: { message: "Please provide a name between 1-48 characters." },
},
});
this.setState({ loading: false });

View File

@ -208,7 +208,7 @@ export default class SidebarSingleSlateSettings extends React.Component {
onClick={this._handleSubmit}
loading={this.state.loading}
>
Save changes
Save Changes
</System.ButtonPrimary>
{!this.state.loading ? (

View File

@ -50,10 +50,11 @@ const STYLES_INPUT_CONTAINER_FULL = css`
const STYLES_INPUT = css`
${INPUT_STYLES}
padding: 0 24px 0 24px;
text-overflow: ellipsis;
white-space: nowrap;
box-shadow: 0 0 0 1px inset ${Constants.system.border};
box-shadow: 0 0 0 1px ${Constants.system.border} inset;
:focus {
outline: 0;

View File

@ -112,7 +112,7 @@ export class CreateFilecoinStorageDeal extends React.Component {
</div>
) : null}
<ButtonSecondary full type="label" htmlFor="file">
Add file
Add File
</ButtonSecondary>
{this.state.file ? (
<ButtonPrimary

View File

@ -18,8 +18,8 @@ export default async ({ slateId, userId, data }) => {
},
errorFn: async (e) => {
return {
error: "CREATE_ACTIVITY",
source: e,
error: true,
decorator: "CREATE_ACTIVITY",
};
},
});

View File

@ -18,8 +18,8 @@ export default async ({ userId, key, level = 1 }) => {
},
errorFn: async (e) => {
return {
error: "CREATE_API_KEY_FOR_USER_ID",
source: e,
error: true,
decorator: "CREATE_API_KEY_FOR_USER_ID",
};
},
});

View File

@ -17,8 +17,8 @@ export default async ({ slatename, data = {} }) => {
},
errorFn: async (e) => {
return {
error: "CREATE_SLATE",
source: e,
error: true,
decorator: "CREATE_SLATE",
};
},
});

View File

@ -18,8 +18,8 @@ export default async ({ subscriberUserId, slateId, userId }) => {
},
errorFn: async (e) => {
return {
error: "CREATE_SUBSCRIPTION",
source: e,
error: true,
decorator: "CREATE_SUBSCRIPTION",
};
},
});

View File

@ -18,8 +18,8 @@ export default async ({ ownerUserId, targetUserId }) => {
},
errorFn: async (e) => {
return {
error: "CREATE_TRUSTED_RELATIONSHIP",
source: e,
error: true,
decorator: "CREATE_TRUSTED_RELATIONSHIP",
};
},
});

View File

@ -19,8 +19,8 @@ export default async ({ password, username, salt, data = {} }) => {
},
errorFn: async (e) => {
return {
error: "CREATE_USER",
source: e,
error: true,
decorator: "CREATE_USER",
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ id }) => {
return await runQuery({
label: "DELETE_ACTIVITY_BY_ID",
queryFn: async (DB) => {
const data = await DB.from("activity")
.where({ id })
.del();
const data = await DB.from("activity").where({ id }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
error: "DELETE_ACTIVITY_BY_ID",
source: e,
error: true,
decorator: "DELETE_ACTIVITY_BY_ID",
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ id }) => {
return await runQuery({
label: "DELETE_API_KEY_BY_ID",
queryFn: async (DB) => {
const data = await DB.from("keys")
.where({ id })
.del();
const data = await DB.from("keys").where({ id }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
error: "DELETE_API_KEY_BY_ID",
source: e,
error: true,
decorator: "DELETE_API_KEY_BY_ID",
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ userId }) => {
return await runQuery({
label: "DELETE_API_KEYS_FOR_USER_ID",
queryFn: async (DB) => {
const data = await DB.from("keys")
.where({ owner_id: userId })
.del();
const data = await DB.from("keys").where({ owner_id: userId }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
error: "DELETE_API_KEYS_FOR_USER_ID",
source: e,
error: true,
decorator: "DELETE_API_KEYS_FOR_USER_ID",
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ id }) => {
return await runQuery({
label: "DELETE_SLATE_BY_ID",
queryFn: async (DB) => {
const data = await DB.from("slates")
.where({ id })
.del();
const data = await DB.from("slates").where({ id }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
error: "DELETE_SLATE_BY_ID",
source: e,
error: true,
decorator: "DELETE_SLATE_BY_ID",
};
},
});

View File

@ -15,8 +15,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
return {
error: "DELETE_SLATES_FOR_USER_ID",
source: e,
error: true,
decorator: "DELETE_SLATES_FOR_USER_ID",
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ id }) => {
return await runQuery({
label: "DELETE_SUBSCRIPTION_BY_ID",
queryFn: async (DB) => {
const data = await DB.from("subscriptions")
.where({ id })
.del();
const data = await DB.from("subscriptions").where({ id }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
error: "DELETE_SUBSCRIPTION_BY_ID",
source: e,
error: true,
decorator: "DELETE_SUBSCRIPTION_BY_ID",
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ id }) => {
return await runQuery({
label: "DELETE_TRUSTED_RELATIONSHIP_BY_ID",
queryFn: async (DB) => {
const data = await DB.from("trusted")
.where({ id })
.del();
const data = await DB.from("trusted").where({ id }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
decorator: "DELETE_TRUSTED_RELATIONSHIP_BY_ID",
error: e,
error: true,
};
},
});

View File

@ -4,16 +4,14 @@ export default async ({ username }) => {
return await runQuery({
label: "DELETE_USER_BY_USERNAME",
queryFn: async (DB) => {
const data = await DB.from("users")
.where({ username })
.del();
const data = await DB.from("users").where({ username }).del();
return 1 === data;
},
errorFn: async (e) => {
return {
error: "DELETE_USER_BY_USERNAME",
source: e,
error: true,
decorator: "DELETE_USER_BY_USERNAME",
};
},
});

View File

@ -4,10 +4,7 @@ export default async ({ id }) => {
return await runQuery({
label: "GET_ACTIVITY_BY_ID",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("activity")
.where({ id })
.first();
const query = await DB.select("*").from("activity").where({ id }).first();
if (!query || query.error) {
return null;
@ -22,8 +19,8 @@ export default async ({ id }) => {
},
errorFn: async (e) => {
return {
error: "GET_ACTIVITY_BY_ID",
source: e,
error: true,
decorator: "GET_ACTIVITY_BY_ID",
};
},
});

View File

@ -16,8 +16,8 @@ export default async ({ slateId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_ACTIVITY_FOR_SLATE_ID",
source: e,
error: true,
decorator: "GET_ACTIVITY_FOR_SLATE_ID",
});
return [];

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_ACTIVITY_FOR_USER_ID",
source: e,
error: true,
decorator: "GET_ACTIVITY_FOR_USER_ID",
});
return [];

View File

@ -4,10 +4,7 @@ export default async ({ key }) => {
return await runQuery({
label: "GET_API_KEY_BY_KEY",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("keys")
.where({ key })
.first();
const query = await DB.select("*").from("keys").where({ key }).first();
if (!query || query.error) {
return null;
@ -21,8 +18,8 @@ export default async ({ key }) => {
},
errorFn: async (e) => {
return {
error: "GET_API_KEY_BY_KEY",
source: e,
error: true,
decorator: "GET_API_KEY_BY_KEY",
};
},
});

View File

@ -4,10 +4,7 @@ export default async ({ id }) => {
return await runQuery({
label: "GET_API_KEY",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("keys")
.where({ id })
.first();
const query = await DB.select("*").from("keys").where({ id }).first();
if (!query || query.error) {
return null;
@ -21,8 +18,8 @@ export default async ({ id }) => {
},
errorFn: async (e) => {
return {
error: "GET_API_KEY",
source: e,
error: true,
decorator: "GET_API_KEY",
};
},
});

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_API_KEYS_BY_USER_ID",
source: e,
error: true,
decorator: "GET_API_KEYS_BY_USER_ID",
});
return [];

View File

@ -19,8 +19,8 @@ export default async () => {
},
errorFn: async (e) => {
console.log({
error: "GET_EVERY_SLATE",
source: e,
error: true,
decorator: "GET_EVERY_SLATE",
});
return [];

View File

@ -17,8 +17,8 @@ export default async () => {
},
errorFn: async (e) => {
console.log({
error: "GET_EVERY_USER",
source: e,
error: true,
decorator: "GET_EVERY_USER",
});
return [];

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_PENDING_TRUSTED_RELATIONSHIPS_BY_USER_ID",
source: e,
error: true,
decorator: "GET_PENDING_TRUSTED_RELATIONSHIPS_BY_USER_ID",
});
return [];

View File

@ -4,10 +4,7 @@ export default async ({ id }) => {
return await runQuery({
label: "GET_SLATE_BY_ID",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("slates")
.where({ id })
.first();
const query = await DB.select("*").from("slates").where({ id }).first();
if (!query || query.error) {
return null;
@ -21,8 +18,8 @@ export default async ({ id }) => {
},
errorFn: async (e) => {
return {
error: "GET_SLATE_BY_ID",
source: e,
error: true,
decorator: "GET_SLATE_BY_ID",
};
},
});

View File

@ -21,8 +21,8 @@ export default async ({ slatename }) => {
},
errorFn: async (e) => {
return {
error: "GET_SLATE_BY_NAME",
source: e,
error: true,
decorator: "GET_SLATE_BY_NAME",
};
},
});

View File

@ -16,9 +16,7 @@ export default async ({ userId, publicOnly = false }) => {
.where(hasUser(userId))
.where(isPublic());
} else {
query = await DB.select("*")
.from("slates")
.where(hasUser(userId));
query = await DB.select("*").from("slates").where(hasUser(userId));
}
if (!query || query.error) {
@ -29,8 +27,8 @@ export default async ({ userId, publicOnly = false }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_SLATES_BY_USER_ID",
source: e,
error: true,
decorator: "GET_SLATES_BY_USER_ID",
});
return [];

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_SUBSCRIBERS_BY_USER_ID",
source: e,
error: true,
decorator: "GET_SUBSCRIBERS_BY_USER_ID",
});
return [];

View File

@ -31,8 +31,8 @@ export default async ({ subscriberUserId, slateId, userId }) => {
},
errorFn: async (e) => {
return {
error: "GET_SUBSCRIPTION_BY_ID",
source: e,
error: true,
decorator: "GET_SUBSCRIPTION_BY_ID",
};
},
});

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_SUBSCRIPTIONS_BY_USER_ID",
source: e,
error: true,
decorator: "GET_SUBSCRIPTIONS_BY_USER_ID",
});
return [];

View File

@ -16,8 +16,8 @@ export default async ({ slateId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_SUBSCRIPTIONS_TO_SLATE_ID",
source: e,
error: true,
decorator: "GET_SUBSCRIPTIONS_TO_SLATE_ID",
});
return [];

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_SUBSCRIPTIONS_TO_USER_ID",
source: e,
error: true,
decorator: "GET_SUBSCRIPTIONS_TO_USER_ID",
});
return [];

View File

@ -4,10 +4,7 @@ export default async ({ id }) => {
return await runQuery({
label: "GET_TRUSTED_RELATIONSHIP_BY_ID",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("trusted")
.where({ id })
.first();
const query = await DB.select("*").from("trusted").where({ id }).first();
if (!query || query.error) {
return null;
@ -21,8 +18,8 @@ export default async ({ id }) => {
},
errorFn: async (e) => {
return {
error: "GET_TRUSTED_RELATIONSHIP_BY_ID",
source: e,
error: true,
decorator: "GET_TRUSTED_RELATIONSHIP_BY_ID",
};
},
});

View File

@ -21,8 +21,8 @@ export default async ({ ownerUserId, targetUserId }) => {
},
errorFn: async (e) => {
return {
error: "GET_TRUSTED_RELATIONSHIP_BY_IDS",
source: e,
error: true,
decorator: "GET_TRUSTED_RELATIONSHIP_BY_IDS",
};
},
});

View File

@ -16,8 +16,8 @@ export default async ({ userId }) => {
},
errorFn: async (e) => {
console.log({
error: "GET_TRUSTED_RELATIONSHIPS_BY_USER_ID",
source: e,
error: true,
decorator: "GET_TRUSTED_RELATIONSHIPS_BY_USER_ID",
});
return [];

View File

@ -4,10 +4,7 @@ export default async ({ id }) => {
return await runQuery({
label: "GET_USER_BY_ID",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("users")
.where({ id })
.first();
const query = await DB.select("*").from("users").where({ id }).first();
if (!query || query.error) {
return null;
@ -21,8 +18,8 @@ export default async ({ id }) => {
},
errorFn: async (e) => {
return {
error: "GET_USER_BY_ID",
source: e,
error: true,
decorator: "GET_USER_BY_ID",
};
},
});

View File

@ -21,8 +21,8 @@ export default async ({ username }) => {
},
errorFn: async (e) => {
return {
error: "GET_USER_BY_USERNAME",
source: e,
error: true,
decorator: "GET_USER_BY_USERNAME",
};
},
});

View File

@ -22,8 +22,8 @@ export default async ({ query }) => {
},
errorFn: async (e) => {
console.log({
error: "QUERY_SLATES",
source: e,
error: true,
decorator: "QUERY_SLATES",
});
return [];

View File

@ -20,8 +20,8 @@ export default async ({ query }) => {
},
errorFn: async (e) => {
console.log({
error: "QUERY_USERS",
source: e,
error: true,
decorator: "QUERY_USERS",
});
return [];

View File

@ -10,15 +10,18 @@ export default async ({ id, slatename, updated_at, data }) => {
return await runQuery({
label: "UPDATE_SLATE_BY_ID",
queryFn: async (DB) => {
const response = await DB.from("slates").where("id", id).update(updateObject).returning("*");
const response = await DB.from("slates")
.where("id", id)
.update(updateObject)
.returning("*");
const index = response ? response.pop() : null;
return index;
},
errorFn: async (e) => {
return {
error: "UPDATE_SLATE_BY_ID",
source: e,
error: true,
decorator: "UPDATE_SLATE_BY_ID",
};
},
});

View File

@ -14,8 +14,8 @@ export default async ({ id, data }) => {
},
errorFn: async (e) => {
return {
error: "UPDATE_TRUSTED_RELATIONSHIP_BY_ID",
source: e,
error: true,
decorator: "UPDATE_TRUSTED_RELATIONSHIP_BY_ID",
};
},
});

View File

@ -32,8 +32,8 @@ export default async ({ id, data, username, salt, password }) => {
},
errorFn: async (e) => {
return {
error: "UPDATE_USER_BY_ID",
source: e,
error: true,
decorator: "UPDATE_USER_BY_ID",
};
},
});

View File

@ -224,7 +224,7 @@ export default class SceneEditAccount extends React.Component {
htmlFor="file"
loading={this.state.changingAvatar}
>
Pick avatar
Pick Avatar
</System.ButtonPrimary>
</div>
@ -251,7 +251,7 @@ export default class SceneEditAccount extends React.Component {
onClick={this._handleSave}
loading={this.state.changingUsername}
>
Change username
Change Username
</System.ButtonPrimary>
</div>
@ -280,7 +280,7 @@ export default class SceneEditAccount extends React.Component {
onClick={this._handleSaveBio}
loading={this.state.changingBio}
>
Update information
Update Information
</System.ButtonPrimary>
</div>
@ -315,7 +315,7 @@ export default class SceneEditAccount extends React.Component {
onClick={this._handleChangePassword}
loading={this.state.changingPassword}
>
Change password
Change Password
</System.ButtonPrimary>
</div>
@ -330,7 +330,7 @@ export default class SceneEditAccount extends React.Component {
onClick={this._handleDelete}
loading={this.state.deleting}
>
Delete my account
Delete My Account
</System.ButtonPrimary>
</div>
</ScenePage>

View File

@ -15,10 +15,10 @@ import ScenePage from "~/components/core/ScenePage";
import Profile from "~/components/core/Profile";
const STATUS_BUTTON_MAP = {
trusted: "Remove peer",
untrusted: "Add peer",
sent: "Cancel request",
received: "Accept request",
trusted: "Remove Peer",
untrusted: "Add Peer",
sent: "Cancel Request",
received: "Accept Request",
};
export default class SceneProfile extends React.Component {

View File

@ -159,7 +159,7 @@ export default class SceneSignIn extends React.Component {
detail: {
alert: {
message:
"We could not sign you into your account, try again later.",
"We could not sign you into your account, please try again later.",
},
},
});
@ -181,9 +181,17 @@ export default class SceneSignIn extends React.Component {
_handleCheckUsername = async () => {
if (!Validations.username(this.state.username)) {
return alert(
"Your username was invalid, only characters and numbers are allowed."
);
console.log("invalid username");
dispatchCustomEvent({
name: "create-alert",
detail: {
alert: {
message:
"Your username was invalid, only characters and numbers are allowed. Usernames must between 1-48 characters",
},
},
});
return;
}
this.setState({ loading: true });
@ -358,7 +366,7 @@ export default class SceneSignIn extends React.Component {
onClick={!this.state.loading ? this._handleSubmit : () => {}}
loading={this.state.loading}
>
Sign in
Sign In
</System.ButtonPrimary>
</div>
<div css={STYLES_LINKS}>