Skip to content

Commit

Permalink
dash: support app blocking canary testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredh159 committed Dec 16, 2024
1 parent d0ee5a1 commit 83a6526
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion dash/app/cypress/e2e/create-key.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe(`create key flow`, () => {
id: `app-123`,
name: `Brave`,
slug: `brave`,
selectable: true,
launchable: true,
bundleIds: [],
},
]);
Expand Down
2 changes: 1 addition & 1 deletion dash/app/src/reducers/__tests__/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function identifiedApp(
id: uuid(),
name: `Brave Browser`,
slug: `brave`,
selectable: true,
launchable: true,
bundleIds: [{ id: uuid(), bundleId: `com.brave.Browser` }],
...override,
};
Expand Down
6 changes: 3 additions & 3 deletions dash/app/src/reducers/user-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
UserKeychainSummary,
PlainTimeWindow,
User,
KeychainSchedule,
RuleSchedule,
} from '@dash/types';
import { commit, editable } from '../lib/helpers';

Expand All @@ -25,9 +25,9 @@ export type Action =
| { type: 'setDowntime'; downtime: PlainTimeWindow }
| { type: 'setShowSuspensionActivity'; show: boolean }
| { type: 'removeKeychain'; id: UUID }
| { type: 'setKeychainSchedule'; id: UUID; schedule?: KeychainSchedule }
| { type: 'setKeychainSchedule'; id: UUID; schedule?: RuleSchedule }
| { type: 'addKeychain'; keychain: UserKeychainSummary }
| { type: 'setAddingKeychainSchedule'; schedule?: KeychainSchedule }
| { type: 'setAddingKeychainSchedule'; schedule?: RuleSchedule }
| { type: 'setAddingKeychain'; keychain?: UserKeychainSummary | null };

function reducer(state: State, action: Action): State | undefined {
Expand Down
4 changes: 2 additions & 2 deletions dash/components/src/Keychains/KeychainCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { inflect } from '@shared/string';
import { Button, Badge } from '@shared/components';
import { ChevronDownIcon, ClockIcon, TrashIcon } from '@heroicons/react/24/outline';
import { UsersIcon } from '@heroicons/react/24/solid';
import { defaults, type KeychainSchedule as Schedule } from '@dash/types';
import { defaults, type RuleSchedule as Schedule } from '@dash/types';
import GradientIcon from '../GradientIcon';
import KeychainSchedule from './schedule/KeychainSchedule';

Expand Down Expand Up @@ -118,7 +118,7 @@ const KeychainCard: React.FC<Props> = ({
{props.mode === `assign_to_child` && !props.schedule && (
<button
onClick={() => {
props.setSchedule(defaults.keychainSchedule());
props.setSchedule(defaults.ruleSchedule());
setShowSchedule(true);
}}
className={cx(
Expand Down
6 changes: 3 additions & 3 deletions dash/components/src/Keychains/schedule/KeychainSchedule.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import cx from 'classnames';
import type { KeychainSchedule } from '@dash/types';
import type { RuleSchedule } from '@dash/types';
import SpecifyingActiveOrInactive from './SpecifyingActiveOrInactive';
import WhatDays from './WhatDays';
import WhatTime from './WhatTime';

interface Props {
schedule: KeychainSchedule;
setSchedule(schedule: KeychainSchedule): void;
schedule: RuleSchedule;
setSchedule(schedule: RuleSchedule): void;
}

const KeychainSchedule: React.FC<Props> = ({ schedule, setSchedule }) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import cx from 'classnames';
import { ArrowsRightLeftIcon } from '@heroicons/react/24/outline';
import type { KeychainSchedule } from '@dash/types';
import type { RuleSchedule } from '@dash/types';

const SpecifyingActiveOrInactive: React.FC<{
schedule: KeychainSchedule;
setSchedule(schedule: KeychainSchedule): void;
schedule: RuleSchedule;
setSchedule(schedule: RuleSchedule): void;
isTouchDevice: boolean;
}> = ({ schedule, setSchedule, isTouchDevice }) => (
<button
Expand Down
6 changes: 3 additions & 3 deletions dash/components/src/Keychains/schedule/WhatDays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React from 'react';
import cx from 'classnames';
import { typesafe } from '@shared/ts-utils';
import { CheckIcon } from '@heroicons/react/24/outline';
import type { KeychainSchedule } from '@dash/types';
import type { RuleSchedule } from '@dash/types';
import DropdownCustomizationPoint from './DropdownCustomizationPoint';

const WhatDays: React.FC<{
schedule: KeychainSchedule;
setSchedule(schedule: KeychainSchedule): void;
schedule: RuleSchedule;
setSchedule(schedule: RuleSchedule): void;
isTouchDevice: boolean;
}> = ({ schedule, setSchedule, isTouchDevice }) => (
<DropdownCustomizationPoint
Expand Down
6 changes: 3 additions & 3 deletions dash/components/src/Keychains/schedule/WhatTime.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import cx from 'classnames';
import type { KeychainSchedule } from '@dash/types';
import type { RuleSchedule } from '@dash/types';
import TimeInput from '../../Forms/TimeInput';
import DropdownCustomizationPoint from './DropdownCustomizationPoint';

const WhatTime: React.FC<{
schedule: KeychainSchedule;
setSchedule(schedule: KeychainSchedule): void;
schedule: RuleSchedule;
setSchedule(schedule: RuleSchedule): void;
isTouchDevice: boolean;
}> = ({ schedule, setSchedule, isTouchDevice }) => {
const isInvalid = (() => {
Expand Down
4 changes: 2 additions & 2 deletions dash/components/src/Users/AddKeychainDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { Badge, Button, Loading } from '@shared/components';
import { inflect } from '@shared/string';
import { defaults, type KeychainSummary as Keychain } from '@dash/types';
import type { KeychainSchedule as Schedule, RequestState } from '@dash/types';
import type { RuleSchedule as Schedule, RequestState } from '@dash/types';
import KeychainSchedule from '../Keychains/schedule/KeychainSchedule';

interface Props {
Expand Down Expand Up @@ -318,7 +318,7 @@ const AddKeychainDrawer: React.FC<Props> = ({
</>
) : (
<button
onClick={() => selected && setSchedule(defaults.keychainSchedule())}
onClick={() => selected && setSchedule(defaults.ruleSchedule())}
className={cx(
`flex items-center px-2 py-1 rounded-full transition-[background-color,transform] duration-200 active:scale-90 gap-1.5 bg-slate-200/50 hover:bg-slate-200 active:bg-slate-300`,
)}
Expand Down
8 changes: 4 additions & 4 deletions dash/components/src/Users/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import cx from 'classnames';
import { inflect } from '@shared/string';
import { TextInput, Button, Toggle, Label } from '@shared/components';
import type { KeychainSchedule, PlainTimeWindow } from '@dash/types';
import type { RuleSchedule, PlainTimeWindow } from '@dash/types';
import type { Subcomponents, ConfirmableEntityAction, RequestState } from '@dash/types';
import type { UserKeychainSummary as Keychain } from '@dash/types';
import KeychainCard from '../Keychains/KeychainCard';
Expand Down Expand Up @@ -49,9 +49,9 @@ interface Props {
onDismissAddKeychain(): unknown;
addingKeychain?: Keychain | null;
fetchSelectableKeychainsRequest?: RequestState<{ own: Keychain[]; public: Keychain[] }>;
keychainSchedule?: KeychainSchedule;
setAddingKeychainSchedule(schedule?: KeychainSchedule): unknown;
setAssignedKeychainSchedule(id: UUID, schedule?: KeychainSchedule): unknown;
keychainSchedule?: RuleSchedule;
setAddingKeychainSchedule(schedule?: RuleSchedule): unknown;
setAssignedKeychainSchedule(id: UUID, schedule?: RuleSchedule): unknown;
}

const EditUser: React.FC<Props> = ({
Expand Down
4 changes: 2 additions & 2 deletions dash/types/src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PlainTimeWindow, KeychainSchedule } from './pairql/shared';
import type { PlainTimeWindow, RuleSchedule } from './pairql/shared';

export function timeWindow(): PlainTimeWindow {
return {
Expand All @@ -7,7 +7,7 @@ export function timeWindow(): PlainTimeWindow {
};
}

export function keychainSchedule(): KeychainSchedule {
export function ruleSchedule(): RuleSchedule {
return {
mode: `active`,
days: {
Expand Down
2 changes: 1 addition & 1 deletion dash/types/src/pairql/pairs/GetIdentifiedApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export namespace GetIdentifiedApps {
id: UUID;
name: string;
slug: string;
selectable: boolean;
launchable: boolean;
bundleIds: Array<{
id: UUID;
bundleId: string;
Expand Down
4 changes: 2 additions & 2 deletions dash/types/src/pairql/pairs/SaveUser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// auto-generated, do not edit
import type { KeychainSchedule, SuccessOutput, PlainTimeWindow } from '../shared';
import type { PlainTimeWindow, SuccessOutput, RuleSchedule } from '../shared';

export namespace SaveUser {
export interface Input {
Expand All @@ -14,7 +14,7 @@ export namespace SaveUser {
downtime?: PlainTimeWindow;
keychains: Array<{
id: UUID;
schedule?: KeychainSchedule;
schedule?: RuleSchedule;
}>;
}

Expand Down
30 changes: 15 additions & 15 deletions dash/types/src/pairql/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,6 @@ export interface Key {
key: SharedKey;
}

export interface KeychainSchedule {
mode: 'active' | 'inactive';
days: {
sunday: boolean;
monday: boolean;
tuesday: boolean;
wednesday: boolean;
thursday: boolean;
friday: boolean;
saturday: boolean;
};
window: PlainTimeWindow;
}

export interface KeychainSummary {
id: UUID;
authorId: UUID;
Expand All @@ -97,6 +83,20 @@ export type ReleaseChannel = 'stable' | 'beta' | 'canary';

export type RequestStatus = 'pending' | 'accepted' | 'rejected';

export interface RuleSchedule {
mode: 'active' | 'inactive';
days: {
sunday: boolean;
monday: boolean;
tuesday: boolean;
wednesday: boolean;
thursday: boolean;
friday: boolean;
saturday: boolean;
};
window: PlainTimeWindow;
}

export interface ServerPqlError {
version: number;
id: string;
Expand Down Expand Up @@ -213,7 +213,7 @@ export interface UserKeychainSummary {
description?: string;
isPublic: boolean;
numKeys: number;
schedule?: KeychainSchedule;
schedule?: RuleSchedule;
}

export interface VerifiedNotificationMethod {
Expand Down

0 comments on commit 83a6526

Please sign in to comment.