Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dash: remove time-features gate, v2.5.0 stable #420

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dash/app/src/components/routes/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const UserRoute: React.FC = () => {
isNew={state.user.isNew || false}
name={draft.name}
id={draft.id}
canUseTimeFeatures={draft.canUseTimeFeatures}
setName={(name) => dispatch({ type: `setName`, name })}
keyloggingEnabled={draft.keyloggingEnabled}
setKeyloggingEnabled={(enabled) =>
Expand Down
1 change: 0 additions & 1 deletion dash/app/src/lib/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function user(id: UUID): User {
return {
id,
name: ``,
canUseTimeFeatures: true,
keyloggingEnabled: false,
screenshotsEnabled: false,
screenshotsResolution: 1000,
Expand Down
1 change: 0 additions & 1 deletion dash/app/src/pairql/noopClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const noopClient: ApiClient = {
return Result.success({
id: ``,
name: ``,
canUseTimeFeatures: true,
keyloggingEnabled: false,
screenshotsEnabled: false,
screenshotsResolution: 1000,
Expand Down
1 change: 0 additions & 1 deletion dash/app/src/reducers/__tests__/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function user(override: Partial<User> = {}): User {
return {
id: uuid(),
name: `Huck`,
canUseTimeFeatures: true,
screenshotsEnabled: true,
screenshotsResolution: 1000,
screenshotsFrequency: 60,
Expand Down
41 changes: 19 additions & 22 deletions dash/components/src/Keychains/KeychainCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Props =
| ({
mode: 'assign_to_child';
onRemove(): unknown;
supportsSchedule: boolean;
schedule?: Schedule;
setSchedule(schedule?: Schedule): unknown;
} & Common)
Expand Down Expand Up @@ -116,27 +115,25 @@ const KeychainCard: React.FC<Props> = ({
</Badge>
{props.mode !== `select` && (
<div className="flex items-center pr-2 gap-2">
{props.mode === `assign_to_child` &&
props.supportsSchedule &&
!props.schedule && (
<button
onClick={() => {
props.setSchedule(defaults.keychainSchedule());
setShowSchedule(true);
}}
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 select-none`,
)}
>
<ClockIcon
className={cx(`w-3.5 h-3.5 shrink-0 text-slate-500`)}
strokeWidth={2.5}
/>
<span className="text-sm text-slate-600 font-medium">
Always active
</span>
</button>
)}
{props.mode === `assign_to_child` && !props.schedule && (
<button
onClick={() => {
props.setSchedule(defaults.keychainSchedule());
setShowSchedule(true);
}}
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 select-none`,
)}
>
<ClockIcon
className={cx(`w-3.5 h-3.5 shrink-0 text-slate-500`)}
strokeWidth={2.5}
/>
<span className="text-sm text-slate-600 font-medium">
Always active
</span>
</button>
)}
{props.mode === `assign_to_child` && props.schedule && (
<button
onClick={() => {
Expand Down
54 changes: 25 additions & 29 deletions dash/components/src/Users/AddKeychainDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ interface Props {
request?: RequestState<{ own: Keychain[]; public: Keychain[] }>;
selected?: Keychain;
onSelect(keychain: Keychain): unknown;
supportsSchedule: boolean;
schedule?: Schedule;
setSchedule(schedule?: Schedule): unknown;
onDismiss(): unknown;
Expand All @@ -40,7 +39,6 @@ const AddKeychainDrawer: React.FC<Props> = ({
userName,
schedule,
setSchedule,
supportsSchedule,
}) => {
const shown = request && request.state !== `idle`;
const [whichKeychains, setWhichKeychains] = useState<'own' | 'public'>(`own`);
Expand Down Expand Up @@ -304,37 +302,35 @@ const AddKeychainDrawer: React.FC<Props> = ({
</div>
</main>
<footer className="border-t border-slate-200 bg-white relative">
{supportsSchedule && (
<div className="flex justify-start items-center gap-2 sm:h-[52px] ScheduleContainer">
{schedule ? (
<>
<KeychainSchedule schedule={schedule} setSchedule={setSchedule} />
<button
onClick={() => setSchedule(undefined)}
className="h-4 w-4 flex justify-center items-center rounded-full hover:scale-150 hover:bg-slate-200 transition-[transform,background-color] duration-200 group active:scale-100 active:bg-slate-300"
>
<TrashIcon
strokeWidth={2.2}
className="w-4 h-4 text-slate-400 group-hover:scale-75 transition-transform duration-200"
/>
</button>
</>
) : (
<div className="flex justify-start items-center gap-2 sm:h-[52px] ScheduleContainer">
{schedule ? (
<>
<KeychainSchedule schedule={schedule} setSchedule={setSchedule} />
<button
onClick={() => selected && setSchedule(defaults.keychainSchedule())}
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`,
)}
onClick={() => setSchedule(undefined)}
className="h-4 w-4 flex justify-center items-center rounded-full hover:scale-150 hover:bg-slate-200 transition-[transform,background-color] duration-200 group active:scale-100 active:bg-slate-300"
>
<ClockIcon
className={cx(`w-3.5 h-3.5 shrink-0 text-slate-500`)}
strokeWidth={2.5}
<TrashIcon
strokeWidth={2.2}
className="w-4 h-4 text-slate-400 group-hover:scale-75 transition-transform duration-200"
/>
<span className="text-sm text-slate-600 font-medium">Add schedule</span>
</button>
)}
</div>
)}
</>
) : (
<button
onClick={() => selected && setSchedule(defaults.keychainSchedule())}
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`,
)}
>
<ClockIcon
className={cx(`w-3.5 h-3.5 shrink-0 text-slate-500`)}
strokeWidth={2.5}
/>
<span className="text-sm text-slate-600 font-medium">Add schedule</span>
</button>
)}
</div>
<div className="flex flex-col sm:flex-row justify-between sm:items-end gap-4 xs:gap-8">
<div className="flex flex-col flex-grow">
<div className="flex items-center gap-2">
Expand Down
68 changes: 31 additions & 37 deletions dash/components/src/Users/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface Props {
id: string;
isNew: boolean;
name: string;
canUseTimeFeatures: boolean;
setName(name: string): unknown;
keyloggingEnabled: boolean;
setKeyloggingEnabled(enabled: boolean): unknown;
Expand Down Expand Up @@ -93,7 +92,6 @@ const EditUser: React.FC<Props> = ({
keychainSchedule,
setAddingKeychainSchedule,
setAssignedKeychainSchedule,
canUseTimeFeatures,
}) => {
if (isNew) {
return (
Expand Down Expand Up @@ -141,7 +139,6 @@ const EditUser: React.FC<Props> = ({
/>
<AddKeychainDrawer
request={fetchSelectableKeychainsRequest}
supportsSchedule={canUseTimeFeatures}
onSelect={onSelectKeychainToAdd}
onDismiss={onDismissAddKeychain}
onConfirm={onConfirmAddKeychain}
Expand Down Expand Up @@ -280,43 +277,41 @@ const EditUser: React.FC<Props> = ({
</div>

{/* downtime */}
{canUseTimeFeatures && (
<div className="mt-12 max-w-3xl">
<h2 className="text-lg font-bold text-slate-700">Downtime</h2>
<div className="mt-12 max-w-3xl">
<h2 className="text-lg font-bold text-slate-700">Downtime</h2>
<div
className={`bg-slate-100 mt-3 p-4 sm:p-6 rounded-xl overflow-hidden relative`}
>
<div className="flex justify-between items-center">
<div className="mr-3">
<h3 className="font-medium text-slate-700 leading-tight">
Enable downtime
</h3>
<p className="text-slate-500 text-sm mt-1">
Completely restrict all internet access during specified hours
</p>
</div>
<Toggle enabled={downtimeEnabled} setEnabled={setDowntimeEnabled} />
</div>
<div
className={`bg-slate-100 mt-3 p-4 sm:p-6 rounded-xl overflow-hidden relative`}
className={cx(
`flex justify-center items-center mt-4 bg-white rounded-xl p-4 gap-4 flex-col sm:flex-row md:flex-col md+:flex-row border-[0.5px] border-slate-200 shadow shadow-slate-300/50`,
downtimeEnabled || `hidden`,
)}
>
<div className="flex justify-between items-center">
<div className="mr-3">
<h3 className="font-medium text-slate-700 leading-tight">
Enable downtime
</h3>
<p className="text-slate-500 text-sm mt-1">
Completely restrict all internet access during specified hours
</p>
</div>
<Toggle enabled={downtimeEnabled} setEnabled={setDowntimeEnabled} />
</div>
<div
className={cx(
`flex justify-center items-center mt-4 bg-white rounded-xl p-4 gap-4 flex-col sm:flex-row md:flex-col md+:flex-row border-[0.5px] border-slate-200 shadow shadow-slate-300/50`,
downtimeEnabled || `hidden`,
)}
>
<span className="text-slate-500 font-medium">From</span>
<TimeInput
time={downtime.start}
setTime={(start) => setDowntime({ ...downtime, start })}
/>
<span className="text-slate-500 font-medium">to</span>
<TimeInput
time={downtime.end}
setTime={(end) => setDowntime({ ...downtime, end })}
/>
</div>
<span className="text-slate-500 font-medium">From</span>
<TimeInput
time={downtime.start}
setTime={(start) => setDowntime({ ...downtime, start })}
/>
<span className="text-slate-500 font-medium">to</span>
<TimeInput
time={downtime.end}
setTime={(end) => setDowntime({ ...downtime, end })}
/>
</div>
</div>
)}
</div>

{/* keychains */}
<div className="mt-12 max-w-3xl">
Expand All @@ -326,7 +321,6 @@ const EditUser: React.FC<Props> = ({
<KeychainCard
mode="assign_to_child"
schedule={keychain.schedule}
supportsSchedule={canUseTimeFeatures}
key={keychain.id}
name={keychain.name}
description={keychain.description}
Expand Down
1 change: 0 additions & 1 deletion dash/types/src/pairql/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export interface User {
keychains: UserKeychainSummary[];
downtime?: PlainTimeWindow;
devices: UserDevice[];
canUseTimeFeatures: boolean;
createdAt: ISODateString;
}

Expand Down
2 changes: 0 additions & 2 deletions storybook/stories/dash/Keychains/KeychainCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const ListPublic: Story = props({
const NotDuringSchoolHours: Story = props({
numKeys: 12,
isPublic: true,
supportsSchedule: true,
onRemove: () => {},
editUrl: undefined,
mode: `assign_to_child`,
Expand Down Expand Up @@ -218,7 +217,6 @@ export const Schedulable: Story = props({
...ListPrivateNoDescription.args,
isPublic: true,
mode: `assign_to_child`,
supportsSchedule: true,
setSchedule: () => {},
onRemove: () => {},
});
Expand Down
1 change: 0 additions & 1 deletion storybook/stories/dash/Users/AddKeychainDrawer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Story = StoryObj<typeof meta>;
// @screenshot: xs,md
export const Loading: Story = props({
request: { state: `ongoing` },
supportsSchedule: true,
selected: undefined,
onSelect: () => {},
schedule: undefined,
Expand Down
1 change: 0 additions & 1 deletion storybook/stories/dash/Users/EditUser.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const Default: Story = props({
name: `Little Jimmy`,
keyloggingEnabled: true,
screenshotsEnabled: true,
canUseTimeFeatures: true,
setName: () => {},
setKeyloggingEnabled: () => {},
removeKeychain: () => {},
Expand Down
Loading