feat: warning for protected note without protection

- Use `.sn-button` everywhere
- Delete permissions modal
- Capitalize "Clear session data"
This commit is contained in:
Baptiste Grob
2021-03-22 16:51:49 +01:00
parent cd7b5cc455
commit cc474da0c3
25 changed files with 418 additions and 476 deletions

View File

@@ -2,7 +2,9 @@ import { toDirective, useAutorunValue } from './utils';
import Close from '../../icons/ic_close.svg';
import { AppState } from '@/ui_models/app_state';
function NoAccountWarning({ appState }: { appState: AppState }) {
type Props = { appState: AppState };
function NoAccountWarning({ appState }: Props) {
const canShow = useAutorunValue(() => appState.noAccountWarning.show);
if (!canShow) {
return null;
@@ -14,7 +16,7 @@ function NoAccountWarning({ appState }: { appState: AppState }) {
Sign in or register to back up your notes.
</p>
<button
className="sn-btn mt-3 col-start-1 col-end-3 justify-self-start"
className="sn-button info mt-3 col-start-1 col-end-3 justify-self-start"
onClick={(event) => {
event.stopPropagation();
appState.accountMenu.setShow(true);
@@ -28,12 +30,13 @@ function NoAccountWarning({ appState }: { appState: AppState }) {
}}
title="Ignore"
label="Ignore"
style="height: 20px"
className="border-0 m-0 p-0 bg-transparent cursor-pointer rounded-md col-start-2 row-start-1 color-neutral hover:color-info"
>
<Close className="fill-current" />
<Close className="fill-current block" />
</button>
</div>
);
}
export const NoAccountWarningDirective = toDirective(NoAccountWarning);
export const NoAccountWarningDirective = toDirective<Props>(NoAccountWarning);

View File

@@ -0,0 +1,37 @@
import { AppState } from '@/ui_models/app_state';
import { toDirective } from './utils';
type Props = { appState: AppState; onViewNote: () => void };
function NoProtectionsNoteWarning({ appState, onViewNote }: Props) {
console.log("🚀 ~ file: NoProtectionsNoteWarning.tsx ~ line 7 ~ NoProtectionsNoteWarning ~ onViewNote", onViewNote)
return (
<div className="flex flex-col items-center justify-center text-center max-w-md">
<h1 className="text-2xl m-0 w-full">This note is protected</h1>
<p className="text-lg mt-2 w-full">
Add a passcode or create an account to require authentication to view
this note.
</p>
<div className="mt-4 flex gap-3">
<button
className="sn-button info"
onClick={() => {
appState.accountMenu.setShow(true);
}}
>
Open account menu
</button>
<button className="sn-button outlined" onClick={onViewNote}>
View note
</button>
</div>
</div>
);
}
export const NoProtectionsdNoteWarningDirective = toDirective<Props>(
NoProtectionsNoteWarning,
{
onViewNote: '&',
}
);

View File

@@ -171,7 +171,7 @@ const SessionsModal: FunctionComponent<{
{formatter.format(session.updated_at)}
</p>
<button
className="sk-button danger sk-label"
className="sn-button danger sk-label"
disabled={session.revoking}
onClick={() =>
setRevokingSessionUuid(session.uuid)
@@ -210,17 +210,16 @@ const SessionsModal: FunctionComponent<{
<AlertDialogDescription className="sk-panel-row">
<p>{SessionStrings.RevokeText}</p>
</AlertDialogDescription>
<div className="sk-panel-row">
<div className="sk-button-group">
<div className="flex my-1 gap-2">
<button
className="sk-button neutral sk-label"
className="sn-button neutral sk-label"
ref={cancelRevokeRef}
onClick={closeRevokeSessionAlert}
>
<span>{SessionStrings.RevokeCancelButton}</span>
</button>
<button
className="sk-button danger sk-label"
className="sn-button danger sk-label"
onClick={() => {
closeRevokeSessionAlert();
revokeSession(confirmRevokingSessionUuid);
@@ -228,7 +227,6 @@ const SessionsModal: FunctionComponent<{
>
<span>{SessionStrings.RevokeConfirmButton}</span>
</button>
</div>
</div>
</div>
</div>

View File

@@ -20,11 +20,9 @@ export function useAutorun(
useEffect(() => autorun(view, opts), [view, opts]);
}
export function toDirective(
component: FunctionComponent<{
application: WebApplication;
appState: AppState;
}>
export function toDirective<Props>(
component: FunctionComponent<Props>,
scope: Record<string, '=' | '&'> = {}
) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
return function () {
@@ -37,10 +35,7 @@ export function toDirective(
return {
$onChanges() {
render(
h(component, {
application: $scope.application,
appState: $scope.appState,
}),
h(component, $scope),
$element[0]
);
},
@@ -50,6 +45,7 @@ export function toDirective(
scope: {
application: '=',
appState: '=',
...scope,
},
};
};